Forum Discussion
Keycloak as idp for APM
Hello, just wanted to know if someone finally manage to make this work with F5 APM and keycloak openid (or any custom on premise oAuth2 or openid provider) and authorisation code flow, custom request requests...
I try to do the same for OpenID auth behind an API with v15.1 and AWAF but without success...
- JorenCFeb 26, 2020Nimbostratus
We do have it running here. But haven't found the time to do full a write-up on the basic setup via APM.. :(
Any specific questions you have regarding the APM integration?
- avengingFeb 26, 2020Nimbostratus
OK I tried to use the f5 as a resource server to validate JWT token.
Did you manage to do it using the oauth provider configuration with OpenID Connect discovery like https://keycloakhost:keycloakport/auth/realms/master/.well-known/openid-configuration ?
Because for me, the discovery works but if I use the auto-JWT part, on save, f5 tell me about an issue of certificate (the CA bunble provided in config is the one of the certificate for the OpenId discovery link, may be not the same use by master realm to sign token or authorisation code). So I created the JWKS part manualy.
A request to the f5 APM VIP well redirect to the keycloack for AUTH but once authenticated the F5 tell that it cannot validate the token or auth code provided by the keycloak.
As the password grant type has been deprecated, did you manage to make it work using the authorisation code flow?
Also, wonder if for the step scope validation, you use the f5 type or have created some specific for keycloak?.
Yes, if someone have time to do a detailed write up on dev central on how to configure APM with OpenID as Client and/or Ressource server for using with keycloak or any on premise custom Provider, I think this will help a lot of people.
Thanks.
- JorenCFeb 26, 2020Nimbostratus
yes we are indeed using the OIDC discovery.
If I'm not mistaking the CA bundle used here is just needed to connect to the keycloak endpoint. So like you said, it has nothing to do with the signing cert for tokens.
In our case, we have our keycloak running behind a virtual server on F5 with a public signed digicert certificate. So for the autodiscovery CA bundle I've imported the digicert bundle so F5 can validate this.
Regarding the flows, we had the password flow working more or less out of the box. The codeflow did have an issue. We kept receiving a 401 on the userinfo requests. Is this what you see? The keycloak logs will mention something like invalid_credentials.
In our case: After some tracing and the help of F5 support (big thanks to @Stanislaw Tsiarnouski) we noticed the issue is that keycloak adds the portnumber to the host header when calling introspect / userinfo. But the issuer in the token does not contain this portnumber.. This makes keycloak fail the check. (I still have a case open at RedHat for this but no solution on their part yet..)
So what I did to work around the issue is to remove the portnumber from the Host header if specific requests are passed to the VS of our server.
As a quick and dirty example:
if {[HTTP::method] eq "POST" && [HTTP::host] eq "keycloak.company.com:443"}{ HTTP::header replace Host "keycloak.company.com" }
This then works for both the code flow and password flow.
Do note: All requests have been custom made for keycloak (Access > Federation : OAuth Client / Resource Server : Request). Based on the info from their doc and curl-command used to obtain tokens etc. I found this the least well documented part of the entire setup actually.. 😥
HTH
Joren
- avengingFeb 26, 2020Nimbostratus
ok Thanks JorenC.
No I'm not able to go to scope validation part for the moment, I was just asking if we need to make custom request or if using the preconfigured F5 type was working.
I'm only at the token auth code validation internally on the F5 using JWKS or externally but I'm not able to made this works. I will post the details next week as I have no access to the F5 until monday.
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com