Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
448817c4
Commit
448817c4
authored
Feb 17, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Load public key in initializer.
parent
ad6d6232
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
44 additions
and
15 deletions
+44
-15
app/controllers/application_controller.rb
app/controllers/application_controller.rb
+13
-0
app/controllers/import/bitbucket_controller.rb
app/controllers/import/bitbucket_controller.rb
+5
-0
app/controllers/import/github_controller.rb
app/controllers/import/github_controller.rb
+5
-0
app/controllers/import/gitlab_controller.rb
app/controllers/import/gitlab_controller.rb
+5
-0
app/helpers/oauth_helper.rb
app/helpers/oauth_helper.rb
+2
-0
app/helpers/projects_helper.rb
app/helpers/projects_helper.rb
+0
-12
config/initializers/public_key.rb
config/initializers/public_key.rb
+2
-0
lib/gitlab/bitbucket_import.rb
lib/gitlab/bitbucket_import.rb
+6
-0
lib/gitlab/bitbucket_import/key_adder.rb
lib/gitlab/bitbucket_import/key_adder.rb
+6
-3
No files found.
app/controllers/application_controller.rb
View file @
448817c4
...
...
@@ -16,6 +16,7 @@ class ApplicationController < ActionController::Base
protect_from_forgery
with: :exception
helper_method
:abilities
,
:can?
,
:current_application_settings
helper_method
:github_import_enabled?
,
:gitlab_import_enabled?
,
:bitbucket_import_enabled?
rescue_from
Encoding
::
CompatibilityError
do
|
exception
|
log_exception
(
exception
)
...
...
@@ -313,4 +314,16 @@ class ApplicationController < ActionController::Base
set_filter_values
(
merge_requests
)
merge_requests
end
def
github_import_enabled?
OauthHelper
.
enabled_oauth_providers
.
include?
(
:github
)
end
def
gitlab_import_enabled?
OauthHelper
.
enabled_oauth_providers
.
include?
(
:gitlab
)
end
def
bitbucket_import_enabled?
OauthHelper
.
enabled_oauth_providers
.
include?
(
:bitbucket
)
&&
Gitlab
::
BitbucketImport
.
public_key
.
present?
end
end
app/controllers/import/bitbucket_controller.rb
View file @
448817c4
class
Import::BitbucketController
<
Import
::
BaseController
before_filter
:verify_bitbucket_import_enabled
before_filter
:bitbucket_auth
,
except: :callback
# rescue_from OAuth::Error, with: :bitbucket_unauthorized
...
...
@@ -55,6 +56,10 @@ class Import::BitbucketController < Import::BaseController
@client
||=
Gitlab
::
BitbucketImport
::
Client
.
new
(
current_user
.
bitbucket_access_token
,
current_user
.
bitbucket_access_token_secret
)
end
def
verify_bitbucket_import_enabled
not_found!
unless
bitbucket_import_enabled?
end
def
bitbucket_auth
if
current_user
.
bitbucket_access_token
.
blank?
go_to_bitbucket_for_permissions
...
...
app/controllers/import/github_controller.rb
View file @
448817c4
class
Import::GithubController
<
Import
::
BaseController
before_filter
:verify_github_import_enabled
before_filter
:github_auth
,
except: :callback
rescue_from
Octokit
::
Unauthorized
,
with: :github_unauthorized
...
...
@@ -44,6 +45,10 @@ class Import::GithubController < Import::BaseController
@client
||=
Gitlab
::
GithubImport
::
Client
.
new
(
current_user
.
github_access_token
)
end
def
verify_github_import_enabled
not_found!
unless
github_import_enabled?
end
def
github_auth
if
current_user
.
github_access_token
.
blank?
go_to_github_for_permissions
...
...
app/controllers/import/gitlab_controller.rb
View file @
448817c4
class
Import::GitlabController
<
Import
::
BaseController
before_filter
:verify_gitlab_import_enabled
before_filter
:gitlab_auth
,
except: :callback
rescue_from
OAuth2
::
Error
,
with: :gitlab_unauthorized
...
...
@@ -41,6 +42,10 @@ class Import::GitlabController < Import::BaseController
@client
||=
Gitlab
::
GitlabImport
::
Client
.
new
(
current_user
.
gitlab_access_token
)
end
def
verify_gitlab_import_enabled
not_found!
unless
gitlab_import_enabled?
end
def
gitlab_auth
if
current_user
.
gitlab_access_token
.
blank?
go_to_gitlab_for_permissions
...
...
app/helpers/oauth_helper.rb
View file @
448817c4
...
...
@@ -20,4 +20,6 @@ module OauthHelper
def
additional_providers
enabled_oauth_providers
.
reject
{
|
provider
|
provider
.
to_s
.
starts_with?
(
'ldap'
)}
end
extend
self
end
app/helpers/projects_helper.rb
View file @
448817c4
...
...
@@ -265,16 +265,4 @@ module ProjectsHelper
"success"
end
end
def
github_import_enabled?
enabled_oauth_providers
.
include?
(
:github
)
end
def
gitlab_import_enabled?
enabled_oauth_providers
.
include?
(
:gitlab
)
end
def
bitbucket_import_enabled?
enabled_oauth_providers
.
include?
(
:bitbucket
)
end
end
config/initializers/public_key.rb
0 → 100644
View file @
448817c4
path
=
File
.
expand_path
(
"~/.ssh/id_rsa.pub"
)
Gitlab
::
BitbucketImport
.
public_key
=
File
.
read
(
path
)
if
File
.
exist?
(
path
)
\ No newline at end of file
lib/gitlab/bitbucket_import.rb
0 → 100644
View file @
448817c4
module
Gitlab
module
BitbucketImport
mattr_accessor
:public_key
@public_key
=
nil
end
end
\ No newline at end of file
lib/gitlab/bitbucket_import/key_adder.rb
View file @
448817c4
...
...
@@ -9,13 +9,16 @@ module Gitlab
end
def
execute
return
false
unless
BitbucketImport
.
public_key
.
present?
project_identifier
=
"
#{
repo
[
"owner"
]
}
/
#{
repo
[
"slug"
]
}
"
return
true
if
client
.
deploy_key
(
project_identifier
)
# TODO: Point to actual public key.
client
.
add_deploy_key
(
project_identifier
,
File
.
read
(
"/Users/douwemaan/.ssh/id_rsa.pub"
))
client
.
add_deploy_key
(
project_identifier
,
BitbucketImport
.
public_key
)
true
rescue
false
end
end
end
...
...
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