The Keycloak Auth Proxy makes it possible to protect web resources that have no build in authentication.
This Auth Proxy Service uses Keycloak Proxy a Java/Undertow solution designed for Keycloak but that should work with any other IMA that support OpenID/Connect.
- External traffic is directed to the auth proxy. The Auth proxy decides based on it configuration if the destination needs authentication.
- The Auth Proxy work together with the IAM (Keycloak) and redirects the user to the IAM so the user can login.
- After a successful login the proxy forwards the user to the protected content. According to proxy configuration setting the proxy checks if the user is allowed to access the path.
There are two very common use cases why one would use the Keycloak Auth Proxy together with an Identity & Access Management Service (IAM)
- Protect static websites from unauthorized access only allowing authenticated users to see the content.
This is useful in combination with static website generator or other generated documentation. - Outsource the authentication/authorization to Keycloak Auth Proxy and just relay on the header parameter with username and grants which are forwarded to the upstream application.
The proxy configuration settings can be set with environment variables or with the file proxy.json
mounted as a volume to /app/proxy.json
.
The intended use is that for every service that needed authentication there is an dedicated auth proxy. Auth proxy can be configured to behave differently but not given the configuration via environment variable.
Can be used if you want to auth one service.
See the file proxy.tmpl
Variables without default values are mandatory.
TARGET_URL
The URL to forward the traffic throughHTTP_PORT
(default80
) The port to bind the Auth Proxy tooBASE_PATH
(default/
)REALM
Adapter config realmREALM_PUBLIC_KEY
Realm public keyAUTH_SERVER_URL
The auth server URLRESOURCE
(defaultaccount
) The resource to request aka client idSECRET
Credential secretCONSTRAINT_PATH
(default/*
) You can define multiple path but they must be separated with a;
Despite the uniqueness of keycloak-auth-proxy there are other project that solve the similar problem differently.
- OpenID / Keycloak Proxy service This in Golang written proxy should work nicely with Keycloak and might be a value alternative to the current jvm proxy.
- OAuth2 Proxy
- Lua Resty OpenID/Connect This library is designed for Nginx/OpenResty.