【发布时间】:2021-12-09 03:53:24
【问题描述】:
我正在尝试通过 keycloak JWT 使用 Micronaut GraphQL。我能够使用基本身份验证,尝试转移到不记名令牌,但我错过了一些东西,因为我总是得到 401 Unauthorized,但我在日志中没有看到任何有用的错误消息,甚至将日志记录设置为 TRACE
使用 Micronaut 3.0.0。
我的 application.yml 看起来像这样:
micronaut:
application:
name: myapp
server:
cors:
enabled: true
port: 8080
security:
authentication: bearer
intercept-url-map:
- pattern: /graphiql
access:
- isAnonymous()
- pattern: /graphql
access:
- isAuthenticated()
endpoints:
login:
enabled: false
token:
jwt:
enabled: true
signatures:
jwks:
keycloak:
url: http://xx.xx.xx.xx:8090/auth/realms/myrealm/protocol/openid-connect/certs
oauth2.clients.keycloak:
grant-type: password
client-id: myapp-backend
client-secret: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
authorization:
url: http://xx.xx.xx.xx:8090/auth/realms/myrealm/protocol/openid-connect/auth
custom:
keycloak:
url: http://xx.xx.xx.xx:8090
graphql:
enabled: true
path: /graphql
graphiql:
enabled: true
path: /graphiql
这是我要测试的内容:
curl --location --request POST 'localhost:8080/graphql' \
--header 'Authorization: Bearer {exceptionally long jwt token}' \
--header 'Content-Type: application/json' \
--data-raw '{"query":"query test { scenarios { id } }","operationName":"test"}'
我不确定还有什么有用的。有什么想法吗?
【问题讨论】:
-
您的要求是什么样的?
-
添加了我的测试 curl 语句(删除了 jwt 令牌)
-
我对micronaut了解不多,但不应该有openid的配置吗?
标签: graphql jwt keycloak micronaut