Пример #1
0
 public TokenExchangeGrantValidator(
     IScopedContext <TenantRequestContext> scopedTenantRequestContext,
     IScopedStorage scopedStorage,
     IResourceStore resourceStore,
     IScopedOptionalClaims scopedOptionalClaims,
     IConsentExternalService consentExternalService,
     IExternalServicesStore externalServicesStore,
     IScopedOverrideRawScopeValues scopedOverrideRawScopeValues,
     ISerializer serializer,
     IConsentDiscoveryCacheAccessor consentDiscoveryCacheAccessor,
     IOptions <TokenExchangeOptions> tokenExchangeOptions,
     IIdentityTokenValidator identityTokenValidator,
     ITokenValidator tokenValidator,
     ILogger <TokenExchangeGrantValidator> logger)
 {
     _scopedTenantRequestContext = scopedTenantRequestContext;
     _scopedStorage                 = scopedStorage;
     _serializer                    = serializer;
     _resourceStore                 = resourceStore;
     _scopedOptionalClaims          = scopedOptionalClaims;
     _consentExternalService        = consentExternalService;
     _externalServicesStore         = externalServicesStore;
     _scopedOverrideRawScopeValues  = scopedOverrideRawScopeValues;
     _consentDiscoveryCacheAccessor = consentDiscoveryCacheAccessor;
     _tokenExchangeOptions          = tokenExchangeOptions.Value;
     _identityTokenValidator        = identityTokenValidator;
     _tokenValidator                = tokenValidator;
     _logger = logger;
 }
 public DeviceCodeBackChannelController(
     IExternalServicesStore externalServicesStore,
     IOptions <TokenExchangeOptions> tokenExchangeOptions,
     IIdentityTokenValidator identityTokenValidator,
     IConsentExternalService consentExternalService,
     IConsentDiscoveryCacheAccessor consentDiscoveryCacheAccessor,
     IClientSecretValidator clientValidator,
     IDeviceFlowStore deviceFlowStore,
     ISerializer serializer,
     ICoreMapperAccessor coreMapperAccessor,
     IEventService events,
     ILogger <DeviceCodeBackChannelController> logger)
 {
     _externalServicesStore         = externalServicesStore;
     _tokenExchangeOptions          = tokenExchangeOptions.Value;
     _identityTokenValidator        = identityTokenValidator;
     _consentExternalService        = consentExternalService;
     _consentDiscoveryCacheAccessor = consentDiscoveryCacheAccessor;
     _clientValidator    = clientValidator;
     _deviceFlowStore    = deviceFlowStore;
     _serializer         = serializer;
     _coreMapperAccessor = coreMapperAccessor;
     _events             = events;
     _logger             = logger;
 }
 /// <summary>
 /// Create authentication handler
 /// </summary>
 /// <param name="options"></param>
 /// <param name="logger"></param>
 /// <param name="encoder"></param>
 /// <param name="clock"></param>
 /// <param name="httpContextAccessor"></param>
 /// <param name="accessTokenValidator"></param>
 public IdentityTokenAuthHandler(IOptionsMonitor <AuthenticationSchemeOptions> options,
                                 ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock,
                                 IHttpContextAccessor httpContextAccessor, IIdentityTokenValidator accessTokenValidator) :
     base(options, logger, encoder, clock)
 {
     _httpContextAccessor  = httpContextAccessor;
     _accessTokenValidator = accessTokenValidator;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="OidcClientOptions"/> class.
        /// </summary>
        /// <param name="authority">The authority.</param>
        /// <param name="clientId">The client identifier.</param>
        /// <param name="clientSecret">The client secret.</param>
        /// <param name="scope">The scope.</param>
        /// <param name="redirectUri">The redirect URI.</param>
        /// <param name="webView">The web view.</param>
        /// <param name="validator">The validator.</param>
        /// <exception cref="System.ArgumentNullException">authority</exception>
        public OidcClientOptions(string authority, string clientId, string clientSecret, string scope, string redirectUri, IWebView webView = null, IIdentityTokenValidator validator = null)
            : this(clientId, clientSecret, scope, redirectUri, webView, validator)
        {
            if (string.IsNullOrWhiteSpace(authority))
            {
                throw new ArgumentNullException(nameof(authority));
            }

            _providerInfo = new Lazy <Task <ProviderInformation> >(async() => await ProviderInformation.LoadFromMetadataAsync(authority, ValidateIssuerName, BackchannelHandler, (int)BackchannelTimeout.TotalSeconds));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="OidcClientOptions"/> class.
        /// </summary>
        /// <param name="info">The provider information.</param>
        /// <param name="clientId">The client id.</param>
        /// <param name="clientSecret">The client secret.</param>
        /// <param name="scope">The scope.</param>
        /// <param name="redirectUri">The redirect URI.</param>
        /// <param name="webView">The web view.</param>
        /// <param name="validator">The validator.</param>
        /// <exception cref="System.ArgumentNullException">info</exception>
        public OidcClientOptions(ProviderInformation info, string clientId, string clientSecret, string scope, string redirectUri, IWebView webView = null, IIdentityTokenValidator validator = null)
            : this(clientId, clientSecret, scope, redirectUri, webView, validator)
        {
            if (info == null)
            {
                throw new ArgumentNullException(nameof(info));
            }
            info.Validate();

            _providerInfo = new Lazy <Task <ProviderInformation> >(() => Task.FromResult(info));
        }
        private OidcClientOptions(string clientId, string clientSecret, string scope, string redirectUri, IWebView webView = null, IIdentityTokenValidator validator = null)
        {
            if (string.IsNullOrWhiteSpace(clientId))
            {
                throw new ArgumentNullException(nameof(clientId));
            }
            if (string.IsNullOrWhiteSpace(scope))
            {
                throw new ArgumentNullException(nameof(scope));
            }
            if (string.IsNullOrWhiteSpace(redirectUri))
            {
                throw new ArgumentNullException(nameof(redirectUri));
            }

            // make sure the scopes contain openid
            if (!scope.FromSpaceSeparatedString().Contains("openid"))
            {
                throw new ArgumentException("Scope must include openid", nameof(scope));
            }

            ClientId               = clientId;
            ClientSecret           = clientSecret;
            Scope                  = scope;
            RedirectUri            = redirectUri;
            IdentityTokenValidator = validator ?? new DefaultIdentityTokenValidator();
            WebView                = webView;
        }
        private OidcClientOptions(string clientId, string clientSecret, string scope, string redirectUri, IWebView webView = null, IIdentityTokenValidator validator = null)
        {
            if (string.IsNullOrWhiteSpace(clientId))
            {
                throw new ArgumentNullException(nameof(clientId));
            }
            if (string.IsNullOrWhiteSpace(clientSecret))
            {
                throw new ArgumentNullException(nameof(clientSecret));
            }
            if (string.IsNullOrWhiteSpace(scope))
            {
                throw new ArgumentNullException(nameof(scope));
            }
            if (string.IsNullOrWhiteSpace(redirectUri))
            {
                throw new ArgumentNullException(nameof(redirectUri));
            }

            ClientId               = clientId;
            ClientSecret           = clientSecret;
            Scope                  = scope;
            RedirectUri            = redirectUri;
            IdentityTokenValidator = validator ?? new DefaultIdentityTokenValidator();
            WebView                = webView;
        }