Skip to content

[ApiManagement] Secure Parameter for Cmdlets #4837

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

Merged
merged 6 commits into from
Oct 25, 2017

Conversation

solankisamir
Copy link
Member

@solankisamir solankisamir commented Oct 23, 2017

Description


This checklist is used to make sure that common guidelines for a pull request are followed. You can find a more complete discussion of PowerShell cmdlet best practices here.

General Guidelines

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.
  • The pull request does not introduce breaking changes (unless a major version change occurs in the assembly and module).

Testing Guidelines

  • Pull request includes test coverage for the included changes.
  • PowerShell scripts used in tests should do any necessary setup as part of the test or suite setup, and should not use hard-coded values for locations or existing resources.

Cmdlet Signature Guidelines

  • New cmdlets that make changes or have side effects should implement ShouldProcess and have SupportShouldProcess=true specified in the cmdlet attribute. You can find more information on ShouldProcess here.
  • Cmdlet specifies OutputType attribute if any output is produced - if the cmdlet produces no output, it should implement a PassThru parameter.

Cmdlet Parameter Guidelines

  • Parameter types should not expose types from the management library - complex parameter types should be defined in the module.
  • Complex parameter types are discouraged - a parameter type should be simple types as often as possible. If complex types are used, they should be shallow and easily creatable from a constructor or another cmdlet.
  • Cmdlet parameter sets should be mutually exclusive - each parameter set must have at least one mandatory parameter not in other parameter sets.

* Breaking Changes in Cmdlet to Manage Api Management Users
Azure#4595
- New-AzureRmApiManagementUser Parameter `Password` is changed from
String to SecureString
- Set-AzureRmApiManagementBackend Parameter `Password` is changed from
String to SecureString

* Breaking Changes in Cmdlet to Create Backend Proxy Object
- New-AzureRmApiManagementBackendProxy Parameter `Password` and
`UserName` has been replaced with `ProxyCredentials` of type
PSCredential
* Updated Cmdlet Get-AzureRmApiManagementUser to fix issue
Azure#4510
* Updated Cmdlet New-AzureRmApiManagementApi to create Api with Empty
Path Azure#4069
* Updated documentation for issue
Azure#4676
Copy link
Contributor

@maddieclayton maddieclayton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few small things to fix.

@@ -2039,10 +2043,9 @@ Param($resourceGroupName, $serviceName)
$backendId = getAssetName
try
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix spacing issues with this test

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed formatting throughout the file using VSCode extension for Powershell

{
var user = Client.UsersList(Context, FirstName, LastName, Email, State, GroupId);
WriteObject(user, true);
}
else
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't need this else statement anymore because all three parameter sets are covered (and powershell will always resolve to one parameter set).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -916,6 +916,55 @@ Param($resourceGroupName, $serviceName)
Assert-AreEqual $userNote $user.Note
Assert-AreEqual $userState $user.State

#find user by email
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a few tests with multiple byId parameters (both first and last name for example)?

- Set-AzureRmApiManagementBackend Parameter `Password` is changed from String to SecureString

* Breaking Changes in Cmdlet to Create Backend Proxy Object
- New-AzureRmApiManagementBackendProxy Parameter `Password` and `UserName` has been replaced with `ProxyCredentials` of type PSCredential
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be "... Parameters Password and UserName have been replaced..."

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -39,20 +43,23 @@ The **Get-AzureRmApiManagementApi** cmdlet gets one or more Azure API Management

### Example 1: Get all management APIs
```
PS C:\>Get-AzureRmApiManagementApi -Context $ApiMgmtContext
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice if these examples also had sample output, but not a blocker for this PR.

@@ -24,13 +25,28 @@ The context is used for all of the API Management service cmdlets.

### Example 1: Create a PsApiManagementContext instance
```
PS C:\>$ApiMgmtContext = New-AzureRmApiManagementContext -ResourceGroupName "ContosoResources" -ServiceName "Contoso"
PS C:\>PS C:\>$ApiMgmtContext = New-AzureRmApiManagementContext -ResourceGroupName "ContosoResources" -ServiceName "Contoso"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove extra powershell prompt

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -58,7 +58,7 @@ $RequestRepresentation.Sample = '{ "propName": "propValue" }'
$Request.Representations = @($requestRepresentation)
$Response = New-Object -TypeName Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models.PsApiManagementResponse
$Response.StatusCode = 204
New-AzureRmApiManagementOperation -Context $APImContext -ApiId $APIId -OperationId "01234567890" -Name 'Create/update resource' -Method 'PUT' -UrlTemplate '/resource/{rid}?q={query}' -Description "Use this operation to create new or update existing resource" -TemplateParameters @($rid, $query) -Request $Request -Responses @($response)
New-AzureRmApiManagementOperation -Context $apimContext -ApiId $APIId -OperationId "01234567890" -Name 'Create/update resource' -Method 'PUT' -UrlTemplate '/resource/{rid}?q={query}' -Description "Use this operation to create new or update existing resource" -TemplateParameters @($rid, $query) -Request $Request -Responses @($response)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add "PS C:>" to all separate powershell commands

@@ -25,7 +25,8 @@ The **New-AzureRmApiManagementUser** cmdlet registers a new user.

### Example 1: Register a new user
```
PS C:\>New-AzureRmApiManagementUser -Context $apimContext -FirstName "Patti" -LastName "Fuller" -Email "[email protected]" -Password "qwerty"
$securePassword = ConvertTo-SecureString "qwerty" -AsPlainText -Force
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add "PS C:>"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

```
PS C:\>$apimContext = New-AzureRmApiManagementContext -ResourceGroupName "Api-Default-WestUS" -ServiceName "contoso"
Remove-AzureRmApiManagementIdentityProvider -Context $apimContext -Type 'Facebook' -PassThru
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add "PS C:>"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -25,7 +25,9 @@ The **Set-AzureRmApiManagementUser** cmdlet sets user details.

### Example 1: Change a user's password, email address and state
```
PS C:\>Set-AzureRmApiManagementUser -Context $apimContext -UserId "0123456789" -Email "[email protected]" -Password "asdfgh" -State "Blocked"
PS C:\>$apimContext = New-AzureRmApiManagementContext -ResourceGroupName "Api-Default-WestUS" -ServiceName "contoso"
$securePassword = ConvertTo-SecureString "qwerty" -AsPlainText -Force
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add "PS C:>"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

maddieclayton
maddieclayton previously approved these changes Oct 24, 2017
@maddieclayton
Copy link
Contributor

@KedarJoshi
Copy link

#sign-off

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants