Giter Club home page Giter Club logo

backstage-opa-plugins's Introduction

Welcome to the OPA Plugins Repository for Backstage!

This repository contains a collection of plugins for Backstage that integrate with Open Policy Agent.

Blogs!

Talks!

Plugins

  • backstage-opa-backend - A Backend Plugin that the backstage-opa-entity-checker consumes to evaluate policies.
  • plugin-permission-backend-module-opa-wrapper - An isolated OPA Client and a Policy Evaluator that integrates with the Backstage permissions framework and uses OPA to evaluate policies, making it possible to use OPA for permissions (like RBAC).
  • backstage-opa-entity-checker - A frontend plugin that provides a component card that displays if an entity has the expected entity metadata according to an opa policy.
  • backstage-opa-policies - A frontend component designed to be added to entity pages to fetch and display the OPA policy that entity uses based on a URL provided in an annotation in the catalog-info.yaml file.

Policies

  • backstage-opa-policies - A collection of policies that can be used with the plugins in this repository. (WIP)

Additional Documentation

Each Plugin has its own documentation in the Plugins Folder, I am however, slowly moving things to Github pages. Feel free to help out!

Local Development

Step by step guide to developing locally:

  1. Clone this repository
  2. Create an app-config.local.yaml file in the root of the repository copying the contents from app-config.yaml
  3. Create a PAT (Personal Access Token) for your GitHub account with these scopes: read:org, read:user, user:email. This token should be placed under integrations.github.token in the app-config.local.yaml file.
  4. Run yarn install --immutable in the root of the repository
  5. Use docker-compose up -d to start the OPA server and postgres database (this will also load the two policies in the example-opa-policies folder automatically)
  6. Update the OPA rbac policy in here rbac_policy.rego, or use your own! If you want to use the default policy, you'll have to update is_admin if "group:twocodersbrewing/maintainers" in claims to what ever your user entity claims are.
  7. Run yarn dev or yarn debug in the root of the repository to start the Backstage app (use debug if you want to see what is happening in the OPA plugin)

Contributing

Contributions are welcome! However, still figuring out the best approach as this does require user and group entities to be in the system.

Please open an issue or a pull request. You can also contact me on mastodon at @parcifal.

Please remember to sign your commits with git commit -s so that your commits are signed!

backstage-opa-plugins's People

Contributors

coldblade2000 avatar dependabot[bot] avatar github-actions[bot] avatar parsifal-m avatar stefank13 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

backstage-opa-plugins's Issues

Update Readme

I'd like to update the README.md in the root of the repository to explain a bit what this repo is about.

[BUG] Update the main README

Describe the bug
Main README needs some updates post using a docker compose file and entrypoints

To Reproduce
N/A

Expected behavior
Clearer instructions in the main readme.

Screenshots
N/A

Additional context
The readme in the actual wrapper plugin is fine, but the main readme needs updating.

[FEAT] Improve Documentation on OPA Backend and OPA Permissions Wrapper

Is your feature request related to a problem? Please describe.
The README's for each plugin need updating:

  • Using legacy backend
  • Using new backend
  • Installation instructions fully correct?

Describe the solution you'd like
A clear and concise description of what is required when installing the plugins on any backend system.

Describe alternatives you've considered
None

Additional context
The docs are not bad, they just need updating and refining a bit.

Update OPA config to be more dynamic

After speaking with Anders about integrating OPA with Backstage, a possible improvement would be to make the package name more dynamic.

I also had an idea while traveling that we could make the config accept an array of "configs" something like:

opa-client:
  opa:
    baseUrl: 'http://localhost:8181/v1/data/opa/main'
    policies:
      plugin: entity-checker
        package: 'entitymeta'
      plugin: catalog-entity
        package: 'catalog_policy'
      plugin: some-other-plugin
        package: 'some-other-package'

We could then do something here

Which would make it more dynamic ๐Ÿค” ๐Ÿ’ญ

Another option is to look at making a main package and then extending it as advised here

More example policies

Would be nice to have some more example policies that people can get some inspiration from.

Or I wonder if we could even template some.

[FEAT] Update the Architecture Documents as this has changed.

Is your feature request related to a problem? Please describe.
The Architecture Documents need sprucing up a bit as they are slightly out of date.

Describe the solution you'd like
What it looks like on OLD Backend and NEW Backend.

