I am trying to integrate keycloak into my spring security layer. I have achieved that, the only issue I have yet to solve is the following:
When an endpoint is hit, that requires the user to be authenticated, the site redirects to my keycloak login page. After login, the user is redirected back to the page they initially requested. What I'm trying to achieve is: I do not want my users redirecting from my app to the keycloak login page, and back again, but better yet, to login through a form on my app and "proxy" those captured details to keycloak and get the login token back.
If anyone can shed light on the above, whether it be possible or not, and if so, some direction to the solution would be smashing.
pom.xml:
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-spring-boot-adapter</artifactId>
<version>2.4.0.Final</version>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-tomcat8-adapter</artifactId>
<version>2.4.0.Final</version>
</dependency>
application.properties:
keycloak.realm=MY_REALM
keycloak.realmKey=MY_REALM_KEY
keycloak.auth-server-url=MY_SERVER_URL
keycloak.resource=MY_RESOURCE
keycloak.ssl-required=external
keycloak.public-client=true
keycloak.use-resource-role-mappings=true
keycloak.securityConstraints[0].securityCollections[0].name=static-resources
keycloak.securityConstraints[0].securityCollections[0].patterns[0]=/css/*
keycloak.securityConstraints[0].securityCollections[0].patterns[1]=/fonts/*
keycloak.securityConstraints[0].securityCollections[0].patterns[2]=/js/*
keycloak.securityConstraints[1].securityCollections[0].name=application
keycloak.securityConstraints[1].securityCollections[0].authRoles[0]=MY_ROLE
keycloak.securityConstraints[1].securityCollections[0].patterns[0]=/api/*
What you are trying to achieve contradicts the generell purpose of keycloak to keep user information separated from the application itself. Therefore there is (as fas a I know) no default/clean way to achieve this.
Instead you could consider styling the login page to fit your applications visual appearance.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With