Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove principaltype in Synapse Role-based access control #14767

Merged
merged 7 commits into from
Apr 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Synapse/Synapse/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Additional information about change #1
-->
## Upcoming Release
* Removed principaltype in Synapse Role-based access control

## Version 0.10.0
* Add support for Synapse Role-based access control
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,6 @@ public class NewAzureSynapseRoleAssignment : SynapseRoleCmdletBase
[ValidateNotNullOrEmpty]
public string Item { get; set; }

[Parameter(ValueFromPipelineByPropertyName = false, Mandatory = false, HelpMessage = HelpMessages.WorkspacePrincipalType)]
[ValidateNotNullOrEmpty]
public PrincipalType PrincipalType { get; set; }

[Parameter(Mandatory = false, HelpMessage = HelpMessages.AsJob)]
public SwitchParameter AsJob { get; set; }

Expand Down Expand Up @@ -141,12 +137,6 @@ public override void ExecuteCmdlet()
itemType = this.ItemType.GetItemTypeString();
}

string principalType = null;
if (this.IsParameterBound(c => c.PrincipalType))
{
principalType = this.PrincipalType.GetPrincipalTypeString();
}

if (this.ShouldProcess(this.WorkspaceName, String.Format(Resources.CreatingSynapseRoleAssignment, this.WorkspaceName, this.RoleDefinitionId, this.ObjectId)))
{
// Item type and item should appear Report error if either item type or item is specified.
Expand All @@ -158,7 +148,7 @@ public override void ExecuteCmdlet()

string roleAssignmentId = Guid.NewGuid().ToString();
string scope = SynapseAnalyticsClient.GetRoleAssignmentScope(this.WorkspaceName, itemType, this.Item);
PSRoleAssignmentDetails roleAssignmentDetails = new PSRoleAssignmentDetails(SynapseAnalyticsClient.CreateRoleAssignment(roleAssignmentId, this.RoleDefinitionId, this.ObjectId, scope, principalType));
PSRoleAssignmentDetails roleAssignmentDetails = new PSRoleAssignmentDetails(SynapseAnalyticsClient.CreateRoleAssignment(roleAssignmentId, this.RoleDefinitionId, this.ObjectId, scope));
WriteObject(roleAssignmentDetails);
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/Synapse/Synapse/Common/HelpMessages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,6 @@ SELECT on dbo.myTable by public

public const string WorkspaceItem = "The workspace item.";

public const string WorkspacePrincipalType = "The workspace principal type.";

public const string IsActiveCustomerManagedKey = "Indicates whether to activate the workspace after a customer managed key is provided.";

public const string KeyResourceId = "The resource identifier of Synapse SQL Pool.";
Expand Down
19 changes: 0 additions & 19 deletions src/Synapse/Synapse/Common/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,24 +220,5 @@ public static string GetItemTypeString(this WorkspaceItemType itemType)

return itemTypeString;
}

public static string GetPrincipalTypeString(this PrincipalType principalType)
{
string principalTypeString = null;
switch (principalType)
{
case PrincipalType.User:
principalTypeString = "User";
break;
case PrincipalType.Group:
principalTypeString = "Group";
break;
case PrincipalType.ServicePrincipal:
principalTypeString = "ServicePrincipal";
break;
}

return principalTypeString;
}
}
}
4 changes: 2 additions & 2 deletions src/Synapse/Synapse/Models/SynapseAnalyticsRoleClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ public RoleAssignmentDetails GetRoleAssignmentById(string roleAssignmentId)
return _roleAssignmentsClient.GetRoleAssignmentById(roleAssignmentId);
}

public RoleAssignmentDetails CreateRoleAssignment(string roleAssignmentId, string roleDefinitionId, string objectId, string scope, string principalType)
public RoleAssignmentDetails CreateRoleAssignment(string roleAssignmentId, string roleDefinitionId, string objectId, string scope)
{
return _roleAssignmentsClient.CreateRoleAssignment(roleAssignmentId, new Guid(roleDefinitionId), new Guid(objectId), scope, principalType);
return _roleAssignmentsClient.CreateRoleAssignment(roleAssignmentId, new Guid(roleDefinitionId), new Guid(objectId), scope);
}

public void DeleteRoleAssignmentById(string roleAssignmentId)
Expand Down
7 changes: 0 additions & 7 deletions src/Synapse/Synapse/Models/SynapseConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,5 @@ public enum WorkspaceItemType
LinkedService,
Credential
}

