public TokenValidator(
        IdentityServerOptions options,
        IIssuerNameService issuerNameService,
        IClientStore clients,
        IProfileService profile,
        IReferenceTokenStore referenceTokenStore,
        ICustomTokenValidator customValidator,
        IKeyMaterialService keys,
        ISessionCoordinationService sessionCoordinationService,
        ISystemClock clock,
        ILogger <TokenValidator> logger)
    {
        _options             = options;
        _issuerNameService   = issuerNameService;
        _clients             = clients;
        _profile             = profile;
        _referenceTokenStore = referenceTokenStore;
        _customValidator     = customValidator;
        _keys = keys;
        _sessionCoordinationService = sessionCoordinationService;
        _clock  = clock;
        _logger = logger;

        _log = new TokenValidationLog();
    }
Example #2
0
        public TokenValidator(
            IdentityServerOptions options,
            IHttpContextAccessor context,
            IClientStore clients,
            IProfileService profile,
            IReferenceTokenStore referenceTokenStore,
            IRefreshTokenStore refreshTokenStore,
            ICustomTokenValidator customValidator,
            IKeyMaterialService keys,
            ISystemClock clock,
            ILogger <TokenValidator> logger)
        {
            _options             = options;
            _context             = context;
            _clients             = clients;
            _profile             = profile;
            _referenceTokenStore = referenceTokenStore;
            _refreshTokenStore   = refreshTokenStore;
            _customValidator     = customValidator;
            _keys   = keys;
            _clock  = clock;
            _logger = logger;

            _log = new TokenValidationLog();
        }
