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 example for user-defined roles based on Authzed's guide #141

Merged
merged 2 commits into from
Dec 6, 2024

Conversation

f-moya
Copy link
Contributor

@f-moya f-moya commented Dec 4, 2024

This PR adds an example to the client_spec.rb file, demonstrating how to use the Authzed Ruby client to write a relationship for user-defined roles, as described in the Authzed blog post on user-defined roles.

Background:
While following the guide, I encountered the following pseudocode:

# Grant the "issue_creator" capability to those who have been granted the "project_manager" role
authzed.write(resource="project:oursoftware", relation="issue_creator", subject="role:project_manager#member")

It wasn't immediately clear how to translate this into Ruby code using Authzed's Ruby gem, particularly with respect to constructing the request for creating the relationship.

As mentioned in the issue, this is technically documented on https://buf.build/authzed/api/docs/main:authzed.api.v1#authzed.api.v1.SubjectReference, but I believe an rspec example can help and it doesn't hurt.

Closes #142.

@f-moya f-moya requested a review from a team as a code owner December 4, 2024 20:29
Copy link

github-actions bot commented Dec 4, 2024

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@f-moya
Copy link
Contributor Author

f-moya commented Dec 4, 2024

I have read the CLA Document and I hereby sign the CLA

authzedbot added a commit to authzed/cla that referenced this pull request Dec 4, 2024
Copy link
Contributor

@tstirrat15 tstirrat15 left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for pushing this!

@tstirrat15 tstirrat15 merged commit 079bf4e into authzed:main Dec 6, 2024
4 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Dec 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add example for user-defined roles based on Authzed guide to client specs
2 participants