-
Notifications
You must be signed in to change notification settings - Fork 0
AzDoSecurityNamespacePermission
The AzDoSecurityNamespacePermission DSC resource is used to manage granular permissions within Azure DevOps security namespaces. It allows advanced users and administrators to configure fine-grained access control for specific Azure DevOps resources and operations using the underlying security token system, providing flexibility for complex permission scenarios that standard resource permissions don't cover.
AzDoSecurityNamespacePermission [string] #ResourceName
{
SecurityNamespace = [String] $SecurityNamespace
Token = [String] $Token
GroupName = [String] $GroupName
[ isInherited = [Boolean] $isInherited ]
[ Permissions = [HashTable[]] $Permissions ]
[ Ensure = [String] {'Present', 'Absent'} ]
[ DependsOn = [String[]] ]
[ PsDscRunAsCredential = [PSCredential] ]
}-
SecurityNamespace [String] - The identifier of the security namespace (e.g., 'Build', 'Release', 'Git Repositories').
-
Token [String] - The security token that identifies the specific resource within the namespace.
-
GroupName [String] - The name of the group whose permissions are being managed.
-
isInherited [Boolean] - Whether permissions are inherited. Default is
$true. -
Permissions [HashTable[]] - An array of permission hashtables, each containing:
-
PermissionBit- The numeric permission bit or name -
Allow- Boolean indicating if permission is allowed -
Deny- Boolean indicating if permission is denied
-
-
Ensure [String] - Desired state of the resource:
-
'Present'- (default) Permissions should be configured -
'Absent'- Permissions should be removed
-
-
DependsOn [String[]] - Dependencies on other resources. Use this to control the order of resource execution.
-
PsDscRunAsCredential [PSCredential] - Credentials to run this resource under.
The resource returns the following properties:
- SecurityNamespace - The security namespace identifier
- Token - The security token
- GroupName - The group name
- isInherited - Whether permissions are inherited
- Permissions - The configured permissions
- Ensure - Current state ('Present' or 'Absent')
Configuration NamespacePermissions {
Import-DscResource -ModuleName 'AzureDevOpsDscNative'
Node localhost {
AzDoSecurityNamespacePermission 'BuildPermissions' {
SecurityNamespace = 'Build'
Token = 'ProjectToken'
GroupName = 'Developers'
isInherited = $false
Permissions = @(
@{
PermissionBit = 'Read'
Allow = $true
},
@{
PermissionBit = 'Execute'
Allow = $true
}
)
Ensure = 'Present'
}
}
}
NamespacePermissions
Start-DscConfiguration -Path ./NamespacePermissions -Wait -VerboseConfiguration AdvancedPermissions {
Import-DscResource -ModuleName 'AzureDevOpsDscNative'
Node localhost {
AzDoSecurityNamespacePermission 'ReleasePermissions' {
SecurityNamespace = 'Release'
Token = 'ReleaseDefinitionToken'
GroupName = 'Release Team'
isInherited = $false
Permissions = @(
@{ PermissionBit = 'Read'; Allow = $true },
@{ PermissionBit = 'Create'; Allow = $true },
@{ PermissionBit = 'Edit'; Allow = $true }
)
Ensure = 'Present'
}
}
}
AdvancedPermissions
Start-DscConfiguration -Path ./AdvancedPermissions -Wait -VerboseConfiguration RestrictNamespaceAccess {
Import-DscResource -ModuleName 'AzureDevOpsDscNative'
Node localhost {
AzDoSecurityNamespacePermission 'AdminAccess' {
SecurityNamespace = 'AnalyticsViews'
Token = 'ProjectToken'
GroupName = 'Project Admins'
isInherited = $false
Permissions = @(
@{ PermissionBit = 'Read'; Allow = $true },
@{ PermissionBit = 'Create'; Allow = $true },
@{ PermissionBit = 'Edit'; Allow = $true },
@{ PermissionBit = 'Delete'; Allow = $true }
)
Ensure = 'Present'
}
AzDoSecurityNamespacePermission 'UserRestriction' {
SecurityNamespace = 'AnalyticsViews'
Token = 'ProjectToken'
GroupName = 'Developers'
isInherited = $false
Permissions = @(
@{ PermissionBit = 'Edit'; Allow = $false; Deny = $true }
)
Ensure = 'Present'
}
}
}
RestrictNamespaceAccess
Start-DscConfiguration -Path ./RestrictNamespaceAccess -Wait -Verbose# Get the current state of namespace permissions
$properties = @{
SecurityNamespace = 'Build'
Token = 'ProjectToken'
GroupName = 'Developers'
}
$result = Invoke-DscResource -Name 'AzDoSecurityNamespacePermission' `
-Method Get `
-Property $properties `
-ModuleName 'AzureDevOpsDscNative'
$result | Select-Object SecurityNamespace, Token, GroupName, isInherited, PermissionsConfiguration MultiNamespaceConfig {
Import-DscResource -ModuleName 'AzureDevOpsDscNative'
Node localhost {
AzDoSecurityNamespacePermission 'GitNamespace' {
SecurityNamespace = 'Git Repositories'
Token = 'RepositoryToken'
GroupName = 'Developers'
isInherited = $false
Permissions = @(
@{ PermissionBit = 'Read'; Allow = $true },
@{ PermissionBit = 'Write'; Allow = $true }
)
Ensure = 'Present'
}
AzDoSecurityNamespacePermission 'IterationNamespace' {
SecurityNamespace = 'Iteration'
Token = 'ProjectToken'
GroupName = 'Team'
isInherited = $false
Permissions = @(
@{ PermissionBit = 'Edit'; Allow = $true }
)
Ensure = 'Present'
}
}
}
MultiNamespaceConfig
Start-DscConfiguration -Path ./MultiNamespaceConfig -Wait -Verbose- Namespaces represent categories of securable objects (Build, Release, Git, etc.)
- Each namespace has specific permissions (Read, Write, Edit, Delete, etc.)
- Token identifies the specific resource within the namespace
- This is an advanced resource for complex permission scenarios
- Use standard permission resources (AzDoPipelinePermission, etc.) when available
- Requires understanding of Azure DevOps security model
- Tokens are hierarchical identifiers for resources
- Format varies by namespace type
- Examples: project tokens, repository tokens, pipeline definition tokens
- Use specific resource permission resources when available
- Document namespace and token usage for maintainability
- Test permission changes in non-production first
- Regularly audit namespace-level permissions
Cause: Namespace name is incorrect or doesn't exist
Solution:
# Verify namespace name matches Azure DevOps security model
# Common namespaces: Build, Release, Git Repositories, Iteration, etc.Cause: Token format doesn't match the namespace type
Solution:
- Research token format for specific namespace
- Tokens vary by namespace type and resource
- Consult Azure DevOps security documentation
Cause: Insufficient permissions or invalid group
Solution:
- Verify user has namespace administrator permissions
- Check group exists at appropriate level
- Ensure personal access token has sufficient scope
- AzDoPipelinePermission - Manage pipeline permissions
- AzDoGitPermission - Manage repository permissions
- AzDoAreaPermission - Manage area permissions
- AzDoGroupPermission - Manage group permissions