Example #3
0
        public static TokenValidator CreateTokenValidator(IReferenceTokenStore store = null, IProfileService profile = null)
        {
            if (profile == null)
            {
                profile = new TestProfileService();
            }

            if (store == null)
            {
                store = CreateReferenceTokenStore();
            }

            var clients = CreateClientStore();
            var options = TestIdentityServerOptions.Create();
            var context = new MockHttpContextAccessor(options);
            var logger  = TestLogger.Create <TokenValidator>();

            var validator = new TokenValidator(
                clients: clients,
                referenceTokenStore: store,
                customValidator: new DefaultCustomTokenValidator(
                    profile: profile,
                    clients: clients,
                    logger: TestLogger.Create <DefaultCustomTokenValidator>()),
                keys: new DefaultKeyMaterialService(new[] { new DefaultValidationKeysStore(new[] { TestCert.LoadSigningCredentials().Key }) }),
                logger: logger,
                options: options,
                context: context);

            return(validator);
        }
 public TokenExchangeMutateGrantValidator(
     IScopedContext <TenantRequestContext> scopedTenantRequestContext,
     IReferenceTokenStore referenceTokenStore,
     IPersistedGrantStore persistedGrantStore,
     IScopedStorage scopedStorage,
     IResourceStore resourceStore,
     IScopedOptionalClaims scopedOptionalClaims,
     IConsentExternalService consentExternalService,
     IExternalServicesStore externalServicesStore,
     IScopedOverrideRawScopeValues scopedOverrideRawScopeValues,
     ISerializer serializer,
     IConsentDiscoveryCacheAccessor consentDiscoveryCacheAccessor,
     IOptions <TokenExchangeOptions> tokenExchangeOptions,
     ITokenValidator tokenValidator,
     ILogger <TokenExchangeMutateGrantValidator> logger)
 {
     _scopedTenantRequestContext = scopedTenantRequestContext;
     _persistedGrantStore        = persistedGrantStore;
     _referenceTokenStore        = referenceTokenStore;
     _scopedStorage                 = scopedStorage;
     _serializer                    = serializer;
     _resourceStore                 = resourceStore;
     _scopedOptionalClaims          = scopedOptionalClaims;
     _consentExternalService        = consentExternalService;
     _externalServicesStore         = externalServicesStore;
     _scopedOverrideRawScopeValues  = scopedOverrideRawScopeValues;
     _consentDiscoveryCacheAccessor = consentDiscoveryCacheAccessor;
     _tokenExchangeOptions          = tokenExchangeOptions.Value;
     _tokenValidator                = tokenValidator;
     _logger = logger;
 }
        public TokenValidator(
            IClientStore clients,
            IProfileService profile,
            IReferenceTokenStore referenceTokenStore,
            IRefreshTokenStore refreshTokenStore,
            ICustomTokenValidator customValidator,
            IKeyMaterialService keys,
            ISystemClock clock,
            ILogger <TokenValidator> logger,
            PartyDetailsOptions partyDetailsOptions,
            IdentityServerOptions options)
        {
            _clients             = clients;
            _profile             = profile;
            _referenceTokenStore = referenceTokenStore;
            _refreshTokenStore   = refreshTokenStore;
            _customValidator     = customValidator;
            _keys   = keys;
            _clock  = clock;
            _logger = logger;

            _partyDetailsOptions = partyDetailsOptions;
            _options             = options;

            _log = new TokenValidationLog();
        }
        public IntrospectionRequestValidatorTests()
        {
            _referenceTokenStore = Factory.CreateReferenceTokenStore();
            var tokenValidator = Factory.CreateTokenValidator(_referenceTokenStore);

            _subject = new IntrospectionRequestValidator(tokenValidator, TestLogger.Create <IntrospectionRequestValidator>());
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultTokenService" /> class. This overloaded constructor is deprecated and will be removed in 3.0.0.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="claimsProvider">The claims provider.</param>
 /// <param name="referenceTokenStore">The reference token store.</param>
 /// <param name="creationService">The signing service.</param>
 /// <param name="events">The events service.</param>
 /// <param name="logger">The logger.</param>
 public DefaultTokenService(IHttpContextAccessor context, IClaimsService claimsProvider, IReferenceTokenStore referenceTokenStore, ITokenCreationService creationService, IEventService events, ILogger <DefaultTokenService> logger)
 {
     Logger              = logger;
     Context             = context;
     ClaimsProvider      = claimsProvider;
     ReferenceTokenStore = referenceTokenStore;
     CreationService     = creationService;
     Events              = events;
 }
Example #8
0
        public static TokenValidator CreateTokenValidator(
            IReferenceTokenStore store           = null,
            IRefreshTokenStore refreshTokenStore = null,
            IProfileService profile       = null,
            IdentityServerOptions options = null, ISystemClock clock = null)
        {
            if (options == null)
            {
                options = TestIdentityServerOptions.Create();
            }

            if (profile == null)
            {
                profile = new TestProfileService();
            }

            if (store == null)
            {
                store = CreateReferenceTokenStore();
            }

            clock = clock ?? new StubClock();

            if (refreshTokenStore == null)
            {
                refreshTokenStore = CreateRefreshTokenStore();
            }

            var clients = CreateClientStore();
            var context = new MockHttpContextAccessor(options);
            var logger  = TestLogger.Create <TokenValidator>();

            var keyInfo = new SecurityKeyInfo
            {
                Key = TestCert.LoadSigningCredentials().Key,
                SigningAlgorithm = "RS256"
            };

            var validator = new TokenValidator(
                clients: clients,
                clock: clock,
                profile: profile,
                referenceTokenStore: store,
                refreshTokenStore: refreshTokenStore,
                customValidator: new DefaultCustomTokenValidator(),
                keys: new DefaultKeyMaterialService(
                    new[] { new InMemoryValidationKeysStore(new[] { keyInfo }) },
                    Enumerable.Empty <ISigningCredentialStore>(),
                    new NopAutomaticKeyManagerKeyStore()
                    ),
                logger: logger,
                options: options,
                context: context);

            return(validator);
        }
 public CustomTokenService(IClaimsService claimsProvider
                           , IReferenceTokenStore referenceTokenStore
                           , ITokenCreationService creationService
                           , IHttpContextAccessor contextAccessor
                           , ISystemClock clock
                           , IKeyMaterialService keyMaterialService
                           , ILogger <DefaultTokenService> logger)
     : base(claimsProvider, referenceTokenStore, creationService, contextAccessor, clock, keyMaterialService, logger)
 {
 }
 public CodeDefaultTokenService(IClaimsService claimsProvider, IReferenceTokenStore referenceTokenStore, ITokenCreationService creationService, IHttpContextAccessor contextAccessor, ISystemClock clock, IKeyMaterialService keyMaterialService, IdentityServerOptions options, ILogger <DefaultTokenService> logger)
 {
     ContextAccessor     = contextAccessor;
     ClaimsProvider      = claimsProvider;
     ReferenceTokenStore = referenceTokenStore;
     CreationService     = creationService;
     Clock = clock;
     KeyMaterialService = keyMaterialService;
     Options            = options;
     Logger             = logger;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="TokenRevocationResponseGenerator" /> class.
 /// </summary>
 /// <param name="referenceTokenStore">The reference token store.</param>
 /// <param name="refreshTokenStore">The refresh token store.</param>
 /// <param name="logger">The logger.</param>
 public MyTokenRevocationResponseGenerator(
     IReferenceTokenStore referenceTokenStore,
     IRefreshTokenStore refreshTokenStore,
     ITokenValidator tokenValidator,
     ITokenRevocationEventHandler tokenRevocationEventHandler,
     ILogger <TokenRevocationResponseGenerator> logger)
 {
     ReferenceTokenStore          = referenceTokenStore;
     RefreshTokenStore            = refreshTokenStore;
     _tokenValidator              = tokenValidator;
     _tokenRevocationEventHandler = tokenRevocationEventHandler;
     Logger = logger;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="RevocationEndpoint"/> class.
 /// </summary>
 /// <param name="logger">The logger.</param>
 /// <param name="clientValidator">The client validator.</param>
 /// <param name="requestValidator">The request validator.</param>
 /// <param name="referenceTokenStore">The reference token store.</param>
 /// <param name="refreshTokenStore">The refresh token store.</param>
 /// <param name="events">The events.</param>
 public RevocationEndpoint(ILogger <RevocationEndpoint> logger,
                           ClientSecretValidator clientValidator,
                           ITokenRevocationRequestValidator requestValidator,
                           IReferenceTokenStore referenceTokenStore,
                           IRefreshTokenStore refreshTokenStore,
                           IEventService events)
 {
     _logger              = logger;
     _clientValidator     = clientValidator;
     _requestValidator    = requestValidator;
     _referenceTokenStore = referenceTokenStore;
     _refreshTokenStore   = refreshTokenStore;
     _events              = events;
 }
Example #13
0
 public MyDefaultTokenService(
     IScopedContext <TenantRequestContext> scopedTenantRequestContext,
     IClaimsService claimsProvider,
     IReferenceTokenStore referenceTokenStore,
     ITokenCreationService creationService,
     IHttpContextAccessor contextAccessor,
     ISystemClock clock,
     IKeyMaterialService keyMaterialService,
     IdentityServerOptions options,
     ILogger <DefaultTokenService> logger) : base(claimsProvider, referenceTokenStore, creationService,
                                                  contextAccessor, clock, keyMaterialService, options, logger)
 {
     _scopedTenantRequestContext = scopedTenantRequestContext;
 }
 public DefaultPersistedGrantStoreTests()
 {
     _codes = new DefaultAuthorizationCodeStore(_store,
                                                new PersistentGrantSerializer(),
                                                TestLogger.Create <DefaultAuthorizationCodeStore>());
     _refreshTokens = new DefaultRefreshTokenStore(_store,
                                                   new PersistentGrantSerializer(),
                                                   TestLogger.Create <DefaultRefreshTokenStore>());
     _referenceTokens = new DefaultReferenceTokenStore(_store,
                                                       new PersistentGrantSerializer(),
                                                       TestLogger.Create <DefaultReferenceTokenStore>());
     _userConsent = new DefaultUserConsentStore(_store,
                                                new PersistentGrantSerializer(),
                                                TestLogger.Create <DefaultUserConsentStore>());
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultTokenService" /> class. This overloaded constructor is deprecated and will be removed in 3.0.0.
 /// </summary>
 /// <param name="claimsProvider">The claims provider.</param>
 /// <param name="referenceTokenStore">The reference token store.</param>
 /// <param name="creationService">The signing service.</param>
 /// <param name="contextAccessor">The HTTP context accessor.</param>
 /// <param name="clock">The clock.</param>
 /// <param name="logger">The logger.</param>
 public DefaultTokenService(
     IClaimsService claimsProvider,
     IReferenceTokenStore referenceTokenStore,
     ITokenCreationService creationService,
     IHttpContextAccessor contextAccessor,
     ISystemClock clock,
     ILogger <DefaultTokenService> logger)
 {
     Context             = contextAccessor;
     ClaimsProvider      = claimsProvider;
     ReferenceTokenStore = referenceTokenStore;
     CreationService     = creationService;
     Clock  = clock;
     Logger = logger;
 }
Example #16
0
 public OrganisationTokenService(
     IClaimsService claimsProvider,
     IIdentityServerRepository iIdentityServerRepository,
     IReferenceTokenStore referenceTokenStore,
     ITokenCreationService creationService,
     IHttpContextAccessor contextAccessor,
     ISystemClock clock,
     IKeyMaterialService keyMaterialService,
     IdentityServerOptions options,
     ILogger <DefaultTokenService> logger,
     IIdentityManagementRepository identityManagementRepository)
     : base(claimsProvider, referenceTokenStore, creationService, contextAccessor, clock, keyMaterialService, options, logger)
 {
     _iIdentityManagementRepository = identityManagementRepository ?? throw new ArgumentNullException(nameof(identityManagementRepository));
     _iIdentityServerRepository     = iIdentityServerRepository ?? throw new ArgumentNullException(nameof(iIdentityServerRepository));
 }
 public TokenService(
     IClaimsService claimsProvider,
     IReferenceTokenStore referenceTokenStore,
     ITokenCreationService creationService,
     IHttpContextAccessor contextAccessor,
     ISystemClock clock,
     ILogger <TokenService> logger,
     PartyDetailsOptions partyDetailsOptions,
     SchemeOwnerIdentityProviderOptions idpOptions)
 {
     _context             = contextAccessor;
     _claimsProvider      = claimsProvider;
     _referenceTokenStore = referenceTokenStore;
     _creationService     = creationService;
     _clock  = clock;
     _logger = logger;
     _partyDetailsOptions = partyDetailsOptions;
     _idpOptions          = idpOptions;
 }
Example #18
0
 public TokenHandlerService(
     IIdentityServerInteractionService interaction,
     IEventService events,
     IRefreshTokenService refreshTokenService,
     ITokenService tokenService,
     IReferenceTokenStore referenceTokenStore,
     IUserClaimsPrincipalFactory <IdentityUser <int> > principalFactory,
     IdentityServerOptions options,
     SignInManager <IdentityUser <int> > signInManager,
     UserManager <IdentityUser <int> > userManager)
 {
     _refreshTokenService = refreshTokenService;
     _tokenService        = tokenService;
     _referenceTokenStore = referenceTokenStore;
     _principalFactory    = principalFactory;
     _options             = options;
     _signInManager       = signInManager;
     _userManager         = userManager;
 }
Example #19
0
    public static TokenValidator CreateTokenValidator(
        IReferenceTokenStore store           = null,
        IRefreshTokenStore refreshTokenStore = null,
        IProfileService profile = null,
        IIssuerNameService issuerNameService = null,
        IdentityServerOptions options        = null,
        ISystemClock clock = null)
    {
        options ??= TestIdentityServerOptions.Create();
        profile ??= new TestProfileService();
        store ??= CreateReferenceTokenStore();
        clock ??= new StubClock();
        refreshTokenStore ??= CreateRefreshTokenStore();
        issuerNameService ??= new TestIssuerNameService(options.IssuerUri);

        var clients = CreateClientStore();

        var logger = TestLogger.Create <TokenValidator>();

        var keyInfo = new SecurityKeyInfo
        {
            Key = TestCert.LoadSigningCredentials().Key,
            SigningAlgorithm = "RS256"
        };

        var validator = new TokenValidator(
            clients: clients,
            clock: clock,
            profile: profile,
            referenceTokenStore: store,
            customValidator: new DefaultCustomTokenValidator(),
            keys: new DefaultKeyMaterialService(
                new[] { new InMemoryValidationKeysStore(new[] { keyInfo }) },
                Enumerable.Empty <ISigningCredentialStore>(),
                new NopAutomaticKeyManagerKeyStore()
                ),
            sessionCoordinationService: new StubSessionCoordinationService(),
            logger: logger,
            options: options,
            issuerNameService: issuerNameService);

        return(validator);
    }
Example #20
0
 public MyTokenResponseGenerator(
     IScopedHttpContextRequestForm scopedHttpContextRequestForm,
     IHttpContextAccessor contextAccessor,
     IScopedOptionalClaims scopedOptionalClaims,
     IScopedStorage scopedStorage,
     IRefreshTokenStore refreshTokenStore,
     IReferenceTokenStore referenceTokenStore,
     IPersistedGrantStoreEx persistedGrantStore,
     ISystemClock clock,
     ITokenService tokenService,
     IRefreshTokenService refreshTokenService,
     IScopeParser scopeParser,
     IResourceStore resources,
     IClientStore clients,
     ILogger <TokenResponseGenerator> logger) : base(clock, tokenService, refreshTokenService, scopeParser, resources, clients, logger)
 {
     _scopedHttpContextRequestForm = scopedHttpContextRequestForm;
     _contextAccessor      = contextAccessor;
     _scopedOptionalClaims = scopedOptionalClaims;
     _refreshTokenStore    = refreshTokenStore;
     _referenceTokenStore  = referenceTokenStore;
     _scopedStorage        = scopedStorage;
     _persistedGrantStore  = persistedGrantStore;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="TokenRevocationResponseGenerator" /> class.
 /// </summary>
 /// <param name="referenceTokenStore">The reference token store.</param>
 /// <param name="refreshTokenStore">The refresh token store.</param>
 /// <param name="logger">The logger.</param>
 public TokenRevocationResponseGenerator(IReferenceTokenStore referenceTokenStore, IRefreshTokenStore refreshTokenStore, ILogger <TokenRevocationResponseGenerator> logger)
 {
     ReferenceTokenStore = referenceTokenStore;
     RefreshTokenStore   = refreshTokenStore;
     Logger = logger;
 }
Example #22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CustomTokenValidator" /> class.
 /// </summary>
 /// <param name="store">The referenceToken store.</param>
 /// <param name="logger">The logger.</param>
 public CustomTokenValidator(IReferenceTokenStore store, ILogger <CustomTokenValidator> logger)
 {
     Store  = store;
     Logger = logger;
 }