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 docs about creating custom permission #1454

Merged
merged 2 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 52 additions & 0 deletions content/docs/details/custom-plugins/index.md
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.**
Copy link
Contributor

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?

<div role="alert">
  <div class="docs-cta__tip_title">Coming Soon</div>
  <div  class="docs-cta__tip_message">
    <p>This feature is currently in the process of being rolled out. If you want access, please contact our support or sales teams.</p>
  </div>
</div>

Copy link
Contributor

Choose a reason for hiding this comment

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

@punkle ☝️

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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.


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.
3 changes: 2 additions & 1 deletion content/docs/docs-nav.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,11 @@ nav:
- Accessing public resources: '/docs/details/backend-reading-allow-list/'
- Allowlisting Roadie traffic: '/docs/details/allowlisting-roadie-traffic/'
- How Roadie connects: '/docs/details/how-roadie-connects/'
- Permissions:
- Permissions:
- Introduction: '/docs/details/permissions/'
- Roles: '/docs/details/managing-roles/'
- Policies: '/docs/details/managing-policies/'
- Custom Plugins: '/docs/details/custom-plugins/'
- Proxy Creation: '/docs/details/create-proxy/'
- Setting secrets: '/docs/details/setting-secrets/'
- TechDocs:
Expand Down
Loading