Reputation: 13
I have a problem with local development for our frontend developers in context of security.
Prerequisites:
In the schems below I drew an approximate situation of what is happening
What I am trying to do
The question is
How to set up local development for frontend developers allowing them to login via keycloak and api-gateway in test enviroment? Maybe there are proven schemes on how to do this?
I was trying to use local nginx using some redirect but have no results.
Upvotes: 0
Views: 854
Reputation: 12825
What I do in similar setup (development or not):
spring-cloud-gateway
with spring-boot-starter-oauth2-client
, oauth2Login
and TokenRelay=
filter. This a rather simple way to get an OAuth2 BFF storing tokens in session and translating between session authorization (between the front-end and the gateway) and Bearer token authorization (between the gateway and resource server(s))The authentication sequence (again, whatever the environment, not only in dev) is the following:
authorization_code
flow (one per authorization server if you have several)authorization_code
flowThis last step (step 6 in your drawing, which you seem to have difficulty with) is done with an authentication success handler configured with http.oauth2Login(oauth2 -> oauth2.authenticationSuccessHandler(new RedirectServerAuthenticationSuccessHandler("/ui")))
. You can put an absolute URI there (I always do and you will have to if you don't want to serve the UI through the gateway).
Note that you probably want to configure an AuthenticationFailureHandler
pointing to your React frontend too.
Upvotes: 0