-
Notifications
You must be signed in to change notification settings - Fork 34
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 docs about creating custom permission #1454
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--- | ||
title: Using Permissions in Custom Plugins | ||
publishedDate: '2024-12-18T21:00:00.0Z' | ||
description: How to configure and manage permissions and policies for use in Custom Plugins in Roadie. | ||
--- | ||
|
||
## Introduction | ||
|
||
**This feature is currently in the process of being rolled out. If you want access, please contact our support or sales teams.** | ||
|
||
You can choose to make use of custom permissions in Roadie as part of a custom plugin. This tutorial assumes you have already created and published a [custom plugin](/docs/custom-plugins/overview/). | ||
|
||
In order to make use of a custom permission: | ||
|
||
1. Add `@backstage/plugin-permission-react` and `@backstage/plugin-permission-common` to the plugin's `package.json` file. | ||
|
||
2. Add the following code to a React component. | ||
|
||
```tsx | ||
import React from 'react'; | ||
... | ||
import { RequirePermission } from '@backstage/plugin-permission-react'; | ||
import { createPermission } from '@backstage/plugin-permission-common'; | ||
|
||
const permission = createPermission({ | ||
name: 'see-content', | ||
attributes: { | ||
action: "read" | ||
} | ||
}); | ||
|
||
export const ExampleComponent = () => ( | ||
... | ||
<RequirePermission permission={permission} errorPage={( | ||
<Typography variant="body1"> | ||
Not allowed to see-content. | ||
</Typography> | ||
)}> | ||
<Typography variant="body1"> | ||
Allowed to see content | ||
</Typography> | ||
</RequirePermission> | ||
... | ||
); | ||
``` | ||
|
||
3. In the Roadie UI, click Administration > Settings > User Management > Policies and "Add Policy". Give the policy a name and description and set the permission to "see-content" as defined by the name in the code above and save. | ||
|
||
![Create policy](create-policy.png) | ||
|
||
|
||
4. Assign the Policy to a role. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I would recommend we make this more prominent. Thoughts on using an alert div?
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.
@punkle ☝️
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.
This is already a pattern I am copying from another page.. Id suggest if we are improving this we should make the change across the other pages as part of another commit.
Its a good suggestion though.
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.
It is something I'm trying to move towards as we write new documentation. I have used it in multiple pages already, an example would be on step 18 of the Track Fragments recipe. If you prefer, we can do a bulk update, but I've been doing greenfield page as I create them.
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.
Brilliant. Im all on for it. Let me know if i can help.