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 APIs and values #133

Merged
merged 2 commits into from
Oct 26, 2023
Merged

Conversation

njooma
Copy link
Member

@njooma njooma commented Oct 18, 2023

We need permissions in the SDK for proactive checks around auth

@njooma njooma requested a review from a team as a code owner October 18, 2023 01:12
Copy link

@maximpertsov maximpertsov left a comment

Choose a reason for hiding this comment

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

have a question about the check api

Comment on lines +93 to +95
final request = ListAuthorizationsRequest()
..organizationId = organizationId
..resourceIds.addAll(resourceIds);

Choose a reason for hiding this comment

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

.. is neat a language feature

Copy link
Member Author

Choose a reason for hiding this comment

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

Ya SUPER useful in not having to create temporary objects for assignment

Comment on lines +107 to +109
return response.authorizedPermissions.first.permissions
.map((e) => Permission.values.firstWhere((element) => element.value == e))
.toList();

Choose a reason for hiding this comment

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

[q] (mainly because I'm unfamiliar with the shape of the API response) - why are we only considering the first authorized permission in the response? (response.authorizedPermissions.first)

Copy link
Member Author

Choose a reason for hiding this comment

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

This is a great question! It's because the API actually takes in an array of of permissions to check, and then returns an array of validated permissions.

This method only allows for a single permission check, so we will only get (at most) a single permission response back

@njooma njooma requested a review from clintpurser October 18, 2023 16:16
Copy link
Member

@clintpurser clintpurser left a comment

Choose a reason for hiding this comment

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

LGTM

@njooma njooma merged commit 81a80f8 into viamrobotics:main Oct 26, 2023
@njooma njooma deleted the permissions branch October 26, 2023 18:17
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.

3 participants