GitLab oauth2.0 第三方登录 单点登录

GitLab oauth2.0 第三方登录 单点登录

  • 不废话,直接上代码

不废话,直接上代码


## Oauth2.0配置
gitlab_rails['omniauth_enabled'] = true
## 与显示的name保持一致
gitlab_rails['omniauth_allow_single_sign_on'] = ['ssdlc']
## true时,创建的用户会被封锁
gitlab_rails['omniauth_block_auto_created_users'] = false
gitlab_rails['omniauth_providers'] = [
  {
    'name' => 'ssdlc',
	# 图标base64
    'icon': 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAABVKSURBVHhe5VvZb1zXff5m3zhDUqS4SaL23ZYly5Ij2IblxJWdxkmaxm2RoAjQAulzH/IH5L2veSwCtEX6ELdNEcVtnNaFnciSLcWRtVv7QlEU9yFn3/t9584h74xmqJElFQX8sw/nLuee8/t957eee+WpkfAlJm/990tLX3oAnqoJVDlyqVxDka1cBgqlKvJFnpeACm+6Z/Z4AJ/Xg6AfCAY88Ps9CPE3HPQgwGPeeir0VACoVkFBq0hnq5hZZFuoIKVj/k7Nl7GQriFXqKBcgQHBCO8DwiEfero86O3yoiviRV+3D2v6A+jv9iIe9SIU9Bog1P9J0RMDoEKhi6UaV7mGZLqCq3dLuHS7gFv3y0imKuZ6SVpADdBvldNqZju7BPPyTyAABAiG3+dogEDYMOTHjvUhjA740R1zwImy+Z6AAT82AFLzbKGGydkybk6UcG+mbIS/M8mVzlSMylfVyZCWrsYVbMf5g6x42TUU8CIRJRgJH/p7fNg+GsTeLSEM9fkQDVErHgOILwyAnpJ9z3F1T18t4MS5PG5PlpDOSb1p8xUN+6CwUt9WU3pbSFGVLVniIx4+7Kd2xKkFm0cCOLQ7hN0bQ1gV9yES9tJX1Ps+An0hAMSXVFr2/MnFPH53NmeEz1NwimwY1VpbW3VP0UrQTkhg2GE0bphasW7ARwCC2LI2iD3UiNU0l0cd/pG5kTansh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U3EDoOktAHoVLgB64s7WtcLs4Cpf/VtjCl4f90nSUwVAAytWS+VlIkqhJbSqSp27p1Yy5ZiBSmeFOO3/6z2e4weehvCipwrA/38C/hfEQ2ZgueHngAAAAABJRU5ErkJggg==',
    'app_id' => 'gitlab',
    'app_secret' => 'gitlab',
    'args' => {
      client_options: {
        'site' => 'http://10.0.1.100:84', # including port if necessary
        'user_info_url' => '/user/info',
		 'authorize_url': '/oauth/authorize', # The authorization endpoint for your OAuth server
         'token_url': '/oauth/token' # The token request endpoint for your OAuth server

      },
      user_response_structure: {
        root_path: [], # i.e. if attributes are returned in JsonAPI format (in a 'user' node nested under a 'data' node)
		id_path: 'uuid',
		#/user/info返回对象对应的属性
        attributes: { 
		name: 'fullName',
		username: 'username',
		public_email: 'email',
		email: 'email',
		commit_email: 'email'
		} # if the nickname attribute of a user is called 'username'
      },
      # optionally, you can add the following two lines to "white label" the display name
      # of this strategy (appears in urls and Gitlab login buttons)
      # If you do this, you must also replace oauth2_generic, everywhere it appears above, with the new name. 
      name: 'ssdlc', # display name for this strategy
      strategy_class: "OmniAuth::Strategies::OAuth2Generic", # Devise-specific config option Gitlab uses to find renamed strategy
	  ## */ssdlc/*与显示的name保持一致
      redirect_url: "http://10.0.1.104:9980/users/auth/ssdlc/callback" 
	}
  }
]

#>>>>>>系统邮箱配置.start
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.office365.com"
gitlab_rails['smtp_port'] = 587
gitlab_rails['smtp_user_name'] = "xieshaoping@***.cn"
gitlab_rails['smtp_password'] = "******"
gitlab_rails['smtp_domain'] = "smtp.office365.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
## 要设置为false,否则SSL容易报错
gitlab_rails['smtp_tls'] = false
gitlab_rails['gitlab_email_from'] = 'xieshaoping@***.cn' 
##<<<<<<系统邮箱配置.end

## docker端口-p 9980:9980,-p 9980:80会打不开
# 域名配置
external_url 'http://10.0.1.104:9980' 
gitlab_rails['gitlab_ssh_host'] = "10.0.1.104"
gitlab_rails['gitlab_shell_ssh_port'] = 9922

如有其他问题可联系作者:

手机、微信:15385125253

QQ:987319557

公司名称:开源互联网安全技术有限公司

原创作者:谢少评
原创不易,一分也是爱:

微信:

GitLab oauth2.0 第三方登录 单点登录_第1张图片

支付宝:
GitLab oauth2.0 第三方登录 单点登录_第2张图片

你可能感兴趣的:(技术分享,gitLab,Oauth2.0,gitlab,oauth2,git,后端,服务器)