Describe alternatives you've considered
None

Additional context
Just needs updating.

[FEAT] Make logger less chatty on info level

For any given action I seem to get all of this printed at info level:

[1] 2024-02-08T12:23:19.326Z permission info Sending request to OPA: http://localhost:8181/v1/data/policy type=plugin
[1] 2024-02-08T12:23:19.326Z permission info Sending input to OPA: {"permission":{"name":"catalog.entity.refresh"},"identity":{"user":"user:default/anderseknert","claims":["user:default/anderseknert","group:default/feedback-maintainers","group:default/kube-mgmt-chart-maintainers","group:default/opa-maintainers","group:default/setup-opa-maintainers"]}} type=plugin
[1] 2024-02-08T12:23:19.328Z permission info Permission request sent to OPA with input: {"permission":{"name":"catalog.entity.refresh"},"identity":{"user":"user:default/anderseknert","claims":["user:default/anderseknert","group:default/feedback-maintainers","group:default/kube-mgmt-chart-maintainers","group:default/opa-maintainers","group:default/setup-opa-maintainers"]}} type=plugin

This is quite chatty and logging the input at info level also reveals quite a lot in terms of potentially sensitive information. I'd suggest changing the log level of these events to debug. OPA has decision logging anyway so if I want to see which decisions were made I'd turn to those instead, and have the backstage plugin log only errors, at least at info level.

OPA wrapper module with RBAC plugin

Quick Question/Feedback

Question or Feedback:
Hello. Just want to clarify. I am using RBAC plugin made by janus-idp. When I try to add OPA wrapper, Backstage fails. I want to use OPA wrapper to be able to create additional policies/permissions which I want to use with RBAC. Is it expected that app fails? In your docs, it is stated: "This plugin also requires and assumes that you have at least setup the permission framework (without any policies)".

Plugin Name:
@parsifal-m/plugin-permission-backend-module-opa-wrapper
@janus-idp/backstage-plugin-rbac-backend

Additional Details:
janus-idp RBAC plugin docs: https://github.com/janus-idp/backstage-plugins/blob/main/plugins/rbac-backend/README.md

image

Make a Front-end for OPA

Maybe not specifically related to this repo but I want to write down we should have a frontend for the OPA plugin.

[FEAT] Look into using CHANGESETS for releases

Is your feature request related to a problem? Please describe.
Its quite hard for me now to manage the releases of each package in this monorepo, I've had a look at https://github.com/changesets/changesets and it seems to be the go-to for monorepos.

Describe the solution you'd like
Preferably https://github.com/changesets/changesets but open to other ideas.

Describe alternatives you've considered
None currently, most roads point to https://github.com/changesets/changesets

Additional context
N/A

Front-end for the OPA plugin

It would be nice to have a front-end component for the OPA plugin, it could start off as something simple to just view the current policies on the OPA server.

Then we can modify it later on to also maybe be able to send new policies/update policies.

[FEAT] Better Error Logging

Is your feature request related to a problem? Please describe.
I'm still not too happy with how the error logging works, I would like some more clear precise error logs for when something goes wrong.

Describe the solution you'd like
Better logging, especially in the OPA Backend and Permissions Wrapper

Describe alternatives you've considered
None

Additional context
One thing especially annoying is that if we specify a policy/package but its not present on the OPA server it will just return a JSON error, I'd like this to be changed to advise in some form that the specified package does not exist for example.

[FEAT] Investigate alternative authorization model

While the policy model provided by the Backstage permissions framework works great, it would also be interesting to explore models where OPA has more say in the decisions being made. More specifically, I'd like to see an implementation where OPA doesn't merely pass conditional queries back to the plugins, but overrides the decision-making entirely, and side-steps the plugin's ownership of permissions in favor of the decoupled, externalized model that's more commonly seen in OPA integrations. Both approaches have their pros and cons, of course, and we'll want to document how these differ as part of this.

We got some helpful suggestions on how to accomplish this in the Backstage Discord (thanks @vinzscam!), like overriding the PermissionEvaluator interface with our own client implementation, so let's start there.

[FEAT] Add Guide on how to use HTTP Builtin from OPA

Is your feature request related to a problem? Please describe.
No

Describe the solution you'd like
Some documentation and examples on how to use http builtin to for example fetch a users entity information in order to make more detailed rules.

