Getting rid of credentials in Azure - Part 2 (EasyAuth)

Published Mar 30 2022 09:00 AM 1,921 Views
Senior Member

This is part two in a series on how to get rid of credentials wherever you can in Azure. The first part set the stage with configuring "federated credentials" for doing deployments based on Bicep code stored in GitHub using GitHub Actions. The samples in this post assumes you have this in place, so you might want to take a look at that if you haven't:

https://techcommunity.microsoft.com/t5/azure-developer-community-blog/getting-rid-of-credentials-in-...

 

Starting with this post we will deploy actual resources in Azure so let's start with something easy in the world of credentialless in Azure - like EasyAuth :)

 

Bad puns aside; EasyAuth is a mechanism that allows you to add identity to Azure App Services in a fairly simple manner. And in line with the topic of the series it is without messing around with credentials of course. (They are present behind the scenes - more on that later.)

 

"How to enable a user to sign in to my webpage" is a question with more possible answers than you would initially think. Is it just the classic typing in of username and password and being able to greet the user with a personalized hello afterwards, or more complex use cases where upon signing in APIs are called on the backend either on behalf of the user or with the app acting with an identity of its own? We are not able to dive into all the finer details of the larger authentication and authorization puzzle here, but we are able to look into some of the basics.

 

Azure App Service is one of several ways to run web apps in Azure. It comes in two "versions" - container-based deployments and directly on an underlying web/app server. It's well-suited for some use cases, and less for others, but those considerations are outside the scope of this post which makes the assumption that an App Service is what you want/need. (We will cover other runtime platforms later.) The instructions here make use of containers, but should work in "plain mode" as well since EasyAuth relies on the hosting platform and not the runtime. While the custom containers are based on C# the features demonstrated are not language dependent.

 

Visual Studio has templates and wizards included that will help you with wiring in the necessary code and libraries, and can even help you generate a so-called app registration in Azure and use the corresponding attributes directly in your code. If you choose the template for a simple web app and Azure AD as the identity provider the file appsettings.json will contain your unique values and look something like this:

 

 

 

{
  /*
  The following identity settings need to be configured
  before the project can be successfully executed.
  For more info see https://aka.ms/dotnet-template-ms-identity-platform 
  */
  "AzureAd": {
    "Authority": "https://login.microsoftonline.com/2222-2222-2222-2222",
    "ClientId": "1111-1111-1111-1111",
    "ValidateAuthority": true
  }
}

 

 

 

The rest of the code is not relevant right now so just humor me here even if this is not testable. These settings are not a full set of credentials and not secret as such. If I have misconfigured my app registration in Azure AD it could be I'm letting in more users than I'd like too, but without a clientSecret in addition to the clientId you can't directly connect to my data. However, when we host our web app in Azure App Services we can get rid of these values as well. Which is good for two reasons:

  • We don't need to concern ourselves with credentials :)
  • We get code that is so generic that you could fork it from my GitHub and deploy it straight into your App Service without touching the code.

 

Microsoft provides documentation for how to configure EasyAuth in the portal:
https://docs.microsoft.com/en-us/azure/app-service/scenario-secure-app-authentication-app-service

 

Historically EasyAuth was sort of useless for everything but the most basic scenarios as the token you acquired could not be used for anything else than the signin process. With more recent improvements you can actually use the token to call into things like the Graph API as well with an extra configuration step:
https://docs.microsoft.com/en-us/azure/app-service/scenario-secure-app-access-microsoft-graph-as-use...

 

Deploying a stock container image

We will however start with the more basic things. We will use a sample container from Microsoft, spin up a web site, and enable authentication without ever touching appsettings.json.

 

You can of course do this in the Azure Portal, but in keeping with IaC principles we have Bicep for this as well. Unfortunately Bicep (like ARM) isn't all that great when it comes to registering apps in Azure AD, so you need to run a few lines of Azure CLI first:

 

 

 

$appName = 'foo'
# WebApps require a replyUrl - this is a known suffix for EasyAuth
$replyUrl = "https://$appname.azurewebsites.net/.auth/login/aad/callback"
# Create an app registration
$appId = (az ad app create --display-name $appName --reply-urls $replyUrl --query appId)
# Create a service principal for the app registration
az ad sp create --id $appId
# Add permission for User.Read on MS Graph (static guids)
az ad app permission add --id $appId --api 00000003-0000-0000-c000-000000000000 --api-permissions 311a71cc-e848-46a1-bdf8-97ff7156d8e6=Scope
# Grant the permission added above
az ad app permission grant --id $appId --api 00000003-0000-0000-c000-000000000000

# Deploy the Bicep template
az deployment sub create -l $location  --name ExampleDeployment --template-file main.bicep --parameters azuredeploy.Dev.parameters.json env=Dev authClientId=$appId appName=$appName 

 

 

 

Link: https://github.com/ahelland/Bicep-Landing-Zones/blob/main/credless-in-azure-samples/part-2/easyauth-...

 

For the IaC nitpickers out there - yes, you can technically put this in a deploymentScript element in Bicep. Right now I recommend you run the cli script locally (both app registration and deploying the template) so it isn't required to make things more complicated than necessary.

 

The settings for EasyAuth are embedded as a child resource of the app service:

 

 

 

resource appservice 'Microsoft.Web/sites@2021-03-01' = {
  name: name
  location: location
  tags: resourceTags
  properties: {
    siteConfig: {
      appSettings: [
        {
          name: 'DOCKER_REGISTRY_SERVER_URL'
          value: dockerRegistryUrl
        }
        {
          name: 'DOCKER_REGISTRY_SERVER_USERNAME'
          value: dockerRegistryUsername
        }
        {
          name: 'DOCKER_REGISTRY_SERVER_PASSWORD'
          value: dockerRegistryPassword
        }
        {
          name: 'WEBSITES_ENABLE_APP_SERVICE_STORAGE'
          value: 'false'
        }
      ]
      linuxFxVersion: linuxFxVersion
      appCommandLine: dockerRegistryStartupCommand
      alwaysOn: alwaysOn
      http20Enabled: true
    }    
    serverFarmId: '/subscriptions/${subscriptionId}/resourcegroups/${serverFarmResourceGroup}/providers/Microsoft.Web/serverfarms/${appServicePlanName}'
    clientAffinityEnabled: false
    httpsOnly: true    
  }
  dependsOn: []
  
  resource easyauth_config 'config' = {
    name: 'authsettingsV2'    
    properties: {
      httpSettings: {
        requireHttps: true
      }
      globalValidation: {
        requireAuthentication: true
        redirectToProvider: 'azureActiveDirectory'
        unauthenticatedClientAction: 'RedirectToLoginPage'
      }
      platform: {
        enabled: easyauthEnabled
      }
      login: {
        tokenStore: {
          enabled: true
        }
      }
      identityProviders: {
        azureActiveDirectory: {
          enabled: aadProviderEnabled
          registration: {
            clientId: authClientId
          }          
        }
      }
    }
  }
}

 

 

 

