-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add authentication to metrics endpoint #39
Comments
@jkroepke having a way to restrict access to the metrics endpoint sounds reasonable. Usually this endpoint is scraped by Prometheus which won't have a valid keycloak session. Wondering what's the best way here, i'll try to give it some thought. |
Some inspiration from here https://github.com/AndreyVMarkelov/jira-prometheus-exporter/ This exporter generates a static key. If you want to scrape the endpoint you must attach the key as get parameter. Otherwise you get an unauthorized messages. 2 possible ways to store the static key inside keycloak.
|
I am interested in this. Having those keycloak metrics open to everyone does not seem like good idea. @jkroepke did you managed to configure it? Thanks |
As a workaround and since I have an HAproxy in front of my Keycloak servers, I added a
This config seems to do the trick. |
One way to restrict metrics endpoint is mentioned under Keycloak admin docs https://www.keycloak.org/docs/11.0/server_admin/#admin-endpoints-and-console where you replace |
I've fixed this problem with an nginx location rule and basic auth (ofcourse servering on https)
Prometheus itself supports base64 authentication. |
I still would like to see an in-tree solution without the need to configure an reverse proxy. |
Here is my NGINX Ingress Config to block requests to
|
The location should probably be |
I think it is really important to restrict this endpoint from regular users as well. Seems like the best and easiest way is configuring it in the keycloak configuration. As @giner mentioned:
Maybe just add the jboss cli command in the documentation, at least for now. There is also a way to implement everything as and "admin rest api" but it requires some work, so I'm not sure if this is the approach you want to go with. |
It seems that with KeyCloak 17 there is no way to rextrict endpoints anymore within the server configuration (keycloak/keycloak#12394) Maybe just add an option for some basic authentication. This way not the whole internet will be able to sniff out the metrics |
Description
Add authentication to the metrics endpoint. It should be only accessible with an specific user role oder admin account.
Expected Behavior
http://127.0.0.1:8080/auth/realms/master/metrics should be return 503 unless a valid session with specific role logged in.
Actual Behavior
http://127.0.0.1:8080/auth/realms/master/metrics is would accessible.
The text was updated successfully, but these errors were encountered: