chore: break apart changeset
Signed-off-by: benjdlambert <ben@blam.sh> Signed-off-by: benjdlambert <ben@blam.sh>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/backend-test-utils': minor
|
||||
---
|
||||
|
||||
Added mock implementations for `ActionsService` and `ActionsRegistryService`
|
||||
@@ -1,6 +1,5 @@
|
||||
---
|
||||
'@backstage/backend-plugin-api': minor
|
||||
'@backstage/backend-defaults': patch
|
||||
---
|
||||
|
||||
Added `coreServices.actionsRegistry` and `coreServices.actions` to allow registration of distributed actions from plugins, and the ability to invoke these actions
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/backend-defaults': patch
|
||||
---
|
||||
|
||||
Added some default implementations for the `ActionsService` and `ActionsRegistryService` that allow registration of actions for a particular plugin.
|
||||
+13
-13
@@ -82,6 +82,19 @@ export class DefaultActionsRegistryService implements ActionsRegistryService {
|
||||
router.post(
|
||||
'/.backstage/actions/v1/actions/:actionId/invoke',
|
||||
async (req, res) => {
|
||||
const credentials = await this.httpAuth.credentials(req);
|
||||
if (this.auth.isPrincipal(credentials, 'user')) {
|
||||
if (!credentials.principal.actor) {
|
||||
throw new NotAllowedError(
|
||||
`Actions must be invoked by a service, not a user`,
|
||||
);
|
||||
}
|
||||
} else if (this.auth.isPrincipal(credentials, 'none')) {
|
||||
throw new NotAllowedError(
|
||||
`Actions must be invoked by a service, not an anonymous request`,
|
||||
);
|
||||
}
|
||||
|
||||
const action = this.actions.get(req.params.actionId);
|
||||
|
||||
if (!action) {
|
||||
@@ -99,19 +112,6 @@ export class DefaultActionsRegistryService implements ActionsRegistryService {
|
||||
);
|
||||
}
|
||||
|
||||
const credentials = await this.httpAuth.credentials(req);
|
||||
if (this.auth.isPrincipal(credentials, 'user')) {
|
||||
if (!credentials.principal.actor) {
|
||||
throw new NotAllowedError(
|
||||
`Actions must be invoked by a service, not a user`,
|
||||
);
|
||||
}
|
||||
} else if (this.auth.isPrincipal(credentials, 'none')) {
|
||||
throw new NotAllowedError(
|
||||
`Actions must be invoked by a service, not an anonymous request`,
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await action.action({
|
||||
input: input.data,
|
||||
|
||||
Reference in New Issue
Block a user