Link: https://github.com/ahelland/Bicep-Landing-Zones/blob/main/credless-in-azure-samples/part-2/easyauth-...

 

In this case we used azureActiveDirectory (called "Microsoft" in the portal), but you could use Facebook, Google, etc. if you so like in a similar fashion:

https://docs.microsoft.com/en-us/azure/templates/microsoft.web/sites/config-authsettingsv2?tabs=bice...

 

The quickest way to deploy this is to use az cli locally (in the

Bicep-Landing-Zones/credless-in-azure-samples/part-2/easyauth-stock-image

 folder) where authClientId => the appId you generated in the previous step & appName => the unique part left of .azurewebsites.net:

 

 

 

az deployment sub create -l norwayeast --name ExampleDeployment --template-file main.bicep --parameters azuredeploy.Dev.parameters.json env=Dev authClientId=appid appName=foobar

 

 

 

 

This will deploy a standard container provided by Microsoft with a "Hello World"-type web app and consist of code not touched by me in any way while still requiring the user to sign in.

EasyAuth-01.png

 

This is nice.

 

Deploying a claims reader app

Ok, so clearly the Azure platform is able to do some magic outside of your application code. But since the code here clearly has no concept of identity - what if we want that "Hello Andreas!" greeting? That would require code to handle claims in some way, right? Yes, it would.

 

Let's demo this in two ways. The first is swapping out this with a container image called blazor-easyauth-default-dotnet6 that I have prepared.

 

I ran through the wizard for creating a Blazor serverside app, and on the index page I included code to retrieve and print out the claims of the user identity to demonstrate we have access to those bits as well:

 

 

 

@page "/"
@using System.Security.Claims
@using Microsoft.AspNetCore.Components.Authorization
@inject AuthenticationStateProvider AuthenticationStateProvider

<PageTitle>Index</PageTitle>

<h2>Claims</h2>

<button @onclick="GetClaims">Get claims of currently logged in user.</button>

@if (claims.Count() > 0)
{
    <table class="table">
        <thead>
            <tr>
                <th scope="col">Claim Type</th>
                <th scope="col">Claim Value</th>
            </tr>
        </thead>
        <tbody>
            @foreach (var claim in claims)
            {
                <tr>
                    <td>@claim.Type</td>
                    <td>@claim.Value</td>
                </tr>
            }
        </tbody>
    </table>
}

@code {
    //For handling the claims in the session
    private string authStatusMsg = string.Empty;
    private IEnumerable<Claim> claims = Enumerable.Empty<Claim>();         
    
    private async Task GetClaims()
    {
        var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
        var user = authState.User;

        if (user.Identity.IsAuthenticated)
        {
            authStatusMsg = $"{user.Identity.Name} has been authenticated.";
            claims = user.Claims;
        }
        else
        {
            authStatusMsg = $"User has not been authenticated.";
        }
    }
}

 

 

 

Link: https://github.com/ahelland/Identity-CodeSamples-v2/blob/master/blazor-easyauth-default-dotnet6/Page...

 

This can be deployed with the Bicep code here (which will be explained in a moment):
https://github.com/ahelland/Bicep-Landing-Zones/blob/main/.github/workflows/DeployCredlessEADefault....

EasyAuth-02.png

 

Deploying an app interacting with Microsoft Graph

The second sample takes a cue from another article in the official docs on how to use the Microsoft Graph with EasyAuth:

https://docs.microsoft.com/en-us/azure/app-service/scenario-secure-app-access-microsoft-graph-as-use...

 

This requires a few additions in the code. In appsettings.json we still leave the AzureAd elements with the default values, but we add the settings required for MS Graph:

 

 

 

"Graph": {
    "BaseUrl": "https://graph.microsoft.com/v1.0",
    "Scopes": "user.read"
  },
´´´

In Program.cs we also add a little bit to the setup:
´´´
// Add services to the container.
builder.Services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
    .AddMicrosoftIdentityWebApp(builder.Configuration.GetSection("AzureAd"))
    .EnableTokenAcquisitionToCallDownstreamApi()
    .AddMicrosoftGraph(builder.Configuration.GetSection("Graph"))
    .AddInMemoryTokenCaches();

 

 

 

And in Index.razor we need to add some code and markup to do the actual call to the Graph and display the properties accordingly:

 

 

 

@page "/"
@using Microsoft.Graph
@using Microsoft.AspNetCore.Authorization
@inject GraphServiceClient GraphClient

<PageTitle>Index</PageTitle>

<h2>User properties from MS Graph</h2>

@if (graphUser != null)
{
    <p>Hello @graphUser.DisplayName, it looks like your phone number is @graphUser.MobilePhone</p>
}

<p>
    You should be seeing your name and mobile phone number above if the call to MS Graph worked. (Mobile phone only works if it is defined on the user object.)
</p>

@code {
    protected User graphUser;     

    protected override async Task OnInitializedAsync()
    {
        graphUser = await GraphClient.Me.Request().GetAsync();            
    }    
}

 

 

 

You can get all the code from here:

https://github.com/ahelland/Identity-CodeSamples-v2/tree/master/blazor-easyauth-graph-dotnet6

 

And the deployment Action is here:

https://github.com/ahelland/Bicep-Landing-Zones/blob/main/.github/workflows/DeployCredlessEAGraph.ym...

 

Loading up this code in your browser will yield something like this:

EasyAuth-03.png

(I have not defined a phone number for the user object in this test environment hence the blank value, but the name is correctly retrieved so it's still working as intended from a code perspective.)

 

The trick (for both versions) is essentially that EasyAuth not only exposes a preconfigured callback endpoint, but also a fixed endpoint for tokens at /.auth/me that the app can call into.

 

I skipped explaining both the GitHub Action and the Bicep code so let's do that now. The difference between these two images is basically just the name of the image so they are the same thing. I extrapolated this to a generic Bicep module that can be re-used as seem fit.

 

Compared to deploying the stock image we need to expand the EasyAuth configuration in Bicep:

 

 

 

identityProviders: {
        azureActiveDirectory: {
          enabled: aadProviderEnabled
          registration: {
            clientId: authClientId
            openIdIssuer: 'https://${aadEndpoint}/${tenantId}/v2.0/'
            clientSecretSettingName: 'MICROSOFT_PROVIDER_AUTHENTICATION_SECRET'
          }
          login: {
            loginParameters: [
            'response_type=code id_token'
            'scope=openid offline_access profile https://graph.microsoft.com/User.Read'
            ]
          }   
        }
      }

 

 

 

The loginParameters section is what we referred to earlier as "getting a usable token". This in turn requires that we provide the openIdIssuer parameter to validate the issuer of said token, and we actually also need a clientSecret to make this work. (As I said - some things are still present behind the scenes.)

 

As for the GitHub Action that makes this tick. That was a mouthful to get working correctly.   We need to do this in a multi-step process:

  • Create an Azure AD app registration with placeholder settings.
  • Generate a client secret for the registered app.
  • Deploy the Azure App Service. (Will not work after initial deployment.)
  • Retrieve the name of the App Service with a generated suffix element for pseudo-randomness.
  • Update the App Registration with the correct replyUrl based on previous step.

 

It could have been made easier without the suffix element for the app name, but that was included to make it easier to deploy with unique names (which are required). In real-life you would put a custom domain name in front anyways.

 

Lesson learned here is that putting this in one long script is not how GitHub likes its Actions so in total it ends up as a fair number of lines of yaml when you also include the validation steps from before.

 

If you poke around in the portal and the deployment logs in GitHub you might notice two things.

 

As indicated by the Bicep above you have a configuration setting called MICROSOFT_PROVIDER_AUTHENTICATION_SECRET, and this can be viewed in the Azure Portal:

EasyAuth-04.png

 

And if you take a look in the logs you can see this in clear text as well:

EasyAuth-05.png

 

 

Doesn't this violate my proposed intent of getting rid of credentials? The default consultant style answer would of course be "it depends" :) Your code is clean and contains no credentials so we have improved upon things in general. However, no we don't want these things to be as easily viewable. (Even if they are not readable for the entire internet.)

 

As I've already said, we're not able to get rid of all secrets, and this is the way Azure App Services work. The recommended approach is that you put the secret in Azure Key Vault, and just include a reference in the App Service configuration. To make this work we need to look into Managed Identity for the web app. We haven't gotten around to that yet, but that will be on the agenda for the next post of the series :smile:

%3CLINGO-SUB%20id%3D%22lingo-sub-3270553%22%20slang%3D%22en-US%22%3EGetting%20rid%20of%20credentials%20in%20Azure%20-%20Part%202%20(EasyAuth)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3270553%22%20slang%3D%22en-US%22%3E%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%3CFONT%20size%3D%223%22%3EThis%20is%20part%20two%20in%20a%20series%20on%20how%20to%20get%20rid%20of%20credentials%20wherever%20you%20can%20in%20Azure.%20The%20first%20part%20set%20the%20stage%20with%20configuring%20%22federated%20credentials%22%20for%20doing%20deployments%20based%20on%20Bicep%20code%20stored%20in%20GitHub%20using%20GitHub%20Actions.%20The%20samples%20in%20this%20post%20assumes%20you%20have%20this%20in%20place%2C%20so%20you%20might%20want%20to%20take%20a%20look%20at%20that%20if%20you%20haven't%3A%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%3CA%20title%3D%22Getting%20rid%20of%20credentials%20in%20Azure%20-%20Part%201%22%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fazure-developer-community-blog%2Fgetting-rid-of-credentials-in-azure-part-1%2Fba-p%2F3265205%22%20target%3D%22_blank%22%3Ehttps%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fazure-developer-community-blog%2Fgetting-rid-of-credentials-in-azure-part-1%2Fba-p%2F3265205%3C%2FA%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%3CFONT%20size%3D%222%22%3E%3CSPAN%3EStarting%20with%20this%20post%20we%20will%20deploy%20actual%20resources%20in%20Azure%20so%20l%3C%2FSPAN%3E%3C%2FFONT%3E%3CSPAN%3E%3CFONT%20size%3D%222%22%3Eet's%20start%20with%20something%20easy%20in%20the%20world%20of%20credentialless%20in%20Azure%20-%20like%20EasyAuth%3C%2FFONT%3E%26nbsp%3B%3A)%3C%2Fimg%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%20lang%3D%22en-US%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%3CFONT%20size%3D%222%22%3E%3CSPAN%3EBad%20puns%20aside%3B%20EasyAuth%20is%20a%20mechanism%20that%20allows%20you%20to%20add%20identity%20to%20Azure%20App%20Services%20in%20a%20fairly%20simple%20manner.%20And%20in%20line%20with%20the%20topic%20of%20the%20series%20it%20is%20without%20messing%20around%20with%20credentials%20of%20course.%3C%2FSPAN%3E%3CSPAN%3E%20(They%20are%20present%20behind%20the%20scenes%20-%20more%20on%20that%20later.)%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%3CFONT%20size%3D%222%22%3E%3CSPAN%3E%22How%20to%20enable%20a%20user%20to%20sign%20in%20to%20my%20webpage%22%20is%20a%20question%20with%20more%20possible%20answers%20than%20you%20would%20initially%20think.%20Is%20it%20just%20the%20classic%20typing%20in%20%3C%2FSPAN%3E%3CSPAN%3Eof%20%3C%2FSPAN%3E%3CSPAN%3Eusername%20and%20password%20and%20being%20able%20to%20greet%20the%20user%20with%20a%20personalized%20hello%20afterwards%2C%20or%20more%20complex%20use%20cases%20where%20upon%20signing%20in%20APIs%20are%20called%20on%20the%20backend%20either%20on%20behalf%20of%20the%20user%20or%20with%20the%20app%20acting%20with%20an%20identity%20of%20its%20own%3F%20We%20are%20not%20able%20to%20dive%20into%20all%20the%20finer%20details%20of%20the%20larger%20authentication%20and%20authorization%20puzzle%20here%2C%20but%20we%20are%20able%20to%20look%20into%20some%20of%20the%20basics.%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3EAzure%20App%20Service%20is%20one%20of%20several%20ways%20to%20run%20web%20apps%20in%20Azure.%20It%20comes%20in%20two%20%22versions%22%20-%20container-based%20deployments%20and%20directly%20on%20an%20underlying%20web%2Fapp%20server.%20It's%20well-suited%20for%20some%20use%20cases%2C%20and%20less%20for%20others%2C%20but%20those%20considerations%20are%20outside%20the%20scope%20of%20this%20post%20which%20makes%20the%20assumption%20that%20an%20App%20Service%20is%20what%20you%20want%2Fneed.%20(We%20will%20cover%20other%20runtime%20platforms%20later.)%20The%20instructions%20here%20make%20use%20of%20containers%2C%20but%20should%20work%20in%20%22plain%20mode%22%20as%20well%20since%20EasyAuth%20relies%20on%20the%20hosting%20platform%20and%20not%20the%20runtime.%20While%20the%20custom%20containers%20are%20based%20on%20C%23%20the%20features%20demonstrated%20are%20not%20language%20dependent.%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%20lang%3D%22en-US%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%20lang%3D%22en-US%22%3EVisual%20Studio%20has%20templates%20and%20wizards%20included%20that%20will%20help%20you%20with%20wiring%20in%20the%20necessary%20code%20and%20libraries%2C%20and%20can%20even%20help%20you%20generate%20a%20so-called%20app%20registration%20in%20Azure%20and%20use%20the%20corresponding%20attributes%20directly%20in%20your%20code.%20If%20you%20choose%20the%20template%20for%20a%20simple%20web%20app%20and%20Azure%20AD%20as%20the%20identity%20provider%20the%20file%20%3CSPAN%3Eappsettings.json%3C%2FSPAN%3E%20will%20contain%20your%20unique%20values%20and%20look%20something%20like%20this%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-json%22%3E%3CCODE%3E%7B%0A%20%20%2F*%0A%20%20The%20following%20identity%20settings%20need%20to%20be%20configured%0A%20%20before%20the%20project%20can%20be%20successfully%20executed.%0A%20%20For%20more%20info%20see%20https%3A%2F%2Faka.ms%2Fdotnet-template-ms-identity-platform%20%0A%20%20*%2F%0A%20%20%22AzureAd%22%3A%20%7B%0A%20%20%20%20%22Authority%22%3A%20%22https%3A%2F%2Flogin.microsoftonline.com%2F2222-2222-2222-2222%22%2C%0A%20%20%20%20%22ClientId%22%3A%20%221111-1111-1111-1111%22%2C%0A%20%20%20%20%22ValidateAuthority%22%3A%20true%0A%20%20%7D%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%20lang%3D%22en-US%22%3EThe%20rest%20of%20the%20code%20is%20not%20relevant%20right%20now%20so%20just%20humor%20me%20here%20even%20if%20this%20is%20not%20testable.%20These%20settings%20are%20not%20a%20full%20set%20of%20credentials%20and%20not%20secret%20as%20such.%20If%20I%20have%20misconfigured%20my%20app%20registration%20in%20Azure%20AD%20it%20could%20be%20I'm%20letting%20in%20more%20users%20than%20I'd%20like%20too%2C%20but%20without%20a%20clientSecret%20in%20addition%20to%20the%20clientId%20you%20can't%20directly%20connect%20to%20my%20data.%20However%2C%20when%20we%20host%20our%20web%20app%20in%20Azure%20App%20Services%20we%20can%20get%20rid%20of%20these%20values%20as%20well.%20Which%20is%20good%20for%20two%20reasons%3A%3C%2FP%3E%0A%3CUL%20style%3D%22direction%3A%20ltr%3B%20unicode-bidi%3A%20embed%3B%20margin-top%3A%200in%3B%20margin-bottom%3A%200in%3B%22%20type%3D%22disc%22%3E%0A%3CLI%20lang%3D%22en-US%22%20style%3D%22margin-top%3A%200%3B%20margin-bottom%3A%200%3B%20vertical-align%3A%20middle%3B%22%3E%3CFONT%20size%3D%222%22%3E%3CSPAN%3EWe%20don't%20need%20to%20concern%20ourselves%20with%20credentials%20%3A)%3C%2Fimg%3E%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FLI%3E%0A%3CLI%20lang%3D%22en-US%22%20style%3D%22margin-top%3A%200%3B%20margin-bottom%3A%200%3B%20vertical-align%3A%20middle%3B%22%3E%3CFONT%20size%3D%222%22%3E%3CSPAN%3EWe%20get%20code%20that%20is%20so%20generic%20that%20you%20could%20fork%20it%20from%20my%20GitHub%20and%20deploy%20it%20straight%20into%20your%20App%20Service%20without%20touching%20the%20code.%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%20lang%3D%22en-US%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%20lang%3D%22en-US%22%3EMicrosoft%20provides%20documentation%20for%20how%20to%20configure%20EasyAuth%20in%20the%20portal%3A%3CBR%20%2F%3E%3CA%20title%3D%22Tutorial%3A%20Add%20authentication%20to%20your%20web%20app%20running%20on%20Azure%20App%20Service%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fapp-service%2Fscenario-secure-app-authentication-app-service%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fapp-service%2Fscenario-secure-app-authentication-app-service%3C%2FA%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%20lang%3D%22en-US%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%20lang%3D%22en-US%22%3EHistorically%20EasyAuth%20was%20sort%20of%20useless%20for%20everything%20but%20the%20most%20basic%20scenarios%20as%20the%20token%20you%20acquired%20could%20not%20be%20used%20for%20anything%20else%20than%20the%20signin%20process.%20With%20more%20recent%20improvements%20you%20can%20actually%20use%20the%20token%20to%20call%20into%20things%20like%20the%20Graph%20API%20as%20well%20with%20an%20extra%20configuration%20step%3A%3CBR%20%2F%3E%3CA%20title%3D%22Configure%20App%20Service%20to%20return%20a%20usable%20access%20token%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fapp-service%2Fscenario-secure-app-access-microsoft-graph-as-user%23configure-app-service-to-return-a-usable-access-token%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fapp-service%2Fscenario-secure-app-access-microsoft-graph-as-user%23configure-app-service-to-return-a-usable-access-token%3C%2FA%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%20lang%3D%22en-US%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%3CSTRONG%3EDeploying%20a%20stock%20container%20image%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%20lang%3D%22en-US%22%3EWe%20will%20however%20start%20with%20the%20more%20basic%20things.%20We%20will%20use%20a%20sample%20container%20from%20Microsoft%2C%20spin%20up%20a%20web%20site%2C%20and%20enable%20authentication%20without%20ever%20touching%20%3CFONT%20size%3D%222%22%3E%3CSPAN%3Eappsettings.json%3C%2FSPAN%3E.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%20lang%3D%22en-US%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%20lang%3D%22en-US%22%3EYou%20can%20of%20course%20do%20this%20in%20the%20Azure%20Portal%2C%20but%20in%20keeping%20with%20IaC%20principles%20we%20have%20Bicep%20for%20this%20as%20well.%20Unfortunately%20Bicep%20(like%20ARM)%20isn't%20all%20that%20great%20when%20it%20comes%20to%20registering%20apps%20in%20Azure%20AD%2C%20so%20you%20need%20to%20run%20a%20few%20lines%20of%20Azure%20CLI%20first%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3E%24appName%20%3D%20'foo'%0A%23%20WebApps%20require%20a%20replyUrl%20-%20this%20is%20a%20known%20suffix%20for%20EasyAuth%0A%24replyUrl%20%3D%20%22https%3A%2F%2F%24appname.azurewebsites.net%2F.auth%2Flogin%2Faad%2Fcallback%22%0A%23%20Create%20an%20app%20registration%0A%24appId%20%3D%20(az%20ad%20app%20create%20--display-name%20%24appName%20--reply-urls%20%24replyUrl%20--query%20appId)%0A%23%20Create%20a%20service%20principal%20for%20the%20app%20registration%0Aaz%20ad%20sp%20create%20--id%20%24appId%0A%23%20Add%20permission%20for%20User.Read%20on%20MS%20Graph%20(static%20guids)%0Aaz%20ad%20app%20permission%20add%20--id%20%24appId%20--api%2000000003-0000-0000-c000-000000000000%20--api-permissions%20311a71cc-e848-46a1-bdf8-97ff7156d8e6%3DScope%0A%23%20Grant%20the%20permission%20added%20above%0Aaz%20ad%20app%20permission%20grant%20--id%20%24appId%20--api%2000000003-0000-0000-c000-000000000000%0A%0A%23%20Deploy%20the%20Bicep%20template%0Aaz%20deployment%20sub%20create%20-l%20%24location%20%20--name%20ExampleDeployment%20--template-file%20main.bicep%20--parameters%20azuredeploy.Dev.parameters.json%20env%3DDev%20authClientId%3D%24appId%20appName%3D%24appName%20%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%3CFONT%20size%3D%222%22%3E%3CSPAN%3ELink%3A%20%3C%2FSPAN%3E%3CA%20title%3D%22https%3A%2F%2Fgithub.com%2Fahelland%2FBicep-Landing-Zones%2Fblob%2Fmain%2Fcredless-in-azure-samples%2Fpart-2%2Feasyauth-stock-image%2Faad-app-reg.azcli%22%20href%3D%22https%3A%2F%2Fgithub.com%2Fahelland%2FBicep-Landing-Zones%2Fblob%2Fmain%2Fcredless-in-azure-samples%2Fpart-2%2Feasyauth-stock-image%2Faad-app-reg.azcli%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%3CSPAN%3Ehttps%3A%2F%2Fgithub.com%2Fahelland%2FBicep-Landing-Zones%2Fblob%2Fmain%2Fcredless-in-azure-samples%2Fpart-2%2Feasyauth-stock-image%2Faad-app-reg.azcli%3C%2FSPAN%3E%3C%2FA%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3EFor%20the%20IaC%20nitpickers%20out%20there%20-%20yes%2C%20you%20can%20technically%20put%20this%20in%20a%20deploymentScript%20element%20in%20Bicep.%20Right%20now%20I%20recommend%20you%20run%20the%20cli%20script%20locally%20(both%20app%20registration%20and%20deploying%20the%20template)%20so%20it%20isn't%20required%20to%20make%20things%20more%20complicated%20than%20necessary.%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3EThe%20settings%20for%20EasyAuth%20are%20embedded%20as%20a%20child%20resource%20of%20the%20app%20service%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-json%22%3E%3CCODE%3Eresource%20appservice%20'Microsoft.Web%2Fsites%402021-03-01'%20%3D%20%7B%0A%20%20name%3A%20name%0A%20%20location%3A%20location%0A%20%20tags%3A%20resourceTags%0A%20%20properties%3A%20%7B%0A%20%20%20%20siteConfig%3A%20%7B%0A%20%20%20%20%20%20appSettings%3A%20%5B%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20name%3A%20'DOCKER_REGISTRY_SERVER_URL'%0A%20%20%20%20%20%20%20%20%20%20value%3A%20dockerRegistryUrl%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20name%3A%20'DOCKER_REGISTRY_SERVER_USERNAME'%0A%20%20%20%20%20%20%20%20%20%20value%3A%20dockerRegistryUsername%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20name%3A%20'DOCKER_REGISTRY_SERVER_PASSWORD'%0A%20%20%20%20%20%20%20%20%20%20value%3A%20dockerRegistryPassword%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20name%3A%20'WEBSITES_ENABLE_APP_SERVICE_STORAGE'%0A%20%20%20%20%20%20%20%20%20%20value%3A%20'false'%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20linuxFxVersion%3A%20linuxFxVersion%0A%20%20%20%20%20%20appCommandLine%3A%20dockerRegistryStartupCommand%0A%20%20%20%20%20%20alwaysOn%3A%20alwaysOn%0A%20%20%20%20%20%20http20Enabled%3A%20true%0A%20%20%20%20%7D%20%20%20%20%0A%20%20%20%20serverFarmId%3A%20'%2Fsubscriptions%2F%24%7BsubscriptionId%7D%2Fresourcegroups%2F%24%7BserverFarmResourceGroup%7D%2Fproviders%2FMicrosoft.Web%2Fserverfarms%2F%24%7BappServicePlanName%7D'%0A%20%20%20%20clientAffinityEnabled%3A%20false%0A%20%20%20%20httpsOnly%3A%20true%20%20%20%20%0A%20%20%7D%0A%20%20dependsOn%3A%20%5B%5D%0A%20%20%0A%20%20resource%20easyauth_config%20'config'%20%3D%20%7B%0A%20%20%20%20name%3A%20'authsettingsV2'%20%20%20%20%0A%20%20%20%20properties%3A%20%7B%0A%20%20%20%20%20%20httpSettings%3A%20%7B%0A%20%20%20%20%20%20%20%20requireHttps%3A%20true%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20globalValidation%3A%20%7B%0A%20%20%20%20%20%20%20%20requireAuthentication%3A%20true%0A%20%20%20%20%20%20%20%20redirectToProvider%3A%20'azureActiveDirectory'%0A%20%20%20%20%20%20%20%20unauthenticatedClientAction%3A%20'RedirectToLoginPage'%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20platform%3A%20%7B%0A%20%20%20%20%20%20%20%20enabled%3A%20easyauthEnabled%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20login%3A%20%7B%0A%20%20%20%20%20%20%20%20tokenStore%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20enabled%3A%20true%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20identityProviders%3A%20%7B%0A%20%20%20%20%20%20%20%20azureActiveDirectory%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20enabled%3A%20aadProviderEnabled%0A%20%20%20%20%20%20%20%20%20%20registration%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20clientId%3A%20authClientId%0A%20%20%20%20%20%20%20%20%20%20%7D%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%3CFONT%20size%3D%222%22%3E%3CSPAN%3ELink%3A%20%3C%2FSPAN%3E%3CA%20title%3D%22https%3A%2F%2Fgithub.com%2Fahelland%2FBicep-Landing-Zones%2Fblob%2Fmain%2Fcredless-in-azure-samples%2Fpart-2%2Feasyauth-stock-image%2Fapp-service.bicep%22%20href%3D%22https%3A%2F%2Fgithub.com%2Fahelland%2FBicep-Landing-Zones%2Fblob%2Fmain%2Fcredless-in-azure-samples%2Fpart-2%2Feasyauth-stock-image%2Fapp-service.bicep%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%3CSPAN%3Ehttps%3A%2F%2Fgithub.com%2Fahelland%2FBicep-Landing-Zones%2Fblob%2Fmain%2Fcredless-in-azure-samples%2Fpart-2%2Feasyauth-stock-image%2Fapp-service.bicep%3C%2FSPAN%3E%3C%2FA%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3EIn%20this%20case%20we%20used%20azureActiveDirectory%20(called%20%22Microsoft%22%20in%20the%20portal)%2C%20but%20you%20could%20use%20Facebook%2C%20Google%2C%20etc.%20if%20you%20so%20like%20in%20a%20similar%20fashion%3A%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%20lang%3D%22nb%22%3E%3CA%20title%3D%22Microsoft.Web%20sites%2Fconfig%20'authsettingsV2'%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Ftemplates%2Fmicrosoft.web%2Fsites%2Fconfig-authsettingsv2%3Ftabs%3Dbicep%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Ftemplates%2Fmicrosoft.web%2Fsites%2Fconfig-authsettingsv2%3Ftabs%3Dbicep%3C%2FA%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3EThe%20quickest%20way%20to%20deploy%20this%20is%20to%20use%20az%20cli%20locally%20(in%20the%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%20lang%3D%22nb%22%3E%3CEM%3EBicep-Landing-Zones%2Fcredless-in-azure-samples%2Fpart-2%2Feasyauth-stock-image%3C%2FEM%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%26nbsp%3Bfolder)%20where%20%3CEM%3EauthClientId%20%3C%2FEM%3E%3D%26gt%3B%20the%20appId%20you%20generated%20in%20the%20previous%20step%20%26amp%3B%20%3CEM%3EappName%20%3C%2FEM%3E%3D%26gt%3B%20the%20unique%20part%20left%20of%20.azurewebsites.net%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3Eaz%20deployment%20sub%20create%20-l%20norwayeast%20--name%20ExampleDeployment%20--template-file%20main.bicep%20--parameters%20azuredeploy.Dev.parameters.json%20env%3DDev%20authClientId%3Dappid%20appName%3Dfoobar%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3EThis%20will%20deploy%20a%20standard%20container%20provided%20by%20Microsoft%20with%20a%20%22Hello%20World%22-type%20web%20app%20and%20consist%20of%20code%20not%20touched%20by%20me%20in%20any%20way%20while%20still%20requiring%20the%20user%20to%20sign%20in.%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22EasyAuth-01.png%22%20style%3D%22width%3A%20754px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F359635i1B691C3F1496B0F1%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22EasyAuth-01.png%22%20alt%3D%22EasyAuth-01.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3EThis%20is%20nice.%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%3CSTRONG%3EDeploying%20a%20claims%20reader%20app%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3EOk%2C%20so%20clearly%20the%20Azure%20platform%20is%20able%20to%20do%20some%20magic%20outside%20of%20your%20application%20code.%20But%20since%20the%20code%20here%20clearly%20has%20no%20concept%20of%20identity%20-%20what%20if%20we%20want%20that%20%22Hello%20Andreas!%22%20greeting%3F%20That%20would%20require%20code%20to%20handle%20claims%20in%20some%20way%2C%20right%3F%20Yes%2C%20it%20would.%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3ELet's%20demo%20this%20in%20two%20ways.%20The%20first%20is%20swapping%20out%20this%20with%20a%20container%20image%20called%20%3CEM%3E%3CFONT%20size%3D%222%22%3Eblazor-easyauth-default-dotnet6%20%3C%2FFONT%3E%3C%2FEM%3Ethat%20I%20have%20prepared.%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3EI%20ran%20through%20the%20wizard%20for%20creating%20a%20Blazor%20serverside%20app%2C%20and%20on%20the%20index%20page%20I%20included%20code%20to%20retrieve%20and%20print%20out%20the%20claims%20of%20the%20user%20identity%20to%20demonstrate%20we%20have%20access%20to%20those%20bits%20as%20well%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3E%40page%20%22%2F%22%0A%40using%20System.Security.Claims%0A%40using%20Microsoft.AspNetCore.Components.Authorization%0A%40inject%20AuthenticationStateProvider%20AuthenticationStateProvider%0A%0A%3CPAGETITLE%3EIndex%3C%2FPAGETITLE%3E%0A%0A%3CH2%20id%3D%22toc-hId-415889769%22%3EClaims%3C%2FH2%3E%0A%0A%3CBUTTON%3EGet%20claims%20of%20currently%20logged%20in%20user.%3C%2FBUTTON%3E%0A%0A%40if%20(claims.Count()%20%26gt%3B%200)%0A%7B%0A%20%20%20%20%3C%2FCODE%3E%3CTABLE%20class%3D%22table%22%3E%0A%20%20%20%20%20%20%20%20%3CTHEAD%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%3CTR%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3CTH%20scope%3D%22col%22%3EClaim%20Type%3C%2FTH%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3CTH%20scope%3D%22col%22%3EClaim%20Value%3C%2FTH%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%3C%2FTR%3E%0A%20%20%20%20%20%20%20%20%3C%2FTHEAD%3E%0A%20%20%20%20%20%20%20%20%3CTBODY%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%40foreach%20(var%20claim%20in%20claims)%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3CTR%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3CTD%3E%40claim.Type%3C%2FTD%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3CTD%3E%40claim.Value%3C%2FTD%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3C%2FTR%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%3C%2FTBODY%3E%0A%20%20%20%20%3C%2FTABLE%3E%0A%7D%0A%0A%40code%20%7B%0A%20%20%20%20%2F%2FFor%20handling%20the%20claims%20in%20the%20session%0A%20%20%20%20private%20string%20authStatusMsg%20%3D%20string.Empty%3B%0A%20%20%20%20private%20IEnumerable%3CCLAIM%3E%20claims%20%3D%20Enumerable.Empty%3CCLAIM%3E()%3B%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%0A%20%20%20%20private%20async%20Task%20GetClaims()%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20var%20authState%20%3D%20await%20AuthenticationStateProvider.GetAuthenticationStateAsync()%3B%0A%20%20%20%20%20%20%20%20var%20user%20%3D%20authState.User%3B%0A%0A%20%20%20%20%20%20%20%20if%20(user.Identity.IsAuthenticated)%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20authStatusMsg%20%3D%20%24%22%7Buser.Identity.Name%7D%20has%20been%20authenticated.%22%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20claims%20%3D%20user.Claims%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20else%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20authStatusMsg%20%3D%20%24%22User%20has%20not%20been%20authenticated.%22%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%7D%0A%3C%2FCLAIM%3E%3C%2FCLAIM%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%3CFONT%20size%3D%222%22%3E%3CSPAN%3ELink%3A%20%3C%2FSPAN%3E%3CSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fahelland%2FIdentity-CodeSamples-v2%2Fblob%2Fmaster%2Fblazor-easyauth-default-dotnet6%2FPages%2FIndex.razor%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2Fahelland%2FIdentity-CodeSamples-v2%2Fblob%2Fmaster%2Fblazor-easyauth-default-dotnet6%2FPages%2FIndex.razor%3C%2FA%3E%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%3CFONT%20size%3D%222%22%3E%3CSPAN%3EThis%20can%20be%20deployed%20with%20the%20Bicep%20code%20here%20(which%20will%20be%20explained%20in%20a%20moment)%3A%20%3C%2FSPAN%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20size%3D%222%22%3E%3CSPAN%3E%3CA%20title%3D%22https%3A%2F%2Fgithub.com%2Fahelland%2FBicep-Landing-Zones%2Fblob%2Fmain%2F.github%2Fworkflows%2FDeployCredlessEADefault.yml%22%20href%3D%22https%3A%2F%2Fgithub.com%2Fahelland%2FBicep-Landing-Zones%2Fblob%2Fmain%2F.github%2Fworkflows%2FDeployCredlessEADefault.yml%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2Fahelland%2FBicep-Landing-Zones%2Fblob%2Fmain%2F.github%2Fworkflows%2FDeployCredlessEADefault.yml%3C%2FA%3E%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%3CSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22EasyAuth-02.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F359636i0B05EE795E1C1FCD%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22EasyAuth-02.png%22%20alt%3D%22EasyAuth-02.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%3CSTRONG%3EDeploying%20an%20app%20interacting%20with%20Microsoft%20Graph%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3EThe%20second%20sample%20takes%20a%20cue%20from%20another%20article%20in%20the%20official%20docs%20on%20how%20to%20use%20the%20Microsoft%20Graph%20with%20EasyAuth%3A%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%20lang%3D%22nb%22%3E%3CA%20title%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fapp-service%2Fscenario-secure-app-access-microsoft-graph-as-user%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fapp-service%2Fscenario-secure-app-access-microsoft-graph-as-user%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fapp-service%2Fscenario-secure-app-access-microsoft-graph-as-user%3C%2FA%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3EThis%20requires%20a%20few%20additions%20in%20the%20code.%20In%20appsettings.json%20we%20still%20leave%20the%20AzureAd%20elements%20with%20the%20default%20values%2C%20but%20we%20add%20the%20settings%20required%20for%20MS%20Graph%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3E%22Graph%22%3A%20%7B%0A%20%20%20%20%22BaseUrl%22%3A%20%22https%3A%2F%2Fgraph.microsoft.com%2Fv1.0%22%2C%0A%20%20%20%20%22Scopes%22%3A%20%22user.read%22%0A%20%20%7D%2C%0A%C2%B4%C2%B4%C2%B4%0A%0AIn%20Program.cs%20we%20also%20add%20a%20little%20bit%20to%20the%20setup%3A%0A%C2%B4%C2%B4%C2%B4%0A%2F%2F%20Add%20services%20to%20the%20container.%0Abuilder.Services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)%0A%20%20%20%20.AddMicrosoftIdentityWebApp(builder.Configuration.GetSection(%22AzureAd%22))%0A%20%20%20%20.EnableTokenAcquisitionToCallDownstreamApi()%0A%20%20%20%20.AddMicrosoftGraph(builder.Configuration.GetSection(%22Graph%22))%0A%20%20%20%20.AddInMemoryTokenCaches()%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3EAnd%20in%20Index.razor%20we%20need%20to%20add%20some%20code%20and%20markup%20to%20do%20the%20actual%20call%20to%20the%20Graph%20and%20display%20the%20properties%20accordingly%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3E%40page%20%22%2F%22%0A%40using%20Microsoft.Graph%0A%40using%20Microsoft.AspNetCore.Authorization%0A%40inject%20GraphServiceClient%20GraphClient%0A%0A%3CPAGETITLE%3EIndex%3C%2FPAGETITLE%3E%0A%0A%3CH2%20id%3D%22toc-hId--1391564694%22%3EUser%20properties%20from%20MS%20Graph%3C%2FH2%3E%0A%0A%40if%20(graphUser%20!%3D%20null)%0A%7B%0A%20%20%20%20%3CP%3EHello%20%40graphUser.DisplayName%2C%20it%20looks%20like%20your%20phone%20number%20is%20%40graphUser.MobilePhone%3C%2FP%3E%0A%7D%0A%0A%3CP%3E%0A%20%20%20%20You%20should%20be%20seeing%20your%20name%20and%20mobile%20phone%20number%20above%20if%20the%20call%20to%20MS%20Graph%20worked.%20(Mobile%20phone%20only%20works%20if%20it%20is%20defined%20on%20the%20user%20object.)%0A%3C%2FP%3E%0A%0A%40code%20%7B%0A%20%20%20%20protected%20User%20graphUser%3B%20%20%20%20%20%0A%0A%20%20%20%20protected%20override%20async%20Task%20OnInitializedAsync()%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20graphUser%20%3D%20await%20GraphClient.Me.Request().GetAsync()%3B%20%20%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%7D%20%20%20%20%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3EYou%20can%20get%20all%20the%20code%20from%20here%3A%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%20lang%3D%22nb%22%3E%3CA%20title%3D%22https%3A%2F%2Fgithub.com%2Fahelland%2FIdentity-CodeSamples-v2%2Ftree%2Fmaster%2Fblazor-easyauth-graph-dotnet6%22%20href%3D%22https%3A%2F%2Fgithub.com%2Fahelland%2FIdentity-CodeSamples-v2%2Ftree%2Fmaster%2Fblazor-easyauth-graph-dotnet6%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2Fahelland%2FIdentity-CodeSamples-v2%2Ftree%2Fmaster%2Fblazor-easyauth-graph-dotnet6%3C%2FA%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3EAnd%20the%20deployment%20Action%20is%20here%3A%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%20lang%3D%22nb%22%3E%3CA%20title%3D%22https%3A%2F%2Fgithub.com%2Fahelland%2FBicep-Landing-Zones%2Fblob%2Fmain%2F.github%2Fworkflows%2FDeployCredlessEAGraph.yml%22%20href%3D%22https%3A%2F%2Fgithub.com%2Fahelland%2FBicep-Landing-Zones%2Fblob%2Fmain%2F.github%2Fworkflows%2FDeployCredlessEAGraph.yml%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2Fahelland%2FBicep-Landing-Zones%2Fblob%2Fmain%2F.github%2Fworkflows%2FDeployCredlessEAGraph.yml%3C%2FA%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3ELoading%20up%20this%20code%20in%20your%20browser%20will%20yield%20something%20like%20this%3A%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22EasyAuth-03.png%22%20style%3D%22width%3A%20757px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F359637i08D034D779256605%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22EasyAuth-03.png%22%20alt%3D%22EasyAuth-03.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E(I%20have%20not%20defined%20a%20phone%20number%20for%20the%20user%20object%20in%20this%20test%20environment%20hence%20the%20blank%20value%2C%20but%20the%20name%20is%20correctly%20retrieved%20so%20it's%20still%20working%20as%20intended%20from%20a%20code%20perspective.)%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3EThe%20trick%20(for%20both%20versions)%20is%20essentially%20that%20EasyAuth%20not%20only%20exposes%20a%20preconfigured%20callback%20endpoint%2C%20but%20also%20a%20fixed%20endpoint%20for%20tokens%20at%20%3CSPAN%3E%2F.auth%2Fme%3C%2FSPAN%3E%20that%20the%20app%20can%20call%20into.%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3EI%20skipped%20explaining%20both%20the%20GitHub%20Action%20and%20the%20Bicep%20code%20so%20let's%20do%20that%20now.%20The%20difference%20between%20these%20two%20images%20is%20basically%20just%20the%20name%20of%20the%20image%20so%20they%20are%20the%20same%20thing.%20I%20extrapolated%20this%20to%20a%20generic%20Bicep%20module%20that%20can%20be%20re-used%20as%20seem%20fit.%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3ECompared%20to%20deploying%20the%20stock%20image%20we%20need%20to%20expand%20the%20EasyAuth%20configuration%20in%20Bicep%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3EidentityProviders%3A%20%7B%0A%20%20%20%20%20%20%20%20azureActiveDirectory%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20enabled%3A%20aadProviderEnabled%0A%20%20%20%20%20%20%20%20%20%20registration%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20clientId%3A%20authClientId%0A%20%20%20%20%20%20%20%20%20%20%20%20openIdIssuer%3A%20'https%3A%2F%2F%24%7BaadEndpoint%7D%2F%24%7BtenantId%7D%2Fv2.0%2F'%0A%20%20%20%20%20%20%20%20%20%20%20%20clientSecretSettingName%3A%20'MICROSOFT_PROVIDER_AUTHENTICATION_SECRET'%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20login%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20loginParameters%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20'response_type%3Dcode%20id_token'%0A%20%20%20%20%20%20%20%20%20%20%20%20'scope%3Dopenid%20offline_access%20profile%20https%3A%2F%2Fgraph.microsoft.com%2FUser.Read'%0A%20%20%20%20%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%20%20%20%20%7D%20%20%20%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%3EThe%20%3CI%3EloginParameters%3C%2FI%3E%20section%20is%20what%20we%20referred%20to%20earlier%20as%20%22getting%20a%20usable%20token%22.%20This%20in%20turn%20requires%20that%20we%20provide%20the%20%3CI%3EopenIdIssuer%3C%2FI%3E%20parameter%20to%20validate%20the%20issuer%20of%20said%20token%2C%20and%20we%20actually%20also%20need%20a%20%3CI%3EclientSecret%3C%2FI%3E%20to%20make%20this%20work.%20(As%20I%20said%20-%20some%20things%20are%20still%20present%20behind%20the%20scenes.)%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%3EAs%20for%20the%20GitHub%20Action%20that%20makes%20this%20tick.%20That%20was%20a%20mouthful%20to%20get%20working%20correctly.%26nbsp%3B%26nbsp%3B%20We%20need%20to%20do%20this%20in%20a%20multi-step%20process%3A%3C%2FFONT%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CFONT%20size%3D%222%22%3ECreate%20an%20Azure%20AD%20app%20registration%20with%20placeholder%20settings.%3C%2FFONT%3E%3C%2FLI%3E%0A%3CLI%3E%3CFONT%20size%3D%222%22%3EGenerate%20a%20client%20secret%20for%20the%20registered%20app.%3C%2FFONT%3E%3C%2FLI%3E%0A%3CLI%3E%3CFONT%20size%3D%222%22%3EDeploy%20the%20Azure%20App%20Service.%20(Will%20not%20work%20after%20initial%20deployment.)%3C%2FFONT%3E%3C%2FLI%3E%0A%3CLI%3E%3CFONT%20size%3D%222%22%3ERetrieve%20the%20name%20of%20the%20App%20Service%20with%20a%20generated%20suffix%20element%20for%20pseudo-randomness.%3C%2FFONT%3E%3C%2FLI%3E%0A%3CLI%3E%3CFONT%20size%3D%222%22%3EUpdate%20the%20App%20Registration%20with%20the%20correct%20replyUrl%20based%20on%20previous%20step.%3C%2FFONT%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%3EIt%20could%20have%20been%20made%20easier%20without%20the%20suffix%20element%20for%20the%20app%20name%2C%20but%20that%20was%20included%20to%20make%20it%20easier%20to%20deploy%20with%20unique%20names%20(which%20are%20required).%20In%20real-life%20you%20would%20put%20a%20custom%20domain%20name%20in%20front%20anyways.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%3ELesson%20learned%20here%20is%20that%20putting%20this%20in%20one%20long%20script%20is%20not%20how%20GitHub%20likes%20its%20Actions%20so%20in%20total%20it%20ends%20up%20as%20a%20fair%20number%20of%20lines%20of%20yaml%20when%20you%20also%20include%20the%20validation%20steps%20from%20before.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%3EIf%20you%20poke%20around%20in%20the%20portal%20and%20the%20deployment%20logs%20in%20GitHub%20you%20might%20notice%20two%20things.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%3E%3CSPAN%3EAs%20indicated%20by%20the%20Bicep%20above%20you%20have%20a%20configuration%20setting%20called%20%3C%2FSPAN%3E%3CSPAN%3EMICROSOFT_PROVIDER_AUTHENTICATION_SECRET%2C%20and%20this%20can%20be%20viewed%20in%20the%20Azure%20Portal%3A%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22EasyAuth-04.png%22%20style%3D%22width%3A%20918px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F359638iC6B9CAFF73595CC3%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22EasyAuth-04.png%22%20alt%3D%22EasyAuth-04.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3EAnd%20if%20you%20take%20a%20look%20in%20the%20logs%20you%20can%20see%20this%20in%20clear%20text%20as%20well%3A%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22EasyAuth-05.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F359639i2E41F292C0CF742A%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22EasyAuth-05.png%22%20alt%3D%22EasyAuth-05.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3EDoesn't%20this%20violate%20my%20proposed%20intent%20of%20getting%20rid%20of%20credentials%3F%20The%20default%20consultant%20style%20answer%20would%20of%20course%20be%20%22it%20depends%22%20%3A)%3C%2Fimg%3E%20Your%20code%20is%20clean%20and%20contains%20no%20credentials%20so%20we%20have%20improved%20upon%20things%20in%20general.%20However%2C%20no%20we%20don't%20want%20these%20things%20to%20be%20as%20easily%20viewable.%20(Even%20if%20they%20are%20not%20readable%20for%20the%20entire%20internet.)%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3EAs%20I've%20already%20said%2C%20we're%20not%20able%20to%20get%20rid%20of%20all%20secrets%2C%20and%20this%20is%20the%20way%20Azure%20App%20Services%20work.%20The%20recommended%20approach%20is%20that%20you%20put%20the%20secret%20in%20Azure%20Key%20Vault%2C%20and%20just%20include%20a%20reference%20in%20the%20App%20Service%20configuration.%20To%20make%20this%20work%20we%20need%20to%20look%20into%20Managed%20Identity%20for%20the%20web%20app.%20We%20haven't%20gotten%20around%20to%20that%20yet%2C%20but%20that%20will%20be%20on%20the%20agenda%20for%20the%20next%20post%20of%20the%20series%26nbsp%3B%3CIMG%20class%3D%22lia-deferred-image%20lia-image-emoji%22%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Fhtml%2F%408341BD79091AF36AA2A09063B554B5CD%2Fimages%2Femoticons%2Fsmile_40x40.gif%22%20alt%3D%22%3Asmile%3A%22%20title%3D%22%3Asmile%3A%22%20%2F%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-3270553%22%20slang%3D%22en-US%22%3E%3CP%3EAzure%20is%20gaining%20momentum%20when%20it%20comes%20to%20removing%20credentials%20in%20all%20the%20wrong%20places%20while%20still%20allowing%20for%20authentication%2C%20authorization%20and%20identities%20in%20general.%20This%20is%20the%20second%20part%20of%20a%20series%20which%20will%20dive%20into%20various%20aspects%20and%20details%20on%20how%20to%20make%20this%20work.%20In%20this%20post%20we%20dive%20into%20deploying%20web%20apps%20without%20credentials%20while%20still%20allowing%20full%20usage%20of%20identity%20through%20the%20EasyAuth%20feature%20in%20Azure%20App%20Services.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-3270553%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EApp%20Service%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EBest%20Practices%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Co-Authors
Version history
Last update:
‎Mar 30 2022 09:06 AM
Updated by: