-
Notifications
You must be signed in to change notification settings - Fork 292
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
Enable service account token auth for public API #5254
Conversation
1e382db
to
29c3858
Compare
related_name="alert_receive_channels", | ||
blank=True, | ||
null=True, | ||
) |
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.
Added to keep track of integrations created via a service account token.
organization = Organization.objects.filter(grafana_url=grafana_url).first() | ||
if organization: | ||
return organization | ||
|
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.
We need a way to identify the Grafana URL to hit its API when validating a service account token (note Grafana URL is already a param in Terraform)
permissions = get_service_account_token_permissions(organization, token) | ||
if not permissions: | ||
try: | ||
user, auth_token = ServiceAccountToken.validate_token(organization, token) |
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.
Validation is moved to the ServiceAccountToken
model.
return super().get_queryset().select_related("service_account__organization") | ||
|
||
|
||
class ServiceAccountToken(BaseAuthToken): |
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.
The most relevant bits of this PR are here.
29c3858
to
35a13bc
Compare
35a13bc
to
b1aa482
Compare
5f6712b
to
1bb8e0d
Compare
1bb8e0d
to
cfc29f7
Compare
Related to https://github.com/grafana/oncall-private/issues/2826
Continuing work started in #5211, this adds support for Grafana service accounts tokens for API authentication (except alert group actions which will still require a user behind). Next steps would be updating the go client and the terraform provider to allow service account token auth for OnCall resources.
Following proposal 1.1 from doc.