Share via


Configuratie op basis van bestanden in Azure App Service verificatie

Met App Service verificatie kunnen de verificatie-instellingen worden geconfigureerd met een bestand. Mogelijk moet u een configuratie op basis van bestanden gebruiken om bepaalde preview-mogelijkheden van App Service verificatie/autorisatie te gebruiken voordat ze beschikbaar worden gemaakt via Azure Resource Manager-API's.

Belangrijk

Houd er rekening mee dat de nettolading van uw app, en dus dit bestand, kan worden verplaatst tussen omgevingen, net als bij sleuven. Het is waarschijnlijk dat u een andere app-registratie wilt vastmaken aan elke site. In deze gevallen moet u de standaardconfiguratiemethode blijven gebruiken in plaats van het configuratiebestand te gebruiken.

Configuratie op basis van bestanden inschakelen

  1. Maak een nieuw JSON-bestand voor uw configuratie in de hoofdmap van uw project (geïmplementeerd in D:\home\site\wwwroot in uw web-/functie-app). Vul de gewenste configuratie in op basis van de op bestanden gebaseerde configuratiereferenties. Als u een bestaande Azure Resource Manager-configuratie wijzigt, moet u ervoor zorgen dat u de eigenschappen die zijn vastgelegd in de authsettings verzameling, vertaalt naar uw configuratiebestand.

  2. Wijzig de bestaande configuratie, die wordt vastgelegd in de Azure Resource Manager-API's onder Microsoft.Web/sites/<siteName>/config/authsettingsV2. Als u deze wilt wijzigen, kunt u een Azure Resource Manager-sjabloon of een hulpprogramma zoals Azure Resource Explorer gebruiken. Stel in de verzameling authsettingsV2 twee eigenschappen in (u kunt andere eigenschappen verwijderen):

    1. Instellen platform.enabled op 'true'
    2. Stel in platform.configFilePath op de naam van het bestand (bijvoorbeeld 'auth.json')

Notitie

De indeling voor platform.configFilePath verschilt per platform. In Windows worden zowel relatieve als absolute paden ondersteund. Relatief wordt aanbevolen. Voor Linux worden momenteel alleen absolute paden ondersteund, dus de waarde van de instelling moet '/home/site/wwwroot/auth.json' of vergelijkbaar zijn.

Zodra u deze configuratie-update hebt uitgevoerd, wordt de inhoud van het bestand gebruikt om het gedrag van App Service verificatie/autorisatie voor die site te definiëren. Als u ooit wilt terugkeren naar azure Resource Manager-configuratie, kunt u dit doen door de instelling platform.configFilePath te verwijderen in null.

Naslaginformatie over configuratiebestanden

Alle geheimen waarnaar vanuit uw configuratiebestand wordt verwezen, moeten worden opgeslagen als toepassingsinstellingen. U kunt de instellingen een naam geven die u maar wilt. Zorg ervoor dat de verwijzingen uit het configuratiebestand dezelfde sleutels gebruiken.

De volgende mogelijke configuratieopties in het bestand worden uitgeput:

