我能夠通過以下兩個示例應用程序,以下實現與多個基於REST資源社會登錄的步驟是:
(1)結帳https://github.com/spring-guides/tut-spring-security-and-angular-js/tree/master/oauth2
(2)刪除「authserver」文件夾(我們將使用來自另一個項目auth服務器)
(3)從結賬社會演示auth服務器:https://github.com/spring-guides/tut-spring-boot-oauth2/tree/master/auth-server
(4) 「UI」 項目的開放application.yml,並做如下改變:
server.port: 9001
server.context-path: /zuul
debug: true
spring:
aop:
proxy-target-class: true
security:
oauth2:
client:
client-id: acme
client-secret: acmesecret
access-token-uri: http://localhost:8080/oauth/token
user-authorization-uri: http://localhost:8080/oauth/authorize
grant-type: implicit
resource:
user-info-uri: http://localhost:8080/me
zuul:
routes:
resource:
path: /resource/**
url: http://localhost:9000/resource
user:
path: /user/**
url: http://localhost:8080/me
logging:
level:
org.springframework.security: DEBUG
(5)auth服務器的開放application.yml並添加谷歌屬性:
google:
client:
clientId: <your client id>
clientSecret: <your client secret>
accessTokenUri: https://accounts.google.com/o/oauth2/token
scope: profile,email
userAuthorizationUri: https://accounts.google.com/o/oauth2/auth
clientAuthenticationScheme: form
redirect-uri: http://localhost:8080
resource:
userInfoUri: https://www.googleapis.com/plus/v1/people/me
(6)auth服務器的開放SocialApplication.java: 添加谷歌相關豆和過濾器(類似於facebook和github)。
(7)重命名application.properties到application.yml 「資源」 項目 以下是陽明的內容:
server:
port: 9000
context-path: /resource
security:
oauth2:
resource:
user-info-uri: http://localhost:8080/me
logging:
level:
org.springframework.security: DEBUG
org.springframework.web: DEBUG
(8)現在運行auth服務器,資源和用戶界面項目和點擊端口9001和context/zuul。
但我的UI項目是在Angular 2中,它沒有Spring代碼。所以我無法更改UI項目中的application.properties –
在上述步驟中,UI項目意味着Zuul項目。你可以讓你的UI項目與Spring Boot Jar分開。 –
我是Zuul新手,可以在GitHub中看到您的代碼嗎? @Hitesh shekhada –