Skip to content
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 permissions to JWT #1119

Merged
merged 4 commits into from
Jan 4, 2024
Merged

Conversation

alesstimec
Copy link
Collaborator

Description

For certain method calls, we need to add additional permissions to the JWT: e.g. when adding a model, we need to add cloud permission stating that the user has permission to add-model on that cloud.

Engineering checklist

Check only items that apply

  • Documentation updated
  • Covered by unit tests
  • Covered by integration tests

Test instructions

Notes for code reviewers

Copy link
Contributor

@kian99 kian99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm with a suggestion on removing magic strings.

internal/jimm/applicationoffer.go Outdated Show resolved Hide resolved
internal/jimm/applicationoffer.go Outdated Show resolved Hide resolved
internal/jimm/model.go Outdated Show resolved Hide resolved
For certain method calls, we need to add additional permissions to the JWT:
e.g. when adding a model, we need to add cloud permission stating that the
user has permission to add-model on that cloud.
@alesstimec alesstimec force-pushed the add-permissions-to-jwt branch from 3b636f1 to 13f545c Compare January 3, 2024 09:49
Comment on lines +125 to +130
permissionMap = make(map[string]string, len(permissons))
for _, p := range permissons {
permissionMap[p.resource] = p.relation
}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is smart. I would have sent the map instead of the variadic args and would have ended up constructing the map everywhere and duplicating code. Your way is much smarter. I learned something new today

@alesstimec alesstimec merged commit 08356f8 into canonical:v3 Jan 4, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants