コード例 #1
0
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            var config = new AzureADConfig()
            {
                ClientId               = this.AppId,
                ClientSecret           = this.AppSecret,
                RedirectUri            = ResourceUri ?? AzureADConstants.GraphResourceId,
                AuthenticationEndpoint = Environment,
                TenantDomain           = this.AADDomain,
                TenantId               = AADTenantId ?? ""
            };

            var ilogger = new DefaultUsageLogger(LogVerbose, LogWarning, LogError);


            var authenticationEndpoint = Environment.GetAzureADLoginEndPoint();
            var endpoint = string.Format(AzureADConstants.AuthorityTenantFormat, authenticationEndpoint, this.AADDomain);

            AzureADALv1Connection.CurrentConnection = new AzureADALv1Connection(endpoint, config, ilogger);


            // Write Tokens to Console
            WriteObject(AzureADALv1Connection.CurrentConnection.AuthenticationResult);
        }
コード例 #2
0
 public SecureController(IAuthorizationService authorizationService,
                         IOptions <AzureADConfig> azureAdConfig,
                         ILogger <SecureController> logger)
 {
     _authorizationService = authorizationService;
     _azureADConfig        = azureAdConfig.Value;
     _logger = logger;
 }
コード例 #3
0
        public DbTokenCache(TodoListWebAppContext db, IHttpContextAccessor httpContextAccessor, IOptions <AzureADConfig> aadConfig)
        {
            this.BeforeAccess = BeforeAccessNotification;
            this.AfterAccess  = AfterAccessNotification;
            this.BeforeWrite  = BeforeWriteNotification;


            _aadConfig = aadConfig.Value;
            _userId    = httpContextAccessor.HttpContext.User.FindFirst(AzureADConstants.ObjectIdClaimType).Value;
            string tenantId = httpContextAccessor.HttpContext.User.FindFirst(AzureADConstants.TenantIdClaimType).Value;

            _authContext    = new AuthenticationContext(String.Format(_aadConfig.AuthorityFormat, tenantId), this);
            _appCredentials = new ClientCredential(_aadConfig.ClientId, _aadConfig.ClientSecret);
        }
コード例 #4
0
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();


            var config = new AzureADConfig()
            {
                ClientId     = this.AppId,
                ClientSecret = this.AppSecret,
                RedirectUri  = AzureADConstants.GraphResourceId,
                TenantDomain = this.AADDomain,
                TenantId     = ""
            };

            var ilogger = new DefaultUsageLogger(LogVerbose, LogWarning, LogError);


            AzureADALv1Connection.CurrentConnection = new AzureADALv1Connection(config, ilogger);


            // Write Tokens to Console
            WriteObject(AzureADALv1Connection.CurrentConnection.AuthenticationResult);
        }
 public UserProfileController(IOptions <AzureADConfig> config, IAzureAdTokenService tokenCache)
 {
     _aadConfig  = config.Value;
     _tokenCache = tokenCache;
 }
 /// <summary>
 /// Initialize the Azure AD Connection with config and diagnostics
 /// </summary>
 /// <param name="authenticationEndpoint">The authentication endpoint used to send the user to an Azure AD login screen</param>
 /// <param name="azureADCredentials"></param>
 /// <param name="traceLogger"></param>
 public AzureADALv1Connection(string authenticationEndpoint, AzureADConfig azureADCredentials, ITraceLogger traceLogger)
 {
     _iLogger           = traceLogger;
     AzureADCache       = new AzureADTokenCache(authenticationEndpoint, azureADCredentials, traceLogger);
     AzureADCredentials = azureADCredentials;
 }
コード例 #7
0
 public AuthorizeController(IOptions <AzureADConfig> azureAD)
 {
     this.azureAD = azureAD.Value;
 }
コード例 #8
0
 /// <summary>
 /// Initialize the Azure AD Connection with config and diagnostics
 /// </summary>
 /// <param name="azureADCredentials"></param>
 /// <param name="traceLogger"></param>
 public AzureADALv1Connection(AzureADConfig azureADCredentials, ITraceLogger traceLogger)
 {
     _iLogger           = traceLogger;
     AzureADCache       = new AzureADTokenCache(azureADCredentials, traceLogger);
     AzureADCredentials = azureADCredentials;
 }