多个客户端ID弹出安全配置

时间:2016-09-05 14:16:26

标签: spring spring-security spring-boot google-signin google-oauth2

我已成功在iOS上使用以下application.yml:

实施Google登录
security:
  oauth2:
    resource:
      user-info-uri: https://www.googleapis.com/plus/v1/people/me
      prefer-token-info: true
    client:
      client-id: xxxxx.apps.googleusercontent.com
      access-token-uri: https://www.googleapis.com/oauth2/v3/tokeninfo
      client-authentication-scheme: form
      scope: email,profile

现在我需要为Android客户端添加配置。显然我不能这样做:

security:
  oauth2:
    resource:
      user-info-uri: https://www.googleapis.com/plus/v1/people/me
      prefer-token-info: true
    client:
      client-id: xxxxx.apps.googleusercontent.com
      access-token-uri: https://www.googleapis.com/oauth2/v3/tokeninfo
      client-authentication-scheme: form
      scope: email,profile
    client:
      client-id: xxxxx.apps.googleusercontent.com
      access-token-uri: https://www.googleapis.com/oauth2/v3/tokeninfo
      client-authentication-scheme: form
      scope: email,profile

这样做的正确方法和最佳做法是什么?

1 个答案:

答案 0 :(得分:1)

我从此文件Will Tran Github project application.yml

中找到了您要查找的语法

看起来像这样,

# OAuth2 Details
security.oauth2:
    client:
        client-id: client001
        client-secret: pwd001
        authorized-grant-types: password,authorization_code,refresh_token
        scope: read,write

---

security.oauth2:
    client:    
        client-id: client002
        client-secret: pwd002
        authorized-grant-types: client_credentials
        scope: TRUSTED

---

# /\ Dont forget this one

Ps。:检查链接以便更好地参考。