chore: break apart changeset

Signed-off-by: benjdlambert <ben@blam.sh>

Signed-off-by: benjdlambert <ben@blam.sh>
This commit is contained in:
benjdlambert
2025-05-27 14:26:27 +02:00
parent a9219496d5
commit c999c2568b
4 changed files with 23 additions and 14 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/backend-test-utils': minor
---
Added mock implementations for `ActionsService` and `ActionsRegistryService`
-1
View File
@@ -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
+5
View File
@@ -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.
@@ -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,