-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
feat(entitlement): add authorization feature #4223
Conversation
f1db598
to
0de745c
Compare
+1 |
1 similar comment
+1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @sokoide, thanks for the PR. While I can see this being helpful, I don't think we want to introduce any specific authorization into Loki itself. This allows us to keep the project simpler. I think it's more suitable to put an auth layer in front of Loki to enforce whichever policies make sense. This may not always be the case, but I don't feel comfortable adding this feature into the Loki source at this time. I'm especially sorry because of the effort you've put in here.
Hello @owen-d, thank you very much for your review and explanation. I understood adding an authorization logic in Loki is not preferred. We considered below to meet a security requirement (per logfile/label entitlement), but we couldn't overcome the following limitations and proposed the PR.
|
Would building your own proxy component in front of Loki work? Doing so would allow you to apply any auth schemes you wish before sending to Loki or after performing a query to determine access. |
Hi @owen-d, I was only thinking about existing reverse proxies such as Nginx. Thank you very much for your advice. We'll consider moving the logic into a custom proxy. |
What this PR does / why we need it:
It adds an authorization feature.
Loki now enabled native mTLS for both HTTP and gRPC with #4224 . However, the followings are still not supported.
This feature enables all of the functions.
To make the authorization logic flexible, Loki talks to an external entitlement server (entserver-sample available) over gRPC. The entitlement server is supposed to run on the same host as Loki which means the gRPC call is made from Loki to localhost:21001 (configurable). Later versions may support mTLS between Loki and the entitlement server.
Which issue(s) this PR fixes:
Fixes #4224
Special notes for your reviewer:
Configuration:
If loki.yaml doesn't have
authz_enabled
, it works the same as before.If it has
auth_enabled: true
(multi-tenancy), butauthz_enabled: false
, it works as the same as before which means multi-tenancy, but without authorization.If it has
auth_enabled: false
(single-tenancy), butauthz_enabled: true
, it checks authorization for read (query* API) or write (push API) forfake
organization with the other configs underentitlement
tag.If it has
auth_enabled: true
(multi-tenancy), butauthz_enabled: true
, authorization is checked for the org, user and action (read or write).How to test the authorization feature:
Run entserer-sample on the same host
./entserver-sample -logLevel DEBUG -configFile /path/to/entserver-sample.yml # please configure the yaml
Make push or query requests
Loki ingester (push) or querier (query) makes calls to the entserver and cached the result for
cache_retain_period
.The query detail is shown in stdout of
entserver-sample
with-logLevel DEBUG
.The
entserver-sample
is a sample server for users to implement their entitlement server based on their requirements.entclient-sample
makes a call to the entserver for testing purpose.Checklist