Skip to content
This repository was archived by the owner on Sep 27, 2022. It is now read-only.

Connect to Centrify Platform

Fab Viguier edited this page Dec 7, 2020 · 8 revisions

Before to be able to do any operations against your Centrify Platform tenant, you need to establish a connection using the Connect-CentrifyPlatform cmdlet. This cmdlet supports several authentication methods suitable for both interactive and non-interactive sessions.

Multi-Factor Authentication

When using the cmdlet Connect-CentrifyPlatform for an interactive authentication, the user used to authenticate will be subject to Multi Factor Authentication as if he would authenticate to the Centrify Services using a browser and navigating to the Centrify tenant URL.

To open a Centrify Platform connection using MFA, you need to specify the following information:

  • Url: The Centrify Platform tenant URL to authenticate to
  • User: The user name to authenticate with

Example:

PS C:\Users\Fabrice> Connect-CentrifyPlatform -Url aasgaard.my.centrify.net -User fabrice@aasgaard.net
Connecting to Centrify Identity Services (https://aasgaard.my.centrify.net) as fabrice@aasgaard.net

Enter Password: ********

[Available mechanisms]
1 - Centrify OTP Client
2 - Email... @aasgaard.co.uk
3 - SMS... XXX-0118
Please select a mechanism [1]: 3
Sending a text to mobile phone ending... 0118. Enter the code or click the link in the message to proceed with authentication.
Enter code or press <enter> to finish authentication:

CustomerID : AAC0566
User       : fabrice@aasgaard.net
PodFqdn    : aasgaard.my.centrify.net

OAuth2 Authentication

When using the cmdlet Connect-CentrifyPlatform for a non-interactive authentication, OAuth2 method offers added security by not only providing authentication but also authorisation. This can be achieved using the OAuth Confidential Client model, which combine authentication using a Centrify Service User authorised to perform OAuth Confidential Client authentications and authorisation by specifying a scope of authorised REST API when using obtained OAuth bearer token.

If you don't already have a Centrify Web App configured as an OAuth2 Client, you can configure one following the instructions here: Client Credentials Flow

To open a Centrify Platform connection using OAuth2, you need to specify the following information:

  • Url: The Centrify Platform tenant URL to authenticate to
  • Client: The OAuth2 Client Application ID as configured in the Centrify Web App
  • Scope: The OAuth2 scope to use (must be a scope existing in the OAuth2 Client application used)
  • Secret: Base64 string used to authenticate the OAuth Confidential Client

If you don't know how to encode Base64 string for HTTP Basic Authentication, you can use the Connect-CentrifyPlatform cmdlet to help you generate your encoded secret.

PS C:\Users\Fabrice\Documents\GitHub\Powershell-SDK> Connect-CentrifyPlatform -EncodeSecret
Confidential Client name: oauth_demo@aasgaard.my.centrify.net
Password: *******************
Secret: b2F1dGhfZGVtb0BhYXNnYWFyZC5teS5jZW50cmlmeS5uZXQ6VXNlU3Ryb25nUGFzc3dvcmRzMQ==
PS C:\Users\Fabrice\Documents\GitHub\Powershell-SDK>

Example:

PS C:\Users\Fabrice\Documents\GitHub\Powershell-SDK> Connect-CentrifyPlatform -Url aasgaard.my.centrify.net -Client "OAuth2Demo" -Scope "All" -Secret "b2F1dGhfZGVtb0BhYXNnYWFyZC5teS5jZW50cmlmeS5uZXQ6VXNlU3Ryb25nUGFzc3dvcmRzMQ=="
Connecting to Centrify Identity Services (https://aasgaard.my.centrify.net) using OAuth2 Client Credentials flow

CustomerId : AAC0566
User       : oauth_demo@aasgaard.my.centrify.net
PodFqdn    : aasgaard.my.centrify.net

PS C:\Users\Fabrice\Documents\GitHub\Powershell-SDK>

Note that the Secret used in these examples was only valid for this one time connection, use your own set of username/password and encoded secret to establish a secure connection in your environment.

Security considerations

For automation purpose, you should always prefer using OAuth2 authentication method to avoid storing username and password in scripts, or being prompted for MFA while performing an automated non-interactive authentication.

When using OAuth2 authentication method, you should always prefer storing the Base64 encoded Secret in scripts instead of the OAuth2 Confidential Client username and password. Base64 encoded strings are very easy to reverse and can then disclose username and password. Even though, using them instead of plain username and password helps minimising exposing credentials to bots and malwares scanning the file system.
Whenever there is a security risk associated to the script being accessed, you should consider storing the Secret in a more secure place (e.g. Registry, encrypted file or disk, secret vault).

Clone this wiki locally