Merge pull request #553 from Azure/user/rakku/graphapi-adfs-fix

GraphAPI: Add ADFS to Environment validation set
This commit is contained in:
Rakesh Kumar 2020-03-06 12:20:58 -08:00 коммит произвёл GitHub
Родитель 84d4a228e1 722a676fc8
Коммит 3585edb3e1
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 8 добавлений и 8 удалений

Просмотреть файл

@ -46,7 +46,7 @@ function Initialize-GraphEnvironment
[Parameter(ParameterSetName='Credential_AAD')]
[Parameter(ParameterSetName='RefreshToken_AAD')]
[Parameter(ParameterSetName='ServicePrincipal_AAD')]
[ValidateSet('AzureCloud', 'AzureChinaCloud', 'AzureUSGovernment', 'AzureGermanCloud', 'CustomCloud')]
[ValidateSet('AzureCloud', 'AzureChinaCloud', 'AzureUSGovernment', 'AzureGermanCloud', 'CustomCloud', 'ADFS')]
[string] $Environment = 'AzureCloud',
# The fully-qualified domain name of the ADFS service (e.g. "adfs.azurestack.local").
@ -67,6 +67,11 @@ function Initialize-GraphEnvironment
[string] $CustomCloudARMEndpoint
)
if ($Environment -eq 'ADFS')
{
throw 'To initialize this module for use with an ADFS system, specify the "AdfsFqdn" and "GraphFqdn" parameters, and omit the "Environment" parameter.'
}
if ($AdfsFqdn)
{
$Environment = 'ADFS'
@ -230,7 +235,7 @@ function Initialize-GraphEnvironment
IssuerTemplate = "https://$AdfsFqdn/adfs/{0}/"
LoginEndpoint = [Uri]"https://$AdfsFqdn/adfs/$DirectoryTenantId"
LoginEndpoint = [Uri]"https://$AdfsFqdn/adfs"
GraphEndpoint = [Uri]"https://$GraphFqdn/$DirectoryTenantId"
LoginBaseEndpoint = [Uri]"https://$AdfsFqdn/adfs/"
@ -316,11 +321,6 @@ function Initialize-GraphEnvironment
}
}
if ($AdfsFqdn)
{
$graphEnvironmentTemplate.Applications = [pscustomobject]@{}
}
$Script:GraphEnvironment = [pscustomobject]$graphEnvironmentTemplate
Write-Verbose "Graph Environment initialized: client-request-id: $($Script:GraphEnvironment.User.ClientRequestId)" -Verbose
@ -572,7 +572,7 @@ function Update-GraphAccessToken
$response = Get-GraphToken -UseEnvironmentData
$Script:GraphEnvironment.User.AccessToken = $response.access_token
$Script:GraphEnvironment.User.RefreshToken = if ($response.refresh_token) { ConvertTo-SecureString $response.refresh_token -AsPlainText -Force } else { $null }
$Script:GraphEnvironment.User.RefreshToken = if ($response.refresh_token) { ConvertTo-SecureString $response.refresh_token -AsPlainText -Force } else { $Script:GraphEnvironment.User.RefreshToken }
$Script:GraphEnvironment.User.AccessTokenUpdateTime = [DateTime]::UtcNow
$Script:GraphEnvironment.User.AccessTokenExpiresIn = $response.expires_in
}