Describe alternatives you've considered
N/A

Additional context
Imagine you want to build a rule based on an annotation that a user entity entity has, currently the permissions framework does not send the full user data, only the users name and claims.

Using the HTTP builtin, we can make a get request to the backstage catalog and fetch the users entity information like the metadata including annotations etc... which will be really useful for some rules.

[FEAT] Migrate Backend Plugins To New Backend System

Is your feature request related to a problem? Please describe.
Not frustrating, but we should look at moving to the new Backend system for Backend plugins in Backstage.

Describe the solution you'd like
Something like this -> https://backstage.io/docs/plugins/new-backend-system/

Describe alternatives you've considered
We can leave it for now, and worry about this later.

Additional context
Have to make sure it works for both legacy and new backend system (this includes the permissions framework from backstage itself as well) but this should not be too much of an issue.

[FEAT] Add Architecture Diagrams To Explain How It Works.

Is your feature request related to a problem? Please describe.
I always forget how this thing works, especially if I take some time off. Would be nice to have some pictures for reference.

Describe the solution you'd like
Something in MermaidJS or Draw.io to better understand how things work.

Describe alternatives you've considered
Add more text to the readme, but I think pictures make it easier to digest.

Additional context
N/A

Documentation is wrong for OPA Plugin

This part of the docs is no longer correct:

opa-client:
  opa:
    baseUrl: http://your-opa-server-url
    policies:
      catalog:
        package: your-catalog-package

It should actually be:

opa-client:
  opa:
    baseUrl: 'http://localhost:8181'
    policies:
      entityChecker: --> Entity checker plugin
        package: 'entitymeta'
      catalogPermission: --> Permission wrapper plugin
        package: 'catalog_policy'

Needs updating here: https://github.com/Parsifal-M/brewed-backstage/blob/main/plugins/opa-backend/README.md and could also be updated here: https://github.com/Parsifal-M/brewed-backstage/blob/main/plugins/opa-permissions-wrapper/README.md

Or atleast the back-end plugin should be the source of truth for it and we can just reference to that file in the wrapper plugin.

[FEAT] A Front-end for the OPA plugins

Is your feature request related to a problem? Please describe.
Would be nice to have a front-end for the OPA plugins, especially the Permissions Wrapper, this way you could post new policies to the OPA API.

Describe the solution you'd like
A front-end plugin that users can use to upload policies to OPA which would be running alongside Backstage

Describe alternatives you've considered
There are alternative ways to upload policies to OPA via bundles or other community ways, so this would be nice to have.

Additional context
I'm not sure how much auditing we want to look at enabling here, if a policy is modified you probably want to know by whom and when.

Fix Readme for Permission Wrapper

This is wrong:

import { createRouter } from '@backstage/plugin-permission-backend';
import { Router } from 'express-serve-static-core';
import { PluginEnvironment } from '../types';
import {
  OpaClient,
  PermissionsHandler,
} from '../../../../plugins/opa-permissions-wrapper/src';

Should be this:

import { createRouter } from '@backstage/plugin-permission-backend';
import { Router } from 'express-serve-static-core';
import { PluginEnvironment } from '../types';
import { OpaClient, PermissionsHandler } from '@parsifal-m/opa-permissions-wrapper'

Needs updating in the documentation for the back-end plugin here: https://github.com/Parsifal-M/brewed-backstage/blob/main/plugins/opa-permissions-wrapper/README.md

[FEAT] Use the Notifications System in Backstage to notify when there is an issue with OPA

Is your feature request related to a problem? Please describe.
Something that came to mind when looking into #218 is that if you fall back to say a deny/allow/fail you probably want to be notified that there could be an issue with OPA.

You could set a config value under here once we add policyFallback we could add another value maybe notifyGroup or/and notifyUser and have them receive notifications that there is an issue.

