Yandex OAuth GitLab 用户认证
Yandex OAuth GitLab user authentication
我想通过Yandex.OAuth验证gitlab用户。我正在尝试使用 oauth2_generic
策略,但无法获取用户信息。有谁知道怎么配置吗?
最后,我得到了解决方案:
gitlab_rails['omniauth_enabled'] = true
gitlab_rails['omniauth_allow_single_sign_on'] = ['Yandex']
gitlab_rails['omniauth_block_auto_created_users'] = false
gitlab_rails['omniauth_providers'] = [
{
"name" => "oauth2_generic",
"app_id" => "your-app-id",
"app_secret" => "your-app-secret",
"args" => {
client_options: {
"site" => "https://oauth.yandex.ru",
"authorize_url" => "/authorize",
"token_url" => "/token",
"user_info_url" => "https://login.yandex.ru/info",
},
user_response_structure: {
attributes: {
name: 'login',
email: 'default_email',
first_name: 'first_name',
last_name: 'last_name'
}
},
redirect_url: 'http://your-gitlab-host/users/auth/Yandex/callback',
name: 'Yandex',
strategy_class: "OmniAuth::Strategies::OAuth2Generic"
}
}
]
您需要注册一个具有Yandex.PassportAPI(登录)权限的新客户端,例如:访问用户名、访问电子邮件地址、等等
然后将app_id
和app_secret
填入gitlab配置。就是这样!
我想通过Yandex.OAuth验证gitlab用户。我正在尝试使用 oauth2_generic
策略,但无法获取用户信息。有谁知道怎么配置吗?
最后,我得到了解决方案:
gitlab_rails['omniauth_enabled'] = true
gitlab_rails['omniauth_allow_single_sign_on'] = ['Yandex']
gitlab_rails['omniauth_block_auto_created_users'] = false
gitlab_rails['omniauth_providers'] = [
{
"name" => "oauth2_generic",
"app_id" => "your-app-id",
"app_secret" => "your-app-secret",
"args" => {
client_options: {
"site" => "https://oauth.yandex.ru",
"authorize_url" => "/authorize",
"token_url" => "/token",
"user_info_url" => "https://login.yandex.ru/info",
},
user_response_structure: {
attributes: {
name: 'login',
email: 'default_email',
first_name: 'first_name',
last_name: 'last_name'
}
},
redirect_url: 'http://your-gitlab-host/users/auth/Yandex/callback',
name: 'Yandex',
strategy_class: "OmniAuth::Strategies::OAuth2Generic"
}
}
]
您需要注册一个具有Yandex.PassportAPI(登录)权限的新客户端,例如:访问用户名、访问电子邮件地址、等等
然后将app_id
和app_secret
填入gitlab配置。就是这样!