多个客户端ID春季安全配置 [英] Multiple client ids spring security config

查看:315
本文介绍了多个客户端ID春季安全配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已使用以下application.yml在iOS上成功实现了Google登录:

I have successfully implemented Google Sign-In on iOS with following application.yml:

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客户端添加配置.显然我不能这样做:

Now I need to add configuration for Android client. Obviously I cannot do this:

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

执行此操作的正确方法和最佳做法是什么?

What is the correct approach and best practice to do this?

推荐答案

我从该文件中找到了您要查找的语法

I found the syntax you are looking for from this file 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.: Check the link for better reference.

这篇关于多个客户端ID春季安全配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