├── README.md ├── .gitignore ├── jwt-resource-server ├── src │ └── main │ │ ├── resources │ │ └── application.yml │ │ └── java │ │ └── com │ │ └── cheng │ │ └── resource │ │ └── ResourceServerApplication.java └── pom.xml ├── auth-server ├── src │ └── main │ │ ├── resources │ │ ├── application.yml │ │ └── templates │ │ │ ├── index.html │ │ │ └── login.html │ │ └── java │ │ └── com │ │ └── cheng │ │ └── auth │ │ └── AuthServerApplication.java └── pom.xml ├── resource-server ├── src │ └── main │ │ ├── resources │ │ └── application.yml │ │ └── java │ │ └── com │ │ └── cheng │ │ └── resource │ │ └── ResourceServerApplication.java └── pom.xml ├── ui ├── src │ └── main │ │ ├── resources │ │ ├── application.yml │ │ └── templates │ │ │ └── index.html │ │ └── java │ │ └── com │ │ └── cheng │ │ └── ui │ │ └── UiApplication.java └── pom.xml ├── jwt-auth-server ├── src │ └── main │ │ ├── resources │ │ ├── templates │ │ │ ├── index.html │ │ │ └── login.html │ │ └── application.yml │ │ └── java │ │ └── com │ │ └── cheng │ │ └── auth │ │ └── AuthServerApplication.java └── pom.xml └── pom.xml /README.md: -------------------------------------------------------------------------------- 1 | # oauth2-sso 2 | 3 | 基于Spring Boot + Spring Security OAuth2 + JWT 搭建的单点登录示例 4 | 5 | 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | logs/ 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | -------------------------------------------------------------------------------- /jwt-resource-server/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | logging: 2 | file: logs/oath2-sso.log 3 | level: 4 | root: info 5 | 6 | server: 7 | port: 9992 8 | 9 | spring: 10 | jackson: 11 | date-format: com.fasterxml.jackson.databind.util.ISO8601DateFormat 12 | 13 | security: 14 | oauth2: 15 | resource: 16 | jwt: 17 | key-uri: ${auth-server:http://localhost:9991/uaa}/oauth/token_key 18 | -------------------------------------------------------------------------------- /auth-server/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | logging: 2 | file: logs/oath2-sso.log 3 | level: 4 | root: info 5 | org.springframework.security: DEBUG 6 | 7 | server: 8 | port: 9991 9 | context-path: /uaa 10 | 11 | security: 12 | user: 13 | password: password 14 | oauth2: 15 | client: 16 | client-id: demo 17 | client-secret: demo 18 | scope: read, write 19 | auto-approve-scopes: .* 20 | authorization: 21 | check-token-access: permitAll() -------------------------------------------------------------------------------- /resource-server/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | logging: 2 | file: logs/oath2-sso.log 3 | level: 4 | root: info 5 | 6 | server: 7 | port: 9992 8 | 9 | spring: 10 | jackson: 11 | date-format: com.fasterxml.jackson.databind.util.ISO8601DateFormat 12 | 13 | security: 14 | oauth2: 15 | resource: 16 | token-info-uri: ${auth-server:http://localhost:9991/uaa}/oauth/check_token 17 | jwt: 18 | key-uri: ${auth-server:http://localhost:9999/uaa}/oauth/token_key 19 | client: 20 | client-id: demo 21 | client-secret: demo -------------------------------------------------------------------------------- /ui/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | logging: 2 | file: logs/oath2-sso.log 3 | level: 4 | root: info 5 | org.springframework.security: DEBUG 6 | 7 | server: 8 | port: 9993 9 | 10 | spring: 11 | jackson: 12 | date-format: com.fasterxml.jackson.databind.util.ISO8601DateFormat 13 | 14 | auth-server: http://localhost:9991/uaa 15 | 16 | security: 17 | basic: 18 | enabled: false 19 | oauth2: 20 | client: 21 | client-id: demo 22 | client-secret: demo 23 | access-token-uri: ${auth-server}/oauth/token 24 | user-authorization-uri: ${auth-server}/oauth/authorize 25 | scope: read, write 26 | resource: 27 | token-info-uri: ${auth-server}/oauth/check_token 28 | jwt: 29 | key-uri: ${auth-server}/oauth/token_key 30 | -------------------------------------------------------------------------------- /auth-server/src/main/resources/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |Logged in as: demo
16 | 20 |16 | Login failed ... 17 |
18 | 19 |20 | Logout succeeded. 21 |
22 | 23 | 36 | 37 |16 | Login failed ... 17 |
18 | 19 |20 | Logout succeeded. 21 |
22 | 23 | 36 | 37 |