{
    "platform": {
        "enabled": <true|false>
    },
    "globalValidation": {
        "unauthenticatedClientAction": "RedirectToLoginPage|AllowAnonymous|RejectWith401|RejectWith404",
        "redirectToProvider": "<default provider alias>",
        "excludedPaths": [
            "/path1",
            "/path2",
            "/path3/subpath/*"
        ]
    },
    "httpSettings": {
        "requireHttps": <true|false>,
        "routes": {
            "apiPrefix": "<api prefix>"
        },
        "forwardProxy": {
            "convention": "NoProxy|Standard|Custom",
            "customHostHeaderName": "<host header value>",
            "customProtoHeaderName": "<proto header value>"
        }
    },
    "login": {
        "routes": {
            "logoutEndpoint": "<logout endpoint>"
        },
        "tokenStore": {
            "enabled": <true|false>,
            "tokenRefreshExtensionHours": "<double>",
            "fileSystem": {
                "directory": "<directory to store the tokens in if using a file system token store (default)>"
            },
            "azureBlobStorage": {
                "sasUrlSettingName": "<app setting name containing the sas url for the Azure Blob Storage if opting to use that for a token store>"
            }
        },
        "preserveUrlFragmentsForLogins": <true|false>,
        "allowedExternalRedirectUrls": [
            "https://uri1.azurewebsites.net/",
            "https://uri2.azurewebsites.net/",
            "url_scheme_of_your_app://easyauth.callback"
        ],
        "cookieExpiration": {
            "convention": "FixedTime|IdentityDerived",
            "timeToExpiration": "<timespan>"
        },
        "nonce": {
            "validateNonce": <true|false>,
            "nonceExpirationInterval": "<timespan>"
        }
    },
    "identityProviders": {
        "azureActiveDirectory": {
            "enabled": <true|false>,
            "registration": {
                "openIdIssuer": "<issuer url>",
                "clientId": "<app id>",
                "clientSecretSettingName": "APP_SETTING_CONTAINING_AAD_SECRET",
            },
            "login": {
                "loginParameters": [
                    "paramName1=value1",
                    "paramName2=value2"
                ]
            },
            "validation": {
                "allowedAudiences": [
                    "audience1",
                    "audience2"
                ]
            }
        },
        "facebook": {
            "enabled": <true|false>,
            "registration": {
                "appId": "<app id>",
                "appSecretSettingName": "APP_SETTING_CONTAINING_FACEBOOK_SECRET"
            },
            "graphApiVersion": "v3.3",
            "login": {
                "scopes": [
                    "public_profile",
                    "email"
                ]
            },
        },
        "gitHub": {
            "enabled": <true|false>,
            "registration": {
                "clientId": "<client id>",
                "clientSecretSettingName": "APP_SETTING_CONTAINING_GITHUB_SECRET"
            },
            "login": {
                "scopes": [
                    "profile",
                    "email"
                ]
            }
        },
        "google": {
            "enabled": true,
            "registration": {
                "clientId": "<client id>",
                "clientSecretSettingName": "APP_SETTING_CONTAINING_GOOGLE_SECRET"
            },
            "login": {
                "scopes": [
                    "profile",
                    "email"
                ]
            },
            "validation": {
                "allowedAudiences": [
                    "audience1",
                    "audience2"
                ]
            }
        },
        "twitter": {
            "enabled": <true|false>,
            "registration": {
                "consumerKey": "<consumer key>",
                "consumerSecretSettingName": "APP_SETTING_CONTAINING TWITTER_CONSUMER_SECRET"
            }
        },
        "apple": {
            "enabled": <true|false>,
            "registration": {
                "clientId": "<client id>",
                "clientSecretSettingName": "APP_SETTING_CONTAINING_APPLE_SECRET"
            },
            "login": {
                "scopes": [
                    "profile",
                    "email"
                ]
            }
        },
        "openIdConnectProviders": {
            "<providerName>": {
                "enabled": <true|false>,
                "registration": {
                    "clientId": "<client id>",
                    "clientCredential": {
                        "clientSecretSettingName": "<name of app setting containing client secret>"
                    },
                    "openIdConnectConfiguration": {
                        "authorizationEndpoint": "<url specifying authorization endpoint>",
                        "tokenEndpoint": "<url specifying token endpoint>",
                        "issuer": "<url specifying issuer>",
                        "certificationUri": "<url specifying jwks endpoint>",
                        "wellKnownOpenIdConfiguration": "<url specifying .well-known/open-id-configuration endpoint - if this property is set, the other properties of this object are ignored, and authorizationEndpoint, tokenEndpoint, issuer, and certificationUri are set to the corresponding values listed at this endpoint>"
                    }
                },
                "login": {
                    "nameClaimType": "<name of claim containing name>",
                    "scopes": [
                        "openid",
                        "profile",
                        "email"
                    ],
                    "loginParameterNames": [
                        "paramName1=value1",
                        "paramName2=value2"
                    ],
                }
            },
            //...
        }
    }
}

Meer bronnen