public enum PrincipalType
{
User,
Group,
ServicePrincipal
}
}
}
51 changes: 17 additions & 34 deletions src/Synapse/Synapse/help/New-AzSynapseRoleAssignment.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,58 +15,57 @@ Creates a Synapse Analytics role assignment.
### NewByWorkspaceNameAndNameParameterSet (Default)
```
New-AzSynapseRoleAssignment -WorkspaceName <String> -RoleDefinitionName <String> -SignInName <String>
[-ItemType <WorkspaceItemType>] [-Item <String>] [-PrincipalType <PrincipalType>] [-AsJob]
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
[-ItemType <WorkspaceItemType>] [-Item <String>] [-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
[-Confirm] [<CommonParameters>]
```

### NewByWorkspaceNameAndIdParameterSet
```
New-AzSynapseRoleAssignment -WorkspaceName <String> -RoleDefinitionName <String> -ObjectId <String>
[-ItemType <WorkspaceItemType>] [-Item <String>] [-PrincipalType <PrincipalType>] [-AsJob]
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
[-ItemType <WorkspaceItemType>] [-Item <String>] [-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
[-Confirm] [<CommonParameters>]
```

### NewByWorkspaceNameAndRoleDefinitionIdAndObjectIdParameterSet
```
New-AzSynapseRoleAssignment -WorkspaceName <String> -RoleDefinitionId <String> -ObjectId <String>
[-ItemType <WorkspaceItemType>] [-Item <String>] [-PrincipalType <PrincipalType>] [-AsJob]
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
[-ItemType <WorkspaceItemType>] [-Item <String>] [-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
[-Confirm] [<CommonParameters>]
```

### NewByWorkspaceNameAndServicePrincipalNameParameterSet
```
New-AzSynapseRoleAssignment -WorkspaceName <String> -RoleDefinitionName <String> -ServicePrincipalName <String>
[-ItemType <WorkspaceItemType>] [-Item <String>] [-PrincipalType <PrincipalType>] [-AsJob]
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
[-ItemType <WorkspaceItemType>] [-Item <String>] [-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
[-Confirm] [<CommonParameters>]
```

### NewByWorkspaceObjectAndNameParameterSet
```
New-AzSynapseRoleAssignment -WorkspaceObject <PSSynapseWorkspace> -RoleDefinitionName <String>
-SignInName <String> [-ItemType <WorkspaceItemType>] [-Item <String>] [-PrincipalType <PrincipalType>]
[-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
-SignInName <String> [-ItemType <WorkspaceItemType>] [-Item <String>] [-AsJob]
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

### NewByWorkspaceObjectAndIdParameterSet
```
New-AzSynapseRoleAssignment -WorkspaceObject <PSSynapseWorkspace> -RoleDefinitionName <String>
-ObjectId <String> [-ItemType <WorkspaceItemType>] [-Item <String>] [-PrincipalType <PrincipalType>] [-AsJob]
-ObjectId <String> [-ItemType <WorkspaceItemType>] [-Item <String>] [-AsJob]
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

### NewByWorkspaceObjectAndRoleDefinitionIdAndObjectIdParameterSet
```
New-AzSynapseRoleAssignment -WorkspaceObject <PSSynapseWorkspace> -RoleDefinitionId <String> -ObjectId <String>
[-ItemType <WorkspaceItemType>] [-Item <String>] [-PrincipalType <PrincipalType>] [-AsJob]
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
[-ItemType <WorkspaceItemType>] [-Item <String>] [-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
[-Confirm] [<CommonParameters>]
```

### NewByWorkspaceObjectAndServicePrincipalNameParameterSet
```
New-AzSynapseRoleAssignment -WorkspaceObject <PSSynapseWorkspace> -RoleDefinitionName <String>
-ServicePrincipalName <String> [-ItemType <WorkspaceItemType>] [-Item <String>]
[-PrincipalType <PrincipalType>] [-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
[<CommonParameters>]
-ServicePrincipalName <String> [-ItemType <WorkspaceItemType>] [-Item <String>] [-AsJob]
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

## DESCRIPTION
Expand All @@ -90,10 +89,10 @@ This command assigns ContosoRole to the user whose principal name is ContosoName

### Example 3
```powershell
PS C:\> New-AzSynapseRoleAssignment -WorkspaceName ContosoWorkspace -RoleDefinitionName ContosoRole -SignInName ContosoName -ItemType ContosoItemType -Item ContosoItem -PrincipalType ContosoPrincipalType
PS C:\> New-AzSynapseRoleAssignment -WorkspaceName ContosoWorkspace -RoleDefinitionName ContosoRole -SignInName ContosoName -ItemType ContosoItemType -Item ContosoItem
```

This command assigns ContosoRole to the user whose principal name is ContosoName and item type is ContosoItemType, item is ContosoItem, principal type is ContosoPrincipalType.
This command assigns ContosoRole to the user whose principal name is ContosoName and item type is ContosoItemType, item is ContosoItem.

### Example 4
```powershell
Expand Down Expand Up @@ -181,22 +180,6 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -PrincipalType
The workspace principal type.

