Use Azure Entra ID as authentication for Portainer

Published on

Use Azure Entra ID as authentication for Portainer

If you’re using the BE version of Portainer, you can easily set up your Azure Entra tenant user as an authentication source with just a single click. Unfortunately, this feature isn’t available in the CE edition. However, since both Portainer and Azure Entra use OAuth 2.0, it’s entirely possible to integrate Azure Entra with Portainer!

Chances are, if you’ve landed on this page, you already know what Portainer is. In a nutshell, Portainer is a management tool for Docker containers, allowing you to manage them on one or multiple nodes through a web interface. So, instead of managing your containers through the command line interface, you expose a web interface for Docker management.

If you navigate within Portainer to Settings -> Authentication, you’ll notice that the Azure Entra feature is only available in the BE edition. While LDAP is available in the CE edition, this protocol isn’t supported by Azure Entra. Fortunately, it’s possible to configure Azure Entra with the OAuth option.

Step 1: Configuring Azure Entra ID

To enable Portainer to use Azure Entra, you must first register the application and assign the appropriate permissions.

Step 2: Configuring Portainer

Now that you’ve created an App configuration for Portainer, it’s time to set up Portainer to authenticate with your Tenant.

Client ID: Your Azure Directory (tenant) ID

Authorization URL: https://login.microsoftonline.com/<tenant ID>/oauth2/v2.0/authorize

Access token URL: https://login.microsoftonline.com/<tenant ID>/oauth2/v2.0/token

Resource URL: https://graph.microsoft.com/v1.0/me

Redirect URL: <Portainer URL (which must match the URL provided during App registration)>

Logout URL: https://login.microsoftonline.com/<tenant ID>/oauth2/v2.0/logout

User identifier: mail

Scopes: openid+email+profile

Alternatively, you can choose to provide all users in your tenant access to Portainer by enabling the Automatic user provisioning option under Settings -> Authentication.

Step 3: Logging in with Azure Entra

Now that both Azure Entra ID and Portainer are configured, you should see a button on the Portainer login page to log in with your Microsoft account. You’ll be redirected to the Microsoft login page, and after a successful authentication, you’ll be returned to the Portainer web application.