Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
1347b8d81b4f
Commit
c2b33d3b
authored
Mar 04, 2016
by
James Lopez
Browse files
added import url exposer to construct URL withunencrypted credentials
parent
4c74ed9d1cb1
Changes
5
Hide whitespace changes
Inline
Side-by-side
app/models/project_import_data.rb
View file @
1347b8d8
...
...
@@ -13,6 +13,7 @@
class
ProjectImportData
<
ActiveRecord
::
Base
belongs_to
:project
attr_encrypted
:credentials
,
key:
Gitlab
::
Application
.
secrets
.
db_key_base
serialize
:credentials
,
JSON
serialize
:data
,
JSON
...
...
lib/gitlab/github_import/importer.rb
View file @
1347b8d8
...
...
@@ -7,8 +7,7 @@ class Importer
def
initialize
(
project
)
@project
=
project
import_data
=
project
.
import_data
.
try
(
:data
)
github_session
=
import_data
[
"github_session"
]
if
import_data
github_session
=
project
.
import_data
.
credentials
if
import_data
@client
=
Client
.
new
(
github_session
[
"github_access_token"
])
@formatter
=
Gitlab
::
ImportFormatter
.
new
end
...
...
lib/gitlab/github_import/project_creator.rb
View file @
1347b8d8
...
...
@@ -32,8 +32,8 @@ def execute
def
create_import_data
(
project
)
project
.
create_import_data
(
credentials:
session_data
.
delete
(
:github_access_token
),
data:
{
"
github_session
"
=>
session_data
})
credentials:
{
github_access_token:
session_data
.
delete
(
:github_access_token
)
}
,
data:
{
github_session
:
session_data
})
end
end
end
...
...
lib/gitlab/github_import/wiki_formatter.rb
View file @
1347b8d8
...
...
@@ -12,7 +12,9 @@ def path_with_namespace
end
def
import_url
project
.
import_url
.
sub
(
/\.git\z/
,
".wiki.git"
)
import_url
=
Gitlab
::
ImportUrlExposer
.
expose
(
import_url:
project
.
import_url
,
credentials:
project
.
import_data
.
credentials
)
import_url
.
sub
(
/\.git\z/
,
".wiki.git"
)
end
end
end
...
...
lib/gitlab/import_url_exposer.rb
0 → 100644
View file @
1347b8d8
module
Gitlab
# Exposes an import URL that includes the credentials unencrypted.
# Extracted to its own class to prevent unintended use.
module
ImportUrlExposer
extend
self
def
expose
(
import_url
:,
credentials:
)
import_url
.
sub
(
"//"
,
"//
#{
parsed_credentials
(
credentials
)
}
@"
)
end
private
def
parsed_credentials
(
credentials
)
credentials
.
values
.
join
(
":"
)
end
end
end
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment