-
Notifications
You must be signed in to change notification settings - Fork 4.5k
/
DeviceCodeCredentialOptions.cs
63 lines (53 loc) · 3.35 KB
/
DeviceCodeCredentialOptions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace Azure.Identity
{
/// <summary>
/// Options to configure the <see cref="DeviceCodeCredential"/>.
/// </summary>
public class DeviceCodeCredentialOptions : TokenCredentialOptions, ISupportsTokenCachePersistenceOptions, ISupportsDisableInstanceDiscovery, ISupportsAdditionallyAllowedTenants
{
private string _tenantId;
/// <summary>
/// Prevents the <see cref="DeviceCodeCredential"/> from automatically prompting the user. If automatic authentication is disabled a AuthenticationRequiredException will be thrown from <see cref="DeviceCodeCredential.GetToken"/> and <see cref="DeviceCodeCredential.GetTokenAsync"/> in the case that
/// user interaction is necessary. The application is responsible for handling this exception, and calling <see cref="DeviceCodeCredential.Authenticate(CancellationToken)"/> or <see cref="DeviceCodeCredential.AuthenticateAsync(CancellationToken)"/> to authenticate the user interactively.
/// </summary>
public bool DisableAutomaticAuthentication { get; set; }
/// <summary>
/// The tenant ID the user will be authenticated to. If not specified the user will be authenticated to their home tenant.
/// </summary>
public string TenantId
{
get { return _tenantId; }
set { _tenantId = Validations.ValidateTenantId(value, allowNull: true); }
}
/// <summary>
/// Specifies tenants in addition to the specified <see cref="TenantId"/> for which the credential may acquire tokens.
/// Add the wildcard value "*" to allow the credential to acquire tokens for any tenant the logged in account can access.
/// If no value is specified for <see cref="TenantId"/>, this option will have no effect, and the credential will acquire tokens for any requested tenant.
/// </summary>
public IList<string> AdditionallyAllowedTenants { get; internal set; } = new List<string>();
/// <summary>
/// The client ID of the application used to authenticate the user. If not specified the user will be authenticated with an Azure development application.
/// </summary>
public string ClientId { get; set; } = Constants.DeveloperSignOnClientId;
/// <summary>
/// Specifies the <see cref="TokenCachePersistenceOptions"/> to be used by the credential. If not options are specified, the token cache will not be persisted to disk.
/// </summary>
public TokenCachePersistenceOptions TokenCachePersistenceOptions { get; set; }
/// <summary>
/// The <see cref="Identity.AuthenticationRecord"/> captured from a previous authentication.
/// </summary>
public AuthenticationRecord AuthenticationRecord { get; set; }
/// <summary>
/// The callback which will be executed to display the device code login details to the user. In not specified the device code and login instructions will be printed to the console.
/// </summary>
public Func<DeviceCodeInfo, CancellationToken, Task> DeviceCodeCallback { get; set; }
/// <inheritdoc/>
public bool DisableInstanceDiscovery { get; set; }
}
}