Since v12.5 of the portal (or PVWA), authentication via Swagger has changed. Now users need to log into Swagger through the Auth API on the Swagger page. This describes how to use SAML authentication to login to Swagger.
Steps
Pre-requisites:-
- IdP initiated SSO must be set in the <appSettings> section of the <Drive letter>:\inetpub\wwwroot\PasswordVault\web.config file on the PVWA:-
<add key="EnableIdPInitiatedSso" value="yes"/>
- Find the User access URL of the Idira App from the IdP. For example, the Idira Application in Azure will be something like this:-
This is where to find this value in Azure:-
- Download the PS-SAML-Interactive module from the following website - https://github.com/allynl93/PS-SAML-Interactive
Procedure:-
On the machine you want to use for Swagger, place the PS-SAML-Interactive module into a separate directory and open this directory into a Powershell Administrator window. Then type the following:-
- import-module -name .\PS-SAML-Interactive.psm1
- $LoginURL = 'https://myapps.microsoft.com/signin/1ab23456-123a-12a3-a123-1234a567bc89?tenantId=a1b2c3d4-1ab2-12ab-ab1c-1abcd234567e'
- New-SAMLInteractive -LoginIDP $LoginURL
You will then be prompted for login credentials for your IdP. These credentials should be the ones you want to use to login to Swagger.
A SAMLResponse will be returned in the Powershell window. To make things easier, you could change the third command above to 'New-SAMLInteractive -LoginIDP $LoginURL > SAMLResponse.txt' so that the SAML Response is saved to a text file.
The SAML Response now needs to be URL encoded since it will probably contain characters that are not in a format that can be transmitted over the internet. Such characters include '+' or '#'. For this you can use a website such as www.samltools.com/url.php or meyerweb.com/eric/tools/dencoder (other sites are available).
Copy the urlencoded SAML Response into a notepad file or similar.
Navigate to the swagger page and click on the AUTH API. For the 'type' value use SAML and for the 'data' value use the following:-
SAMLResponse=<url encoded SAMLResponse>&apiUse=true
Note: Though the below screenshot says that setting "secureMode" to "true" is optional, the current workflow requires this key to either be deleted from the call or set to "false." If you have it set to "true," you will get errors on subsequent calls after authenticating.
Ensure that Parameter content type is set to application/x-www-form-urlencoded
After clicking ‘Try it out’ you will see an authentication token in the Response body with a Response Code of 200.
This indicates that authorization was successful. Now you will be able to carry out tasks using the other APIs on the swagger page.
PLEASE NOTE: Authentication will fail if ANY user is already logged in to the PVWA or Web Portal through another tab on the same browser. If the user wants to use Swagger as well as being logged into the PVWA or Web Portal then Swagger will need to be loaded up with the browser window in incognito mode.