| | | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | | 2 | | // Licensed under the MIT License. |
| | | 3 | | |
| | | 4 | | using System; |
| | | 5 | | |
| | | 6 | | namespace Azure.Identity |
| | | 7 | | { |
| | | 8 | | /// <summary> |
| | | 9 | | /// Defines fields exposing the well known authority hosts for the Azure Public Cloud and sovereign clouds. |
| | | 10 | | /// </summary> |
| | | 11 | | public static class AzureAuthorityHosts |
| | | 12 | | { |
| | | 13 | | private const string AzurePublicCloudHostUrl = "https://login.microsoftonline.com/"; |
| | | 14 | | private const string AzureChinaHostUrl = "https://login.chinacloudapi.cn/"; |
| | | 15 | | private const string AzureGermanyHostUrl = "https://login.microsoftonline.de/"; |
| | | 16 | | private const string AzureGovernmentHostUrl = "https://login.microsoftonline.us/"; |
| | | 17 | | /// <summary> |
| | | 18 | | /// The host of the Azure Active Directory authority for tenants in the Azure Public Cloud. |
| | | 19 | | /// </summary> |
| | 232 | 20 | | public static Uri AzurePublicCloud { get; } = new Uri(AzurePublicCloudHostUrl); |
| | | 21 | | |
| | | 22 | | /// <summary> |
| | | 23 | | /// The host of the Azure Active Directory authority for tenants in the Azure China Cloud. |
| | | 24 | | /// </summary> |
| | 10 | 25 | | public static Uri AzureChina { get; } = new Uri(AzureChinaHostUrl); |
| | | 26 | | |
| | | 27 | | /// <summary> |
| | | 28 | | /// The host of the Azure Active Directory authority for tenants in the Azure German Cloud. |
| | | 29 | | /// </summary> |
| | 6 | 30 | | public static Uri AzureGermany { get; } = new Uri(AzureGermanyHostUrl); |
| | | 31 | | |
| | | 32 | | /// <summary> |
| | | 33 | | /// The host of the Azure Active Directory authority for tenants in the Azure US Government Cloud. |
| | | 34 | | /// </summary> |
| | 0 | 35 | | public static Uri AzureGovernment { get; } = new Uri(AzureGovernmentHostUrl); |
| | | 36 | | |
| | | 37 | | internal static Uri GetDefault() |
| | | 38 | | { |
| | 206 | 39 | | return EnvironmentVariables.AuthorityHost != null ? new Uri(EnvironmentVariables.AuthorityHost) : AzurePubli |
| | | 40 | | } |
| | | 41 | | |
| | | 42 | | internal static string GetDefaultScope(Uri authorityHost) |
| | | 43 | | { |
| | 28 | 44 | | switch (authorityHost.ToString()) |
| | | 45 | | { |
| | | 46 | | case AzurePublicCloudHostUrl: |
| | 28 | 47 | | return "https://management.core.windows.net//.default"; |
| | | 48 | | case AzureChinaHostUrl: |
| | 0 | 49 | | return "https://management.core.chinacloudapi.cn//.default"; |
| | | 50 | | case AzureGermanyHostUrl: |
| | 0 | 51 | | return "https://management.core.cloudapi.de//.default"; |
| | | 52 | | case AzureGovernmentHostUrl: |
| | 0 | 53 | | return "https://management.core.usgovcloudapi.net//.default"; |
| | | 54 | | default: |
| | 0 | 55 | | return null; |
| | | 56 | | } |
| | | 57 | | } |
| | | 58 | | |
| | | 59 | | internal static Uri GetDeviceCodeRedirectUri(Uri authorityHost) |
| | | 60 | | { |
| | 24 | 61 | | return new Uri(authorityHost, "/common/oauth2/nativeclient"); |
| | | 62 | | } |
| | | 63 | | } |
| | | 64 | | } |