-
-
Notifications
You must be signed in to change notification settings - Fork 98
Description
I followed the BFF tutorial, and while my architecture is somewhat similar, I'm having the issue that once the gateway (acting as a reverse proxy, oauth client) fetches the token from Keycloak via the session (I can see Spring calling userinfo with the token, so it's there), but doesn't forward it downstream to my resource server.
My frontend gets redirected to keycloak, the user logs in and is redirected back to the app, but due to no token being passed downstream, my BFF is getting an anonymous token. I've looked at the request going to the BFF and there's really no authorization header, or a token sent downstream.
I'm new to Spring/Java, so I'm probably missing something, please let me know. Below are my configs:
My gateway is running on http://localhost:8081, Keycloak on 8080 and resource server on 7001.
Gateway (BFF):
spring:
cloud:
security:
oauth2:
client:
registration:
keycloak:
provider: keycloak
client-id: backoffice-client
client-secret: 61FOqIXrbF4kDgf90QkgszIfnXxXotPL
authorization-grant-type: authorization_code
scope: openid, profile, email
provider:
keycloak:
issuer-uri: http://localhost:8080/realms/app_backoffice_dev
gateway:
default-filters:
- DedupeResponseHeader=Access-Control-Allow-Credentials Access-Control-Allow-Origin
globalcors:
corsConfigurations:
'[/**]':
allowedOrigins: "*"
allowedHeaders: "*"
allowedMethods:
- GET
- POST
- DELETE
- PUT
- OPTIONS
routes:
- id: perimeter_bff_bo
uri: http://localhost:7001
predicates:
- Path=/api/v1/backoffice/**
filters:
- TokenRelay=
- SaveSession
- StripPrefix=3
com:
c4-soft:
springaddons:
oidc:
ops:
- iss: http://localhost:8080/realms/app_backoffice_dev
authorities:
- path: $.realm_access.roles
aud:
client:
client-uri: http://localhost:8081
security-matchers:
- /api/**
- /login/**
- /oauth2/**
- /logout/**
permit-all:
- /api/**
- /login/**
- /oauth2/**
- /logout/connect/back-channel/app_backoffice_dev
csrf: cookie-accessible-from-js
oauth2-redirections:
rp-initiated-logout: ACCEPTED
back-channel-logout:
enabled: true
internal-logout-uri: http://localhost:8081/logout
resourceserver:
permit-all:
- /login-options
- /error
- /actuator/health
- /actuator/inforesource server:
com:
c4-soft:
springaddons:
oidc:
ops:
- iss: http://localhost:8080/realms/app_backoffice_dev
username-claim: $.preferred_username
authorities:
- path: $.realm_access.roles
aud:
resourceserver:
permit-all:
- /me
- /debug
- /actuator/health
- /actuator/info