我有一个用于使用 jwt 令牌的不同应用程序的通用登录页面,当我想调用此组件的其余 API 时,我必须将 jwt 放到标题中以获取 user_info。我有多个使用这个组件的应用程序,如果我可以为此目的使用一个通用的 Oauth2 服务器会更容易。
我开始使用 ory/hydra,但我真的不明白它是如何工作的。我下载了它并使用 hydra serve all 命令在 localhost 上运行,端口为 4444 和 4445(管理员)。之后在另一个命令行中运行以下行:
$ hydra clients create --skip-tls-verify --endpoint ' https://localhost:4445 ' --id client_id --secret secret -c ' https://localhost:8082/login/oauth2/code/ ' -一个“用户信息”
我可以使用的登录页面如下所示:' https://loginpage.../login.html?redirect_url= ' 在这种情况下,重定向 url 应该是什么?(我将有多个 Spring Boot 应用程序)
九头蛇.yml:
log:
level: info
format: json
serve:
public:
port: 4444
host: speacial-host
admin:
port: 4445
host: speacial-host
dsn: memory
webfinger:
jwks:
broadcast_keys:
- hydra.jwt.access-token # This key will be exposed when the OAuth2 Access Token strategy is set to JWT.
oidc_discovery:
- user_info
userinfo_url: http://restapi_url:8080/backend/api/user_info
urls:
self:
issuer: https://speacial-host:4444/
public: https://speacial-host:4444/
login: https://loginpage.../login.html?redirect_url=https://127.0.0.1:4444/oauth/callback
oauth2:
expose_internal_errors: true
profiling: cpu
我需要 oauth 服务器来处理 jwt 令牌。因此,当我必须调用 REST API 时,我想为此调用 oauth 服务器。
春季启动应用程序application.yml:
server:
port: 8082
servlet:
session:
cookie:
name: UISESSION
spring:
thymeleaf:
cache: false
security:
oauth2:
client:
registration:
custom-client:
client-id: client_id
client-secret: secret
client-name: Auth Server
scope: user_info
provider: custom-provider
redirect-uri: https://127.0.0.1:4444/oauth/callback
client-authentication-method: basic
authorization-grant-type: authorization_code
provider:
custom-provider:
token-uri: https://localhost:4444/oauth2/token
authorization-uri: https://localhost:4444/oauth2/auth
user-info-uri: https://localhost:4444/userinfo
user-name-attribute: name
有没有我错过的配置参数?