认证中心基于 5.3.x 版本的cas-server进行二次开发,有其他问题可以参考Cas官网开发手册
bootstrap.properties
spring.application.name=ac
spring.profiles.active=prod
- spring.application.name:项目名称
- spring.profiles.active:激活的配置文件,如 application-prod.yml,这个值在application.yml中配置无效
application.yml
:::warning server.port war包部署时该值无效,只有在开发环境时有效 :::server: context-path: /ac # war包部署时该值无效,只有在开发环境时有效 port: 8080 max-http-header-size: 2097152 tomcat: max-http-post-size: 2097152 # 配置thymeleaf spring: thymeleaf: cache: false
application-${spring.profiles.active}.yml
配置文件下载application-prodserver: context-path: /ac port: 8080 max-http-header-size: 2097152 tomcat: max-http-post-size: 2097152 # 配置thymeleaf spring: thymeleaf: cache: false # 配置参考 https://apereo.github.io/cas/5.3.x/installation/Configuration-Properties.html cas: standalone: configurationDirectory: classpath:/ server: # 认证中心实际部署的地址,根据实际情况进行修改,http:ip:port 格式 name: http://192.168.59.117:30060 # 开发时是 server.context-path中横线转下划线,部署时以server.context-path为准 prefix: ${cas.server.name}${server.context-path} # view: # # 登录成功后的默认跳转地址,配置注册后的用户中心地址 # defaultRedirectUrl: http://192.168.59.117:30033/gc-starter-uc-ui/#/uc/app logout: # 登出后自动重定向到service参数指定的地址 followServiceRedirects: true # 存在时,service 后的值无效 # redirectUrl: http://localhost:8080/gc_starter_ac_war/login # 根据该参数进行获取应用、重定向等,不建议修改 redirectParameter: service # 登出时弹出对话框询问 confirmLogout: false # 是否移除子系统的票据 removeDescendantTickets: true slo: # 禁用单点登出 disabled: false # 异步通知客户端应用登出 asynchronous: true jdbc: showSql: true # 客户端注册配置 serviceRegistry: # 是否从services/*.json文件中加载客户端信息,建议关闭 initFromJson: false # 客户端注册的信息存储方式 # Redis 配置参考 https://apereo.github.io/cas/5.3.x/installation/Configuration-Properties-Common.html#redis-configuration redis: # 从哪一个database读取与存储客户端注册的信息,一定要和用户中心使用的是同一个database,否则心跳不成功 database: ${ac.redis.database} host: ${ac.redis.host} port: ${ac.redis.port} password: ${ac.redis.password} timeout: ${ac.redis.timeout} usePool: ${ac.redis.usePool} useSsl: ${ac.redis.useSsl} pool: fairness: ${ac.redis.pool.fairness} lifo: ${ac.redis.pool.lifo} max-active: ${ac.redis.pool.max-active} maxActive: ${ac.redis.pool.maxActive} maxIdle: ${ac.redis.pool.maxIdle} minIdle: ${ac.redis.pool.minIdle} maxWait: ${ac.redis.pool.maxWait} numTestsPerEvictionRun: ${ac.redis.pool.numTestsPerEvictionRun} softMinEvictableIdleTimeMillis: ${ac.redis.pool.softMinEvictableIdleTimeMillis} minEvictableIdleTimeMillis: ${ac.redis.pool.minEvictableIdleTimeMillis} testOnCreate: ${ac.redis.pool.testOnCreate} testOnBorrow: ${ac.redis.pool.testOnBorrow} testOnReturn: ${ac.redis.pool.testOnReturn} testWhileIdle: ${ac.redis.pool.testWhileIdle} # TGT、ST存储配置 ticket: registry: redis: database: ${ac.redis.database} host: ${ac.redis.host} port: ${ac.redis.port} password: ${ac.redis.password} timeout: ${ac.redis.timeout} usePool: ${ac.redis.usePool} useSsl: ${ac.redis.useSsl} pool: fairness: ${ac.redis.pool.fairness} lifo: ${ac.redis.pool.lifo} max-active: ${ac.redis.pool.max-active} maxActive: ${ac.redis.pool.maxActive} maxIdle: ${ac.redis.pool.maxIdle} minIdle: ${ac.redis.pool.minIdle} maxWait: ${ac.redis.pool.maxWait} numTestsPerEvictionRun: ${ac.redis.pool.numTestsPerEvictionRun} softMinEvictableIdleTimeMillis: ${ac.redis.pool.softMinEvictableIdleTimeMillis} minEvictableIdleTimeMillis: ${ac.redis.pool.minEvictableIdleTimeMillis} testOnCreate: ${ac.redis.pool.testOnCreate} testOnBorrow: ${ac.redis.pool.testOnBorrow} testOnReturn: ${ac.redis.pool.testOnReturn} testWhileIdle: ${ac.redis.pool.testWhileIdle} # Ticket Granting Cookie 配置 tgc: # 如果为true必须是https协议,否则无法携带TGC导致登录后,子应用无法完成单点登录 secure: false # 参考配置 https://apereo.github.io/cas/5.3.x/installation/Configuration-Properties-Common.html#settings crypto: # 开启tgc加密 enabled: true # 设置加密的key,否则在集群中,每个server会生成自己的默认的key,导致其生成的tgc无法被其他节点解密 encryption: key: nXL-DN7Xbt3HsY_Wwp9zVAUP-r4sFkZOIfAstCfpCXI signing: key: tushengN7Xbt3HsY_Wwp9zVAUP-r4sFkZOIfAstCfpCXItushengN7Xbt3HsY_Wwp9zVAUP-r4sFkZOIfAstCfpCXI authn: accept: # 默认登录用户和密码,采用JDBC、LDAP时无效 users: # jdbc配置 请参考 https://apereo.github.io/cas/5.3.x/installation/Configuration-Properties.html#query-database-authentication jdbc: query: # 数据库连接 - url: jdbc:mysql://192.168.1.4:3306/cloud_ai_1_0_0?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&rewriteBatchedStatements=true # 用户名 user: root # 密码 password: *** # 用户名查询语句 sql: select * from gc_user where username=? fieldPassword: password # 驱动类 driverClass: com.mysql.jdbc.Driver # 密码加密类 passwordEncoder: type: com.gccloud.starter.ac.encoder.MyPasswordEncoder characterEncoding: UTF-8 # 属性展示列表 principalAttributeList: username,real_name,company,phone,email,id # 异常自定义加载 exceptions: exceptions: com.gccloud.starter.ac.exception.CaptchaException,com.gccloud.starter.ac.exception.AppAuthFailedException,com.gccloud.starter.ac.exception.MobileNullException # saml2.0认证 参考:https://apereo.github.io/cas/5.3.x/installation/Configuration-Properties.html#saml-idp 配置类:SamlIdPProperties samlIdp: # 系统生成idp元数据时使用的entityId,此entityId也是sp获取idp的地址依据 entityId: ${cas.server.prefix}/idp # 系统生成idp元数据时使用的作用域 scope: '*' metadata: # cas-idp相关文件路径,包括元数据文件、加密和签名的密钥,需要注意的是这些文件名是固定的,请参照当前saml文件夹下的文件名; # 当你修改配置文件时,元数据文件并不会改变,因为当location位置已经有元文件系统就不会生成了,当你需要修改entityId、scope、密钥时,如果location位置没有变化的话,请删除元数据文件进行重新生成 location: classpath:/saml # 私钥生成算法 privateKeyAlgName: RSA # 是否需要验证元数据 requireValidMetadata: true # 元数据缓存过期时间,单位(天) cacheExpirationMinutes: 1 # 一旦资源被解析,无效的元数据是否应该在启动时迅速地主动失败 failFast: true # 防止元数据实例连接到MDQ服务器的基本认证用户名 basicAuthnUsername: # 防止元数据实例连接到MDQ服务器的基本认证密码 basicAuthnPassword: # 防止元数据实例连接到MDQ服务器支持的内容类型 supportedContentTypes: logout: # 登出请求是否必须签名 forceSignedLogoutRequests: true # 是否启用和处理SAML单点登出回调 singleLogoutCallbacksDisabled: false response: # 服务没有指定的情况下,包含在响应中的默认身份验证上下文类。 defaultAuthenticationContextClass: urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport # 表明所有属性的默认名称格式,以防单个属性没有被单独映射。 defaultAttributeNameFormat: uri # 错误响应是否应该被签名 signError: false # 以秒为单位的时间单位,用于偏移身份验证日期,如valid-from和valid-until元素。 skewAllowance: 5 # 签名编码类型: BASIC/X509 credentialType: X509 # list 每个单独的属性都可以映射到特定的名称格式。例子:attributeName->basic|uri|unspecified|custom-format-etc,.... attributeNameFormats: # oauth2.0协议配置 配置参考:https://apereo.github.io/cas/5.3.x/installation/Configuration-Properties.html#oauth2 配置类:org.apereo.cas.configuration.model.support.oauth.OAuthProperties oauth: accessToken: # accessToken最大有效时间 maxTimeToLiveInSeconds: 28800 # CAS 身份验证协议属性是否应作为此访问令牌验证的一部分发布 releaseProtocolAttributes: true # 滑动窗口时间 timeToKillInSeconds: 7200 code: # code可用次数,默认使用一次后失效 numberOfUses: 1 # code有效时间 timeToKillInSeconds: 30 grants: resourceOwner: # 授权时是否需要携带header:service requireServiceHeader: true refreshToken: # 刷新令牌硬超时时间 timeToKillInSeconds: 2592000 # 用户信息返回的类型 NESTED嵌套模式 {a: xx, b: { c : xx } },FLAT扁平化 {a: xx, b.c : xx } userProfileViewType: NESTED # oidc协议配置 配置参考:https://apereo.github.io/cas/5.3.x/installation/Configuration-Properties.html#openid-connect 配置类:org.apereo.cas.configuration.model.support.oidc.OidcProperties oidc: # 生成id token的claims项 claims: sub,name,preferred_username,family_name,given_name,middle_name,given_name,profile,picture,nickname,website,zoneinfo,locale,updated_at,birthdate,email,email_verified,phone_number,phone_number_verified,address # 动态注册运行模式 OPEN、PROTECTED dynamicClientRegistrationMode: OPEN # OIDC issuer issuer: ${cas.server.name}${server.context-path}/oidc # JWKS 文件应在缓存中保留多长时间 jwksCacheInMinutes: 60 # 用于处理认证令牌的签名/加密的JWKS文件资源的路径 jwksFile: /etc/cas/keystore.jwks # 支持的范围列表 scopes: openid,profile,email,address,phone,offline_access # ID token 偏移值 skew: 5 # 支持的主题类型 subjectTypes: public,pairwise # 默认从中文文档读 locale: defaultValue: zh_CN ac: # redis 配置参考 https://apereo.github.io/cas/5.3.x/installation/Configuration-Properties-Common.html#redis-configuration redis: database: 1 host: 192.168.1.1 password: *** port: 6380 timeout: 2000 useSsl: false usePool: true pool: fairness: false lifo: true max-active: 20 maxActive: 8 maxIdle: 8 minIdle: 0 maxWait: -1 numTestsPerEvictionRun: 0 softMinEvictableIdleTimeMillis: 0 minEvictableIdleTimeMillis: 0 testOnCreate: false testOnBorrow: false testOnReturn: false testWhileIdle: false captcha: img: expiration: 60 # 查询用户的数据来源,数据库:jdbc,LDAP:ldap querySource: jdbc phone: expiration: 300 # 手机号查询语句 sql: select * from gc_user where phone=? # 查询用户的数据来源 querySource: jdbc layout: # 登录页title title: 认证中心CloudAI contents: - 统一应用、用户、角色、菜单管理 - 支持JWT、CAS、OAuth2.0、OpenID、OIDC、SAML协议 - 基于Vue+ElementUI+SpringBoot技术栈开发 - 由技术中台PBU千行框架小组成员倾力打造 authn: # 用户中心要保持和这里一致 appKey: zREjZx9tT1eg5bPkSMsrqp03HLo9Mtad appSecret: 4ua4uQggI0g5DRIxc3oP5hDElUX8TcYW # 是否启用安全数字签名,开发时可以禁用 enabled: true
:::danger 大部分配置文件使用以上给定的值作为默认值即可,以下是部署时必须修改的配置项 :::
- cas.server.name:该项需修改为认证中心部署后的实际地址,根据实际情况进行修改,http://ip:port 格式
cas.authn.ldap:如果您需要接入到LDAP,则该配置项下的所有项需要按照您实际的ldap服务去配置一般不需要,如果需要使用ldap,请参照如下配置
cas: authn: ... # 省略其它内容,您需要配置以后内容到yml文件里,并修改ldap配置 # ldap认证 请参考 https://apereo.github.io/cas/5.3.x/installation/Configuration-Properties-Common.html#ldap-connection-settings ldap: - type: AUTHENTICATED # ldap的url ldapUrl: ldap://192.168.59.71:3890 # 是否使用ssl useSsl: false connectTimeout: 5000 # 操作的基础dn baseDn: dc=mylitboy,dc=com # 查询过滤条件 searchFilter: (|(uid={user})(mail={user})(mobile={user})) # 是否查询子级 subtreeSearch: true # 登录的域 bindDn: cn=admin,dc=mylitboy,dc=com # 登录密码 bindCredential: ldap123 # 属性主键值 principalAttributeId: uid # 是否允许多属性 allowMultiplePrincipalAttributeValues: true # 密码加密属性 passwordEncoder: type: NONE enhanceWithEntryResolver: true additionalAttributes: allowMissingPrincipalAttributeValue: true # 允许展示的属性列表 principalAttributeList: displayName,givenName,mail,sn,cn,commonName,department,title,description,telephoneNumber,physicalDeliveryOfficeName,memberOf,employeeNumber,mobile minPoolSize: 3 maxPoolSize: 50 validateOnCheckout: true validatePeriodically: true validatePeriod: 600 failFast: true idleTime: 5000 prunePeriod: 5000 blockWaitTime: 5000
cas.authn.jdbc:如果您需要使用到数据库来获取用户信息,则该配置项下的所有项需要按照您实际的数据库信息去配置, 和用户中心的数据库配置保持一致,基本上都需要
- ac.redis:必须修改的项,根据您使用的redis服务的信息填写
- ac.authn:必须修改的项,需要与用户中心的 uc.ac.authn 配置项保持一致,为了安全不要使用默认值,后果自负
:::warning
其他配置根据使用需求修改,配置说明参考注释
:::
messages_zh_CN.properties
中文汉化配置 ```propertiesWelcome Screen Messages
screen.welcome.welcome=欢迎来到中央认证系统。默认的认证处理器支持那些用户名等于密码的账号,开发者可以试试看。 screen.welcome.security=出于安全考虑,一旦您访问过那些需要您提供凭证信息的应用时,请操作完成之后登出并关闭浏览器。 screen.welcome.instructions=请输入您的用户名和密码. screen.welcome.label.netid=用户名: screen.welcome.label.netid.accesskey=n screen.welcome.label.password=密\u3000码: screen.welcome.label.password.accesskey=p screen.welcome.label.warn=转向其他站点前提示我。 screen.welcome.label.warn.accesskey=w screen.welcome.button.login=登录 screen.welcome.button.clear=重置
logo.title=转到Apereo网站首页 copyright=版权所有 © 2005–2012 Apereo, Inc. 保留全部权利。
Blocked Errors Page
screen.blocked.header=访问被拒绝 screen.blocked.message=输错密码次数太多,账号被锁定。
Confirmation Screen Messages
screen.confirmation.message=单击 这里 ,便能够访问到目标应用。
Generic Success Screen Messages
screen.success.header=登录成功 screen.success.success=您已经成功登录中央认证系统。 screen.success.security=出于安全考虑,一旦您访问过那些需要您提供凭证信息的应用时,请操作完成之后登出并关闭浏览器。
Logout Screen Messages
screen.logout.header=注销成功 screen.logout.success=您已经成功退出CAS系统,谢谢使用! screen.logout.security=出于安全考虑,请关闭您的浏览器。
screen.service.sso.error.header=在访问到到目标服务前,你必须经过重新认证的考验 screen.service.sso.error.message=你正试图访问要求重新认证的服务。请尝试进行再次认证。
username.required=必须录入用户名。 password.required=必须录入密码。
Authentication failure messages
authenticationFailure.AccountDisabledException=这个账户被禁用了。 authenticationFailure.AccountLockedException=这个账户被上锁了。 authenticationFailure.CredentialExpiredException=你的密码过期了。 authenticationFailure.InvalidLoginLocationException=你不能从这个工作站登录。 authenticationFailure.InvalidLoginTimeException=你的账户现在被禁止登录了。 authenticationFailure.AccountNotFoundException=用户名或密码错误。 authenticationFailure.FailedLoginException=用户名或密码错误。 authenticationFailure.UNKNOWN=认证信息无效。 authenticationFailure.CaptchaException=验证码错误。 authenticationFailure.AppAuthFailedException=用户无权访问应用。 authenticationFailure.MobileNullException=手机号或验证码为空。
INVALID_REQUEST_PROXY=必须同时提供’pgt’和’targetService’参数 INVALID_TICKET_SPEC=校验票根失败。您可能采用服务票根来校验代理票根,或没有将renew设为true。 INVALID_REQUEST=必须同时提供’service’和’ticket’参数 INVALID_TICKET=未能够识别出目标 ‘’{0}’’票根 INVALID_SERVICE=票根’’{0}’’不符合目标服务 INVALID_PROXY_CALLBACK=所提供的代理回调网址’’{0}’’不能提供认证。 UNAUTHORIZED_SERVICE_PROXY=所提供的服务’’{0}’’没有权限使用CAS代理的认证方式。
screen.service.error.header=未认证授权的服务 screen.service.error.message=不允许使用CAS来认证您访问的目标应用。 screen.service.empty.error.message=CAS的服务记录是空的,没有定义服务。 \ 希望通过CAS进行认证的应用程序必须在服务记录中明确定义。
Password policy
password.expiration.warning=你的密码会在{0}天内过期。请立刻修改你的密码。 password.expiration.loginsRemaining=在必须修改密码之前,你还剩{0}次登录。 screen.accountdisabled.heading=这个账户已经被禁用了。 screen.accountdisabled.message=请联系系统管理员来重新获得访问权限。 screen.accountlocked.heading=这个账户已经被锁住了。 screen.accountlocked.message=请联系系统管理员来重新获得访问权限。 screen.expiredpass.heading=你的密码已经过期了。 screen.expiredpass.message=请修改你的密码。 screen.mustchangepass.heading=你必须修改你的密码。 screen.mustchangepass.message=请修改你的密码。 screen.badhours.heading=现在你的账户被禁止登录了。 screen.badhours.message=请稍后再试。 screen.badworkstation.heading=你不能从这个工作站登录。 screen.badworkstation.message=请联系系统管理员来重新获得访问权限。
OAuth
screen.oauth.confirm.header=授权 screen.oauth.confirm.message=要授权”{0}”访问你全部个人信息吗? screen.oauth.confirm.allow=允许
Unavailable
screen.unavailable.heading=CAS无法使用 screen.unavailable.message=在试图完成你的请求时出错。请通知你的技术支持或重试。 ```