@@ -0,0 +1,8 @@
|
||||
---
|
||||
'@backstage/backend-common': minor
|
||||
'example-app': patch
|
||||
'example-backend': patch
|
||||
'@backstage/plugin-permission-node': patch
|
||||
---
|
||||
|
||||
Integrate permission framework into example app
|
||||
@@ -22,13 +22,14 @@ resulting value.
|
||||
node -p 'require("crypto").randomBytes(24).toString("base64")'
|
||||
```
|
||||
|
||||
**NOTE**: For ease of development, we auto-generate a key for you if you haven't
|
||||
configured a secret in dev mode. You _must set your own secret_ in order for
|
||||
backend-to-backend authentication to work in production.
|
||||
|
||||
Requests originating from a backend plugin can be authenticated by decorating
|
||||
them with a backend token. Backend tokens can be generated using a
|
||||
`TokenManager`, which can be passed to plugin backends via the
|
||||
`PluginEnvironment`. The `TokenManager` provided in new Backstage instances
|
||||
generated by `create-app` is a stub, which returns empty tokens and accepts any
|
||||
input string as valid. To enable backend-to-backend authentication, you'll need
|
||||
to instantiate a new one using the secret from your config instead:
|
||||
`PluginEnvironment`.
|
||||
|
||||
```diff
|
||||
// packages/backend/src/index.ts
|
||||
@@ -42,8 +43,7 @@ function makeCreateEnv(config: Config) {
|
||||
|
||||
const cacheManager = CacheManager.fromConfig(config);
|
||||
const databaseManager = DatabaseManager.fromConfig(config);
|
||||
- const tokenManager = ServerTokenManager.noop();
|
||||
+ const tokenManager = ServerTokenManager.fromConfig(config);
|
||||
+ const tokenManager = ServerTokenManager.default({ config, logger: root });
|
||||
```
|
||||
|
||||
With this `tokenManager`, you can then generate a server token for requests:
|
||||
|
||||
@@ -126,9 +126,7 @@ export type PolicyDecision =
|
||||
}
|
||||
| ConditionalPolicyDecision;
|
||||
|
||||
// Warning: (ae-missing-release-tag) "ServerPermissionClient" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public (undocumented)
|
||||
// @public
|
||||
export class ServerPermissionClient extends PermissionClient {
|
||||
constructor(options: {
|
||||
discoveryApi: DiscoveryApi;
|
||||
|
||||
@@ -25,6 +25,11 @@ import {
|
||||
PermissionClient,
|
||||
} from '@backstage/plugin-permission-common';
|
||||
|
||||
/**
|
||||
* A server side {@link @backstage/plugin-permission-common#PermissionClient}
|
||||
* that allows all backend-to-backend requests.
|
||||
* @public
|
||||
*/
|
||||
export class ServerPermissionClient extends PermissionClient {
|
||||
private readonly serverTokenManager: ServerTokenManager;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user