Fixed issue #596 - Gitlab Auth not working.
This commit is contained in:
parent
d36570aef0
commit
9e00143134
7 changed files with 124 additions and 34 deletions
|
@ -11,34 +11,45 @@ class Index extends App.ControllerSubContent
|
|||
render: =>
|
||||
auth_provider_all = {
|
||||
facebook: {
|
||||
key: 'facebook'
|
||||
url: '/auth/facebook',
|
||||
name: 'Facebook',
|
||||
config: 'auth_facebook',
|
||||
url: '/auth/facebook'
|
||||
name: 'Facebook'
|
||||
config: 'auth_facebook'
|
||||
},
|
||||
twitter: {
|
||||
key: 'twitter'
|
||||
url: '/auth/twitter',
|
||||
name: 'Twitter',
|
||||
config: 'auth_twitter',
|
||||
url: '/auth/twitter'
|
||||
name: 'Twitter'
|
||||
config: 'auth_twitter'
|
||||
},
|
||||
linkedin: {
|
||||
key: 'linkedin'
|
||||
url: '/auth/linkedin',
|
||||
name: 'LinkedIn',
|
||||
config: 'auth_linkedin',
|
||||
url: '/auth/linkedin'
|
||||
name: 'LinkedIn'
|
||||
config: 'auth_linkedin'
|
||||
},
|
||||
github: {
|
||||
url: '/auth/github'
|
||||
name: 'GitHub'
|
||||
config: 'auth_github'
|
||||
},
|
||||
gitlab: {
|
||||
url: '/auth/gitlab'
|
||||
name: 'GitLab'
|
||||
config: 'auth_gitlab'
|
||||
},
|
||||
google_oauth2: {
|
||||
key: 'google_oauth2'
|
||||
url: '/auth/google_oauth2',
|
||||
name: 'Google',
|
||||
config: 'auth_google_oauth2',
|
||||
url: '/auth/google_oauth2'
|
||||
name: 'Google'
|
||||
config: 'auth_google_oauth2'
|
||||
},
|
||||
oauth2: {
|
||||
url: '/auth/oauth2'
|
||||
name: 'OAuth2'
|
||||
config: 'auth_oauth2'
|
||||
},
|
||||
}
|
||||
auth_providers = []
|
||||
auth_providers = {}
|
||||
for key, provider of auth_provider_all
|
||||
if @Config.get(provider.config) is true || @Config.get(provider.config) is 'true'
|
||||
auth_providers.push provider
|
||||
auth_providers[key] = provider
|
||||
|
||||
@html App.view('profile/linked_accounts')(
|
||||
user: App.Session.get()
|
||||
|
@ -54,7 +65,7 @@ class Index extends App.ControllerSubContent
|
|||
@ajax(
|
||||
id: 'account'
|
||||
type: 'DELETE'
|
||||
url: @apiPath + '/users/account'
|
||||
url: "#{@apiPath}/users/account"
|
||||
data: JSON.stringify(provider: provider, uid: uid)
|
||||
processData: true
|
||||
success: @success
|
||||
|
|
|
@ -40,9 +40,9 @@ class Index extends App.ControllerContent
|
|||
render: (data = {}) ->
|
||||
auth_provider_all = {
|
||||
facebook: {
|
||||
url: '/auth/facebook'
|
||||
name: 'Facebook'
|
||||
config: 'auth_facebook'
|
||||
url: '/auth/facebook',
|
||||
name: 'Facebook',
|
||||
config: 'auth_facebook',
|
||||
class: 'facebook'
|
||||
},
|
||||
twitter: {
|
||||
|
@ -59,13 +59,13 @@ class Index extends App.ControllerContent
|
|||
},
|
||||
github: {
|
||||
url: '/auth/github'
|
||||
name: 'Github'
|
||||
name: 'GitHub'
|
||||
config: 'auth_github'
|
||||
class: 'github'
|
||||
},
|
||||
gitlab: {
|
||||
url: '/auth/gitlab'
|
||||
name: 'Gitlab'
|
||||
name: 'GitLab'
|
||||
config: 'auth_gitlab'
|
||||
class: 'gitlab'
|
||||
},
|
||||
|
@ -75,6 +75,12 @@ class Index extends App.ControllerContent
|
|||
config: 'auth_google_oauth2'
|
||||
class: 'google'
|
||||
},
|
||||
oauth2: {
|
||||
url: '/auth/oauth2'
|
||||
name: 'OAuth2'
|
||||
config: 'auth_oauth2'
|
||||
class: 'oauth2'
|
||||
},
|
||||
}
|
||||
auth_providers = []
|
||||
for key, provider of auth_provider_all
|
||||
|
|
|
@ -5,10 +5,12 @@
|
|||
</div>
|
||||
<div class="page-content">
|
||||
<ul>
|
||||
<% for auth_provider in @auth_providers: %>
|
||||
<li> <%- @T( auth_provider.name ) %>
|
||||
<% if !@user['accounts'] || !@user['accounts'][auth_provider.key]: %><a href="<%= auth_provider.url %>"><%- @T('Add') %></a>
|
||||
<% else: %>"<%= @user['accounts'][auth_provider.key]['username'] %>" <a href="#" data-uid="<%= @user['accounts'][auth_provider.key]['uid'] %>" data-provider="<%= auth_provider.key %>" class="js-remove"><%- @T('remove') %></a>
|
||||
<% for key, provider of @auth_providers: %>
|
||||
<li> <%- @T( provider.name ) %>
|
||||
<% if !@user['accounts'] || !@user['accounts'][key]: %><a href="<%= provider.url %>">
|
||||
<%- @T('Add') %></a>
|
||||
<% else: %>
|
||||
"<%= @user['accounts'][key]['username'] %>" <a href="#" data-uid="<%= @user['accounts'][key]['uid'] %>" data-provider="<%= key %>" class="js-remove"><%- @T('remove') %></a>
|
||||
<% end %>
|
||||
</li>
|
||||
<% end %>
|
||||
|
|
|
@ -1,17 +1,47 @@
|
|||
Rails.application.config.middleware.use OmniAuth::Builder do
|
||||
|
||||
# twitter database connect
|
||||
provider :twitter_database, 'not_change_will_be_set_by_databse', 'not_change_will_be_set_by_databse',
|
||||
client_options: { authorize_path: '/oauth/authorize', site: 'https://api.twitter.com' }
|
||||
provider :twitter_database, 'not_change_will_be_set_by_database', 'not_change_will_be_set_by_database', {
|
||||
client_options: {
|
||||
authorize_path: '/oauth/authorize',
|
||||
site: 'https://api.twitter.com',
|
||||
}
|
||||
}
|
||||
|
||||
# facebook database connect
|
||||
provider :facebook_database, 'not_change_will_be_set_by_databse', 'not_change_will_be_set_by_databse'
|
||||
provider :facebook_database, 'not_change_will_be_set_by_database', 'not_change_will_be_set_by_database'
|
||||
|
||||
# linkedin database connect
|
||||
provider :linked_in_database, 'not_change_will_be_set_by_databse', 'not_change_will_be_set_by_databse'
|
||||
provider :linked_in_database, 'not_change_will_be_set_by_database', 'not_change_will_be_set_by_database'
|
||||
|
||||
# google database connect
|
||||
provider :google_oauth2_database, 'not_change_will_be_set_by_databse', 'not_change_will_be_set_by_databse',
|
||||
authorize_options: { access_type: 'online', approval_prompt: '' }
|
||||
provider :google_oauth2_database, 'not_change_will_be_set_by_database', 'not_change_will_be_set_by_database', {
|
||||
authorize_options: {
|
||||
access_type: 'online',
|
||||
approval_prompt: '',
|
||||
}
|
||||
}
|
||||
|
||||
# github database connect
|
||||
provider :github_database, 'not_change_will_be_set_by_database', 'not_change_will_be_set_by_database'
|
||||
|
||||
# gitlab database connect
|
||||
provider :gitlab_database, 'not_change_will_be_set_by_database', 'not_change_will_be_set_by_database', {
|
||||
client_options: {
|
||||
site: 'https://not_change_will_be_set_by_database',
|
||||
authorize_url: '/oauth/authorize',
|
||||
token_url: '/oauth/token'
|
||||
},
|
||||
scope: 'read_user',
|
||||
}
|
||||
|
||||
# oauth2 database connect
|
||||
provider :oauth2_database, 'not_change_will_be_set_by_database', 'not_change_will_be_set_by_database', {
|
||||
client_options: {
|
||||
site: 'https://not_change_will_be_set_by_database',
|
||||
authorize_url: '/oauth/authorize',
|
||||
token_url: '/oauth/token',
|
||||
},
|
||||
}
|
||||
|
||||
end
|
||||
|
|
13
vendor/lib/github_database.rb
vendored
Normal file
13
vendor/lib/github_database.rb
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
class GithubDatabase < OmniAuth::Strategies::GitHub
|
||||
option :name, 'github'
|
||||
|
||||
def initialize(app, *args, &block)
|
||||
|
||||
# database lookup
|
||||
config = Setting.get('auth_github_credentials') || {}
|
||||
args[0] = config['app_id']
|
||||
args[1] = config['app_secret']
|
||||
super
|
||||
end
|
||||
|
||||
end
|
14
vendor/lib/gitlab_database.rb
vendored
Normal file
14
vendor/lib/gitlab_database.rb
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
class GitlabDatabase < OmniAuth::Strategies::GitLab
|
||||
option :name, 'gitlab'
|
||||
|
||||
def initialize(app, *args, &block)
|
||||
|
||||
# database lookup
|
||||
config = Setting.get('auth_gitlab_credentials') || {}
|
||||
args[0] = config['app_id']
|
||||
args[1] = config['app_secret']
|
||||
args[2][:client_options] = args[2][:client_options].merge(config.symbolize_keys)
|
||||
super
|
||||
end
|
||||
|
||||
end
|
14
vendor/lib/oauth2_database.rb
vendored
Normal file
14
vendor/lib/oauth2_database.rb
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
class Oauth2Database < OmniAuth::Strategies::OAuth2
|
||||
option :name, 'oauth2'
|
||||
|
||||
def initialize(app, *args, &block)
|
||||
|
||||
# database lookup
|
||||
config = Setting.get('auth_oauth2_credentials') || {}
|
||||
args[0] = config['app_id']
|
||||
args[1] = config['app_secret']
|
||||
args[2][:client_options] = args[2][:client_options].merge(config.symbolize_keys)
|
||||
super
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in a new issue