diff --git a/.changeset/ten-dryers-compete.md b/.changeset/ten-dryers-compete.md index 02715d0736..f1591c0040 100644 --- a/.changeset/ten-dryers-compete.md +++ b/.changeset/ten-dryers-compete.md @@ -4,4 +4,4 @@ '@backstage/plugin-azure-devops-common': patch --- -Azure DevOps plugin is now integrated with permission framework for its core features, see the https://github.com/backstage/backstage/blob/master/plugins/azure-devops/README.md for more details. +Azure DevOps plugin is now integrated with permission framework for its core features, see the https://github.com/backstage/backstage/blob/master/plugins/azure-devops/README.md#permission-framework for more details. diff --git a/plugins/azure-devops/README.md b/plugins/azure-devops/README.md index 996ff57690..9e5ec384f8 100644 --- a/plugins/azure-devops/README.md +++ b/plugins/azure-devops/README.md @@ -322,9 +322,11 @@ To get the README component working you'll need to do the following two steps: ## Permission Framework -Azure DevOps plugin is now supporting the permission framework for PRs, GitTags, Pipelines & ReadMe. +Azure DevOps plugin supports the permission framework for PRs, GitTags, Pipelines and Readme features. -To enable the permission on the legacy backend system add the below config in `packages/backend/src/plugins/azure-devops.ts`. +New Backend you can skip the below and proceed with [permission configuration](#configure-permission) + +To enable permissions for the legacy backend system in `packages/backend/src/plugins/azure-devops.ts` add the following. ```diff export default async function createPlugin( @@ -341,17 +343,18 @@ export default async function createPlugin( ### Configure Permission -To apply the permission rule add the following in `packages/backend/src/plugins/permissions.ts`. +To apply the permission rules add the following in `packages/backend/src/plugins/permissions.ts`. -> Note this is example only `azureDevOpsPullRequestDashboardReadPermission` is Basic permission rest all Resource Permission. As an adopter you can configure how you wanted. +> Note: the following is just an example of how you might want to setup permissions, as an Adopter you can configure this to fit your needs. Also all the permissions are Resource Permissions as they work with an Entity with the exception of `azureDevOpsPullRequestDashboardReadPermission`. ```diff + + import { + azureDevOpsPullRequestReadPermission, + azureDevOpsPipelineReadPermission, + azureDevOpsGitTagReadPermission, + azureDevOpsReadmeReadPermission, -+ azureDevOpsPullRequestDashboardReadPermission } from '@backstage/azure-devops-common'; ++ azureDevOpsPullRequestDashboardReadPermission } from '@backstage/plugin-azure-devops-common'; ... async handle( request: PolicyQuery, @@ -361,7 +364,7 @@ async handle( + isPermission(request.permission, azureDevOpsPipelineReadPermission) || + isPermission(request.permission, azureDevOpsGitTagReadPermission) || + isPermission(request.permission, azureDevOpsReadmeReadPermission)) { -+ return createTodoListConditionalDecision( ++ return createCatalogConditionalDecision( + request.permission, + catalogConditions.isEntityOwner({ + claims: user?.identity.ownershipEntityRefs ?? [], @@ -370,7 +373,9 @@ async handle( + } + if ( isPermission(request.permission, azureDevOpsPullRequestDashboardReadPermission) { ++ return { + result: AuthorizeResult.ALLOW, ++ }; + } return { diff --git a/plugins/azure-devops/src/api/AzureDevOpsClient.ts b/plugins/azure-devops/src/api/AzureDevOpsClient.ts index e1fde33555..ea78f3d3a1 100644 --- a/plugins/azure-devops/src/api/AzureDevOpsClient.ts +++ b/plugins/azure-devops/src/api/AzureDevOpsClient.ts @@ -198,6 +198,7 @@ export class AzureDevOpsClient implements AzureDevOpsApi { if (opts.path) { queryString.append('path', opts.path); } + queryString.append('entityRef', opts.entityRef); return await this.get( `readme/${encodeURIComponent(opts.project)}/${encodeURIComponent( opts.repo,