```yaml
Type: Microsoft.Azure.Commands.Synapse.Models.SynapseConstants+PrincipalType
Parameter Sets: (All)
Aliases:
Accepted values: User, Group, ServicePrincipal

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -RoleDefinitionId
Id of the Role that is assigned to the principal.

Expand Down
2 changes: 0 additions & 2 deletions src/Synapse/Synapse/help/Remove-AzSynapseRoleAssignment.md
Original file line number Diff line number Diff line change
Expand Up @@ -358,5 +358,3 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
## NOTES

## RELATED LINKS

## RELATED LINKS
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,14 @@
"Microsoft.Azure.PowerShell.Cmdlets.Synapse.dll","Microsoft.Azure.Commands.Synaspe.NewAzureSynapseWorkspace","New-AzSynapseWorkspace","0","2020","The cmdlet 'New-AzSynapseWorkspace' no longer supports the type 'System.String' for parameter 'ManagedVirtualNetwork'.","Change the type for parameter 'ManagedVirtualNetwork' back to 'System.String'."
"Microsoft.Azure.PowerShell.Cmdlets.Synapse.dll","Microsoft.Azure.Commands.Synapse.NewAzureSynapseFirewallRule","New-AzSynapseFirewallRule","0","2000","The cmdlet 'New-AzSynapseFirewallRule' no longer supports the parameter 'AllowAllAzureIP' and no alias was found for the original parameter name.","Add the parameter 'AllowAllAzureIP' back to the cmdlet 'New-AzSynapseFirewallRule', or add an alias to the original parameter name."
"Microsoft.Azure.PowerShell.Cmdlets.Synapse.dll","Microsoft.Azure.Commands.Synapse.NewAzureSynapseFirewallRule","New-AzSynapseFirewallRule","0","1050","The parameter set 'CreateByNameAllowAllIpParameterSet' for cmdlet 'New-AzSynapseFirewallRule' has been removed.","Add parameter set 'CreateByNameAllowAllIpParameterSet' back to cmdlet 'New-AzSynapseFirewallRule'."
"Microsoft.Azure.PowerShell.Cmdlets.Synapse.dll","Microsoft.Azure.Commands.Synapse.NewAzureSynapseFirewallRule","New-AzSynapseFirewallRule","0","1050","The parameter set 'CreateByParentObjectAllowAllIpParameterSet' for cmdlet 'New-AzSynapseFirewallRule' has been removed.","Add parameter set 'CreateByParentObjectAllowAllIpParameterSet' back to cmdlet 'New-AzSynapseFirewallRule'."
"Microsoft.Azure.PowerShell.Cmdlets.Synapse.dll","Microsoft.Azure.Commands.Synapse.NewAzureSynapseFirewallRule","New-AzSynapseFirewallRule","0","1050","The parameter set 'CreateByParentObjectAllowAllIpParameterSet' for cmdlet 'New-AzSynapseFirewallRule' has been removed.","Add parameter set 'CreateByParentObjectAllowAllIpParameterSet' back to cmdlet 'New-AzSynapseFirewallRule'."
"Microsoft.Azure.PowerShell.Cmdlets.Synapse.dll","Microsoft.Azure.Commands.Synapse.NewAzureSynapseRoleAssignment","New-AzSynapseRoleAssignment","0","2000","The cmdlet 'New-AzSynapseRoleAssignment' no longer supports the parameter 'PrincipalType' and no alias was found for the original parameter name.","Add the parameter 'PrincipalType' back to the cmdlet 'New-AzSynapseRoleAssignment', or add an alias to the original parameter name."
"Microsoft.Azure.PowerShell.Cmdlets.Synapse.dll","Microsoft.Azure.Commands.Synapse.NewAzureSynapseRoleAssignment","New-AzSynapseRoleAssignment","0","1050","The parameter set 'NewByWorkspaceNameAndNameParameterSet' for cmdlet 'New-AzSynapseRoleAssignment' has been removed.","Add parameter set 'NewByWorkspaceNameAndNameParameterSet' back to cmdlet 'New-AzSynapseRoleAssignment'."
"Microsoft.Azure.PowerShell.Cmdlets.Synapse.dll","Microsoft.Azure.Commands.Synapse.NewAzureSynapseRoleAssignment","New-AzSynapseRoleAssignment","0","1050","The parameter set 'NewByWorkspaceNameAndIdParameterSet' for cmdlet 'New-AzSynapseRoleAssignment' has been removed.","Add parameter set 'NewByWorkspaceNameAndIdParameterSet' back to cmdlet 'New-AzSynapseRoleAssignment'."
"Microsoft.Azure.PowerShell.Cmdlets.Synapse.dll","Microsoft.Azure.Commands.Synapse.NewAzureSynapseRoleAssignment","New-AzSynapseRoleAssignment","0","1050","The parameter set 'NewByWorkspaceNameAndRoleDefinitionIdAndObjectIdParameterSet' for cmdlet 'New-AzSynapseRoleAssignment' has been removed.","Add parameter set 'NewByWorkspaceNameAndRoleDefinitionIdAndObjectIdParameterSet' back to cmdlet 'New-AzSynapseRoleAssignment'."
"Microsoft.Azure.PowerShell.Cmdlets.Synapse.dll","Microsoft.Azure.Commands.Synapse.NewAzureSynapseRoleAssignment","New-AzSynapseRoleAssignment","0","1050","The parameter set 'NewByWorkspaceNameAndServicePrincipalNameParameterSet' for cmdlet 'New-AzSynapseRoleAssignment' has been removed.","Add parameter set 'NewByWorkspaceNameAndServicePrincipalNameParameterSet' back to cmdlet 'New-AzSynapseRoleAssignment'."
"Microsoft.Azure.PowerShell.Cmdlets.Synapse.dll","Microsoft.Azure.Commands.Synapse.NewAzureSynapseRoleAssignment","New-AzSynapseRoleAssignment","0","1050","The parameter set 'NewByWorkspaceObjectAndNameParameterSet' for cmdlet 'New-AzSynapseRoleAssignment' has been removed.","Add parameter set 'NewByWorkspaceObjectAndNameParameterSet' back to cmdlet 'New-AzSynapseRoleAssignment'."
"Microsoft.Azure.PowerShell.Cmdlets.Synapse.dll","Microsoft.Azure.Commands.Synapse.NewAzureSynapseRoleAssignment","New-AzSynapseRoleAssignment","0","1050","The parameter set 'NewByWorkspaceObjectAndIdParameterSet' for cmdlet 'New-AzSynapseRoleAssignment' has been removed.","Add parameter set 'NewByWorkspaceObjectAndIdParameterSet' back to cmdlet 'New-AzSynapseRoleAssignment'."
"Microsoft.Azure.PowerShell.Cmdlets.Synapse.dll","Microsoft.Azure.Commands.Synapse.NewAzureSynapseRoleAssignment","New-AzSynapseRoleAssignment","0","1050","The parameter set 'NewByWorkspaceObjectAndRoleDefinitionIdAndObjectIdParameterSet' for cmdlet 'New-AzSynapseRoleAssignment' has been removed.","Add parameter set 'NewByWorkspaceObjectAndRoleDefinitionIdAndObjectIdParameterSet' back to cmdlet 'New-AzSynapseRoleAssignment'."
"Microsoft.Azure.PowerShell.Cmdlets.Synapse.dll","Microsoft.Azure.Commands.Synapse.NewAzureSynapseRoleAssignment","New-AzSynapseRoleAssignment","0","1050","The parameter set 'NewByWorkspaceObjectAndServicePrincipalNameParameterSet' for cmdlet 'New-AzSynapseRoleAssignment' has been removed.","Add parameter set 'NewByWorkspaceObjectAndServicePrincipalNameParameterSet' back to cmdlet 'New-AzSynapseRoleAssignment'."
"Microsoft.Azure.PowerShell.Cmdlets.Synapse.dll","Microsoft.Azure.Commands.Synapse.NewAzureSynapseRoleAssignment","New-AzSynapseRoleAssignment","0","1050","The parameter set '__AllParameterSets' for cmdlet 'New-AzSynapseRoleAssignment' has been removed.","Add parameter set '__AllParameterSets' back to cmdlet 'New-AzSynapseRoleAssignment'."