Describe the solution you'd like
Using the notifications framework and based on advice by @drodil we could do something like:

  1. You can do it pretty easily to OPA plugin directly, you just need probably a config value that contains notification receivers in case of error and add notificationService as optional dependency to the plugin. For this you also probably need a scheduled task to check the status periodically.

  2. If it makes sense to use the existing devtools plugin, that would require first a scheduled task to check for the endpoints (+ i would add support for caching as it's possible to generate quite a lot of requests to external systems with this) and secondly support for notifications

Describe alternatives you've considered
I think we can always go for Option 1 initially then also look at adding option 2 later on if we can.

Additional context
N/A

[FEAT] List all catalog conditional rules

Is your feature request related to a problem? Please describe.

It would be great to list the available conditional rules from the catalog plugin from the Backstage repository.

Describe the solution you'd like

We can add them to a readme somewhere close to policies to help people make policies using the rules.

Describe alternatives you've considered

We just don't do it, but that wouldn't be very nice now would it? ๐Ÿ˜

Additional context

I don't think there is any specific docs on the available rules, we'll have to go diving into the code ๐Ÿคฟ

[FEAT] Add more complex rule examples to the docs

Is your feature request related to a problem? Please describe.
Kind of related to #205 need to add some more complex examples to help people use this easier.

Describe the solution you'd like
Would be nice (in the end) to have a github pages type thing with some good docs and examples, but just having a nice README maybe split up with rules for CATALOG, SCAFFOLDER.. etc.. would also be fine.

Describe alternatives you've considered
N/A

Additional context
Should also add references for regal as it really helps with policy writing and can really help people new to Rego and OPA to accelerate the adoption

[FEAT] Add the rest of the Docs to the Docsify /docs folder

Is your feature request related to a problem? Please describe.
The rest of the docs for the other plugins need to be added to the /docs folder as well.

Describe the solution you'd like
Nice docs site with github pages.

Describe alternatives you've considered
N/A

Additional context
README are fine, but docsify makes it a bit more presentable.

[FEAT] Get The Opa Wrapper To Directly Integrate With OPA Instead Of Using The OPA Backend Plugin

Is your feature request related to a problem? Please describe.
Remove dependency on OPA Backend for the OPA Permission Wrapper.

Describe the solution you'd like
Its not strictly nesecessary for the OPA Permission Wrapper to use the OPA Backend, we could make the wrapper talk directly to OPA instead.

Describe alternatives you've considered
We continue to use the OPA Backend, requiring two plugins in order for it to work.

Additional context
N/A

[FEAT] Add some fallback functionality in the case of a failed connection to OPA

Is your feature request related to a problem? Please describe.
The issue is backstage will become crippled should the OPA server not be running, or is otherwise inaccessible. This is acceptable in some contexts, but it can be a critical problem in certain environments. In particular, it is a crucial issue blocking initial adoption of OPA in my organization, as concerns are raised about "what happens if OPA is down?".

Describe the solution you'd like
Some fallback or failsafe functionality. A simple option is a wildcard ALLOW policy in case OPA is inaccessible. Another option is falling back to a secondary permission policy implemented in Typescript. Ideally, this would be a configuration option to avoid causing undesired effects on existing projects that already implement the OPA Wrapper.

Describe alternatives you've considered
I've looked over through the code of he plugins, and plenty of Backstage documentation. There is no documented pathway to solve this without forking this plugin, as the Backstage-OPA plugins are exclusive with other permissions plugins (or an order of priority can't be established)

Additional context
I've been authorized to work on this issue by my company, and I'll try to have something to show by Saturday. I reached out to Parsifal-M on Mastodon and he said this would be an interesting feature to add. My implementation would seek to be of minimal impact to existing projects, and hopefully show an example of fallback policies.

Update Readme

Update the readme, or add a section/another readme for spinning up this backstage instance.

Can help people trying to contribute to certain plugins as not all of them can be spun up in isolation.

[FEAT] OPA Entity Checker update to support `entrypoints`

Is your feature request related to a problem? Please describe.
The OPA Entity Checker plugin needs to be updated to also support the entrypoints (like the OPA permission wrapper)

Describe the solution you'd like
Same as the OPA wrapper, so we can use entrypoints instead of evaluating the whole policy

Describe alternatives you've considered
N/A

Additional context
N/A

[FEAT] Allow setting `entrypoint` in `opaClient` rather than `package`

It wasn't clear from the docs what the name of the rule which was to be evaluated should be, as only the package was requested in configuration. The name shouldn't matter however, and I think it would be preferable if the user could set an entrypoint instead of a package. Entrypoints would be either a package or a package/rule combination and using any level of nesting, like policy, policy/backstage/permissions or policy/backstage/permissions/decision.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.