Skip to content

Latest commit

 

History

History
88 lines (76 loc) · 3.05 KB

File metadata and controls

88 lines (76 loc) · 3.05 KB

Azure AD SSO Implementation Guide

Table of Contents

  1. Introduction
  2. Azure AD Registration
  3. App Service Authentication Configuration
  4. Code Examples
  5. Service Principal Configuration
  6. Azure CLI Commands

Introduction

This guide provides a comprehensive overview of implementing Single Sign-On (SSO) using Azure Active Directory (Azure AD).

Azure AD Registration

To begin, you need to register your application in Azure AD:

  • Navigate to the Azure Portal.
  • Go to Azure Active Directory > App registrations > New registration.
    • Provide a name for your application.
    • Choose the supported account types.
    • Specify the redirect URI (e.g., https://yourapp.azurewebsites.net/signin-oidc).
    • Click Register.

App Service Authentication Configuration

To configure the App Service for Azure AD authentication:

  • In the Azure Portal, navigate to your App Service.
  • Under the Settings section, click on Authentication / Authorization.
  • Click on Add identity provider and select Microsoft.
  • Configure the settings as per your Azure AD application details:
    • Client ID
    • Client Secret
    • Authorization API
    • And select appropriate permissions.

Code Examples

index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>SSO Implementation</title>
</head>
<body>
    <h1>Welcome to SSO Implementation</h1>
    <button onclick="login()">Login</button>
    <button onclick="logout()">Logout</button>
</body>

<script>
function login() {
    window.location.href = '/signin-oidc';
}

function logout() {
    window.location.href = '/signout-oidc';
}
</script>
</html>

Login Functionality

The login functionality will redirect users to the Azure AD login page, where they can enter their credentials and authenticate.

Logout Functionality

The logout functionality will redirect users to sign-out from Azure AD and your application.

Service Principal Configuration

  • When you register an application in Azure AD, a Service Principal is automatically created. This represents the application in Azure AD. Ensure that your application has the necessary API permissions assigned.

Azure CLI Commands

Here are some useful Azure CLI commands for managing your Azure AD and Application:

  • To create an Azure AD application:
az ad app create --display-name "YourAppName" --identifier-uris "https://yourapp.azurewebsites.net" --reply-urls "https://yourapp.azurewebsites.net/signin-oidc"
  • To create a Service Principal:
az ad sp create --id <ApplicationId>
  • To assign permissions:
az ad app permission add --id <ApplicationId> --api <ApiId> --api-permissions <permissions>