Merge branch 'private-pull-request-1479' into develop
This commit is contained in:
commit
b1eb729d2d
10 changed files with 164 additions and 2 deletions
1
Gemfile
1
Gemfile
|
@ -41,6 +41,7 @@ gem 'omniauth-google-oauth2'
|
||||||
gem 'omniauth-linkedin-oauth2'
|
gem 'omniauth-linkedin-oauth2'
|
||||||
gem 'omniauth-twitter'
|
gem 'omniauth-twitter'
|
||||||
gem 'omniauth-microsoft-office365'
|
gem 'omniauth-microsoft-office365'
|
||||||
|
gem 'omniauth-weibo-oauth2'
|
||||||
|
|
||||||
gem 'twitter'
|
gem 'twitter'
|
||||||
gem 'telegramAPI'
|
gem 'telegramAPI'
|
||||||
|
|
|
@ -95,4 +95,9 @@ App.Config.set('auth_provider_all', {
|
||||||
name: 'OAuth2'
|
name: 'OAuth2'
|
||||||
config: 'auth_oauth2'
|
config: 'auth_oauth2'
|
||||||
class: 'oauth2'
|
class: 'oauth2'
|
||||||
|
weibo:
|
||||||
|
url: '/auth/weibo'
|
||||||
|
name: 'Weibo'
|
||||||
|
config: 'auth_weibo'
|
||||||
|
class: 'weibo'
|
||||||
})
|
})
|
||||||
|
|
|
@ -56,6 +56,7 @@
|
||||||
.icon-note { width: 16px; height: 16px; }
|
.icon-note { width: 16px; height: 16px; }
|
||||||
.icon-oauth2-button { width: 29px; height: 24px; }
|
.icon-oauth2-button { width: 29px; height: 24px; }
|
||||||
.icon-office365-button { width: 29px; height: 24px; }
|
.icon-office365-button { width: 29px; height: 24px; }
|
||||||
|
.icon-weibo-button { width: 29px; height: 24px; }
|
||||||
.icon-one-ticket { width: 48px; height: 10px; }
|
.icon-one-ticket { width: 48px; height: 10px; }
|
||||||
.icon-organization { width: 16px; height: 16px; }
|
.icon-organization { width: 16px; height: 16px; }
|
||||||
.icon-outbound-calls { width: 17px; height: 17px; }
|
.icon-outbound-calls { width: 17px; height: 17px; }
|
||||||
|
@ -97,4 +98,4 @@
|
||||||
.icon-user { width: 16px; height: 16px; }
|
.icon-user { width: 16px; height: 16px; }
|
||||||
.icon-web { width: 17px; height: 17px; }
|
.icon-web { width: 17px; height: 17px; }
|
||||||
.icon-zoom-in { width: 20px; height: 20px; }
|
.icon-zoom-in { width: 20px; height: 20px; }
|
||||||
.icon-zoom-out { width: 20px; height: 20px; }
|
.icon-zoom-out { width: 20px; height: 20px; }
|
||||||
|
|
|
@ -2645,6 +2645,10 @@ ol.tabs li {
|
||||||
background: hsl(15,100%,47%);
|
background: hsl(15,100%,47%);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.auth-provider--weibo {
|
||||||
|
background: hsl(0,0%,27%);
|
||||||
|
}
|
||||||
|
|
||||||
.provider-name {
|
.provider-name {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,4 +46,7 @@ Rails.application.config.middleware.use OmniAuth::Builder do
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# weibo database connect
|
||||||
|
provider :weibo_database, 'not_change_will_be_set_by_database', 'not_change_will_be_set_by_database'
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
63
db/migrate/20170924054554_weibo_oauth2.rb
Normal file
63
db/migrate/20170924054554_weibo_oauth2.rb
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
class WeiboOauth2 < ActiveRecord::Migration[4.2]
|
||||||
|
def up
|
||||||
|
|
||||||
|
# return if it's a new setup
|
||||||
|
return if !Setting.find_by(name: 'system_init_done')
|
||||||
|
Setting.create_if_not_exists(
|
||||||
|
title: 'Authentication via %s',
|
||||||
|
name: 'auth_weibo',
|
||||||
|
area: 'Security::ThirdPartyAuthentication',
|
||||||
|
description: 'Enables user authentication via %s. Register your app first at [%s](%s).',
|
||||||
|
options: {
|
||||||
|
form: [
|
||||||
|
{
|
||||||
|
display: '',
|
||||||
|
null: true,
|
||||||
|
name: 'auth_weibo',
|
||||||
|
tag: 'boolean',
|
||||||
|
options: {
|
||||||
|
true => 'yes',
|
||||||
|
false => 'no',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
preferences: {
|
||||||
|
controller: 'SettingsAreaSwitch',
|
||||||
|
sub: ['auth_weibo_credentials'],
|
||||||
|
title_i18n: ['Weibo'],
|
||||||
|
description_i18n: ['Weibo', 'Sina Weibo Open Portal', 'http://open.weibo.com'],
|
||||||
|
permission: ['admin.security'],
|
||||||
|
},
|
||||||
|
state: false,
|
||||||
|
frontend: true
|
||||||
|
)
|
||||||
|
Setting.create_if_not_exists(
|
||||||
|
title: 'Weibo App Credentials',
|
||||||
|
name: 'auth_weibo_credentials',
|
||||||
|
area: 'Security::ThirdPartyAuthentication::Weibo',
|
||||||
|
description: 'Enables user authentication via Sina Weibo.',
|
||||||
|
options: {
|
||||||
|
form: [
|
||||||
|
{
|
||||||
|
display: 'App ID',
|
||||||
|
null: true,
|
||||||
|
name: 'app_id',
|
||||||
|
tag: 'input',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
display: 'App Secret',
|
||||||
|
null: true,
|
||||||
|
name: 'app_secret',
|
||||||
|
tag: 'input',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
state: {},
|
||||||
|
preferences: {
|
||||||
|
permission: ['admin.security'],
|
||||||
|
},
|
||||||
|
frontend: false
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
|
@ -1274,6 +1274,63 @@ Setting.create_if_not_exists(
|
||||||
frontend: false
|
frontend: false
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Setting.create_if_not_exists(
|
||||||
|
title: 'Authentication via %s',
|
||||||
|
name: 'auth_weibo',
|
||||||
|
area: 'Security::ThirdPartyAuthentication',
|
||||||
|
description: 'Enables user authentication via %s. Register your app first at [%s](%s).',
|
||||||
|
options: {
|
||||||
|
form: [
|
||||||
|
{
|
||||||
|
display: '',
|
||||||
|
null: true,
|
||||||
|
name: 'auth_weibo',
|
||||||
|
tag: 'boolean',
|
||||||
|
options: {
|
||||||
|
true => 'yes',
|
||||||
|
false => 'no',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
preferences: {
|
||||||
|
controller: 'SettingsAreaSwitch',
|
||||||
|
sub: ['auth_weibo_credentials'],
|
||||||
|
title_i18n: ['Weibo'],
|
||||||
|
description_i18n: ['Sina Weibo', 'Sina Weibo Open Protal', 'http://open.weibo.com'],
|
||||||
|
permission: ['admin.security'],
|
||||||
|
},
|
||||||
|
state: false,
|
||||||
|
frontend: true
|
||||||
|
)
|
||||||
|
Setting.create_if_not_exists(
|
||||||
|
title: 'Weibo App Credentials',
|
||||||
|
name: 'auth_weibo_credentials',
|
||||||
|
area: 'Security::ThirdPartyAuthentication::Weibo',
|
||||||
|
description: 'Enables user authentication via Weibo.',
|
||||||
|
options: {
|
||||||
|
form: [
|
||||||
|
{
|
||||||
|
display: 'App ID',
|
||||||
|
null: true,
|
||||||
|
name: 'client_id',
|
||||||
|
tag: 'input',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
display: 'App Secret',
|
||||||
|
null: true,
|
||||||
|
name: 'client_secret',
|
||||||
|
tag: 'input',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
state: {},
|
||||||
|
preferences: {
|
||||||
|
permission: ['admin.security'],
|
||||||
|
},
|
||||||
|
frontend: false
|
||||||
|
)
|
||||||
|
|
||||||
Setting.create_if_not_exists(
|
Setting.create_if_not_exists(
|
||||||
title: 'Minimum length',
|
title: 'Minimum length',
|
||||||
name: 'password_min_size',
|
name: 'password_min_size',
|
||||||
|
|
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 64 KiB |
15
public/assets/images/icons/weibo-button.svg
Normal file
15
public/assets/images/icons/weibo-button.svg
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<svg width="29px" height="24px" viewBox="0 0 29 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<!-- Generator: Sketch 46.2 (44496) - http://www.bohemiancoding.com/sketch -->
|
||||||
|
<title>icon-weibo-button</title>
|
||||||
|
<desc>Created with Sketch.</desc>
|
||||||
|
<defs></defs>
|
||||||
|
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||||
|
<g id="weibo-button" fill-rule="nonzero" fill="#ffffff">
|
||||||
|
<path d="M12.183,21.53472 C7.38,21.99168 3.234,19.90368 2.922,16.88064 C2.61,13.85184 6.252,11.0352 11.05,10.57824 C15.853,10.12128 19.999,12.20928 20.305,15.23232 C20.622,18.26112 16.98,21.08352 12.183,21.53472 Z M21.784,11.4912 C21.376,11.3712 21.093,11.29536 21.308,10.77888 C21.772,9.65856 21.818,8.69664 21.314,8.00544 C20.374,6.71712 17.797,6.7824 14.846,7.9728 C14.846,7.9728 13.917,8.35872 14.155,7.65696 C14.608,6.2544 14.54,5.08512 13.832,4.40544 C12.229,2.86656 7.97,4.46496 4.316,7.9728 C1.586,10.58784 0,13.3776 0,15.78624 C0,20.38656 6.151,23.18688 12.166,23.18688 C20.05,23.18688 25.301,18.78816 25.301,15.29664 C25.301,13.18176 23.449,11.9856 21.784,11.49024 L21.784,11.4912 Z" id="Shape"></path>
|
||||||
|
<path d="M27.023,3.06336 C25.12,1.03488 22.31,0.26304 19.716,0.79008 L19.716,0.79008 C19.116,0.91488 18.736,1.48032 18.866,2.05152 C18.996,2.62752 19.58,2.99232 20.18,2.86752 C22.026,2.49216 24.02,3.04128 25.374,4.48224 C26.728,5.9232 27.096,7.8864 26.512,9.6048 L26.512,9.6048 C26.325,10.16448 26.642,10.76256 27.226,10.94784 C27.809,11.12736 28.432,10.82304 28.625,10.2624 L28.625,10.25664 C29.441,7.8528 28.925,5.09088 27.022,3.0624 L27.023,3.06336 Z" id="Shape"></path>
|
||||||
|
<path d="M24.095,5.60256 C23.166,4.6128 21.795,4.23744 20.538,4.49856 C20.023,4.60224 19.694,5.09664 19.802,5.59104 C19.915,6.08544 20.425,6.40128 20.935,6.2928 L20.935,6.2928 C21.552,6.168 22.221,6.35232 22.674,6.83136 C23.127,7.3152 23.252,7.9728 23.053,8.54976 L23.053,8.54976 C22.894,9.02784 23.166,9.55008 23.67,9.70752 C24.174,9.86016 24.712,9.59904 24.876,9.1152 C25.272,7.93536 25.023,6.58656 24.094,5.60256 L24.095,5.60256 Z" id="Shape"></path>
|
||||||
|
<path d="M12.45,16.05888 C12.28,16.33632 11.912,16.46688 11.623,16.35264 C11.334,16.24416 11.249,15.92832 11.413,15.6624 C11.583,15.39552 11.94,15.26592 12.223,15.36864 C12.506,15.46656 12.608,15.77664 12.45,16.05888 Z M10.915,17.94048 C10.451,18.6528 9.454,18.96288 8.706,18.63648 C7.97,18.31584 7.749,17.48928 8.213,16.79328 C8.672,16.10304 9.635,15.79296 10.377,16.09152 C11.13,16.4016 11.374,17.2224 10.915,17.94048 Z M12.659,12.90528 C10.376,12.33408 7.794,13.42752 6.802,15.35712 C5.788,17.32512 6.768,19.5168 9.073,20.23488 C11.463,20.97408 14.284,19.8384 15.264,17.71776 C16.233,15.63552 15.026,13.49856 12.659,12.90528 L12.659,12.90528 Z" id="Shape"></path>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 2.8 KiB |
13
vendor/lib/weibo_database.rb
vendored
Normal file
13
vendor/lib/weibo_database.rb
vendored
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
class WeiboDatabase < OmniAuth::Strategies::Weibo
|
||||||
|
option :name, 'weibo'
|
||||||
|
|
||||||
|
def initialize(app, *args, &block)
|
||||||
|
|
||||||
|
# database lookup
|
||||||
|
config = Setting.get('auth_weibo_credentials') || {}
|
||||||
|
args[0] = config['client_id']
|
||||||
|
args[1] = config['client_secret']
|
||||||
|
super
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
Loading…
Reference in a new issue