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
adminand passwordPa55w0rd. -
Add a new realm named
spring-cloud-gateway-realm. -
Import
realm-export.json, withIf a resource exists: Skip. -
On the
spring-cloud-gateway-clientclient Credentials tab,Regenerate Secretand store value in gatewayapplication.yml. -
Add a new user with username
spring-cloud-gateway-user. -
Under credentials set user password to
passwordwithTemporary: OFF.
-
a realm named
spring-cloud-gateway-realm. -
a client named
spring-cloud-gateway-clientwith:-
Access Type: confidentialandCredentials 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.