We use keycloak as our OpenID Connect provider. To set it up:
-
Start Keycloak through
docker-compose up
. -
Open http://localhost:8090 and login with username
admin
and passwordPa55w0rd
. -
Add a new realm named
spring-cloud-gateway-realm
. -
Import
realm-export.json
, withIf a resource exists: Skip
. -
On the
spring-cloud-gateway-client
client Credentials tab,Regenerate Secret
and store value in gatewayapplication.yml
. -
Add a new user with username
spring-cloud-gateway-user
. -
Under credentials set user password to
password
withTemporary: OFF
.
-
a realm named
spring-cloud-gateway-realm
. -
a client named
spring-cloud-gateway-client
with:-
Access Type: confidential
andCredentials Secret:f37a4996-47f4-4c4c-aedc-c4dcde42b314
-
Valid Redirect URIs: http://localhost:8080/*
-
Access Token Lifespan: 20 minutes
-
-
a user named
spring-cloud-gateway-user
.
The gateway will authenticate with the client credentials to the realm. When redirected by the gateway you can login with the user credentials.