Esempio n. 1
0
 public AuthController(IUserService userService, IAuthService authService, IRefreshTokenService refreshTokenService, IMapper mapper)
 {
     _userService         = userService;
     _authService         = authService;
     _mapper              = mapper;
     _refreshTokenService = refreshTokenService;
 }
 public TokenResponseGenerator(ITokenService tokenService, IRefreshTokenService refreshTokenService, IScopeStore scopes, ILoggerFactory loggerFactory)
 {
     _tokenService = tokenService;
     _refreshTokenService = refreshTokenService;
     _scopes = scopes;
     _logger = loggerFactory.CreateLogger<TokenResponseGenerator>();
 }
 public TokenResponseGenerator(ITokenService tokenService, IRefreshTokenService refreshTokenService, ITokenHandleStore tokenHandles, CoreSettings settings, IAuthorizationCodeStore codes)
 {
     _settings = settings;
     _tokenService = tokenService;
     _refreshTokenService = refreshTokenService;
     _tokenHandles = tokenHandles;
 }
Esempio n. 4
0
 public AuthController(IUserService userService, IRoleService roleService, IJwtAuthManager jwtAuthManager, IRefreshTokenService refreshTokenService)
 {
     _userService         = userService;
     _roleService         = roleService;
     _jwtAuthManager      = jwtAuthManager;
     _refreshTokenService = refreshTokenService;
 }
 public TokenResponseGenerator(ITokenService tokenService, IRefreshTokenService refreshTokenService, IScopeStore scopes, ICustomTokenResponseGenerator customResponseGenerator)
 {
     _tokenService = tokenService;
     _refreshTokenService = refreshTokenService;
     _scopes = scopes;
     _customResponseGenerator = customResponseGenerator;
 }
 public TokenResponseGenerator(ITokenService tokenService, IRefreshTokenService refreshTokenService, IScopeStore scopes, ICustomTokenResponseGenerator customResponseGenerator)
 {
     _tokenService        = tokenService;
     _refreshTokenService = refreshTokenService;
     _scopes = scopes;
     _customResponseGenerator = customResponseGenerator;
 }
Esempio n. 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultRefreshTokenService" /> class.
 /// </summary>
 public ServerSideSessionRefreshTokenService(
     Decorator <IRefreshTokenService> inner,
     ISessionCoordinationService sessionCoordinationService)
 {
     Inner = inner.Instance;
     SessionCoordinationService = sessionCoordinationService;
 }
Esempio n. 8
0
        public async Task CreateAsync(AuthenticationTokenCreateContext context)
        {
            var refreshTokenId = Guid.NewGuid().ToString("n");

            if (context.Ticket == null)
            {
                context.Response.StatusCode   = 400;
                context.Response.ContentType  = "application/json";
                context.Response.ReasonPhrase = "invalid refresh token";
                return;
            }

            IRefreshTokenService refreshTokenService = ResolverFactory.GetService <RefreshTokenService>();

            var client = context.OwinContext.Get <Client>("oauth:client");

            var token = new RefreshTokenDto()
            {
                RefreshTokenId = UnitHelper.GetHash(refreshTokenId),
                Subject        = context.Ticket.Identity.Name,
                IssuedUtc      = DateTime.UtcNow,
                ExpiresUtc     = DateTime.UtcNow.AddDays(client.RefreshTokenLifeTime)
            };

            context.Ticket.Properties.IssuedUtc = token.IssuedUtc;

            context.Ticket.Properties.ExpiresUtc = token.ExpiresUtc;

            token.ProtectedTicket = context.SerializeTicket();

            await refreshTokenService.CreateAsync(token);

            context.SetToken(refreshTokenId);
        }
Esempio n. 9
0
 public TokenResponseGenerator(ITokenService tokenService, IRefreshTokenService refreshTokenService, IScopeStore scopes, ILoggerFactory loggerFactory)
 {
     _tokenService        = tokenService;
     _refreshTokenService = refreshTokenService;
     _scopes = scopes;
     _logger = loggerFactory.CreateLogger <TokenResponseGenerator>();
 }
 public AccountController(
     IIdentityServerInteractionService interaction,
     IClientStore clientStore,
     IHttpContextAccessor httpContextAccessor,
     IAuthenticationSchemeProvider schemeProvider,
     IEventService events,
     IRefreshTokenService refreshTokenService,
     ITokenService tokenService,
     IUserClaimsPrincipalFactory <IdentityUser <int> > principalFactory,
     IdentityServerOptions options,
     SignInManager <IdentityUser <int> > signInManager,
     UserManager <IdentityUser <int> > userManager,
     TokenHandlerService tokenHandler,
     AppDbContext context)
 {
     // if the TestUserStore is not in DI, then we'll just use the global users collection
     _context          = context;
     _interaction      = interaction;
     _events           = events;
     _account          = new AccountService(interaction, httpContextAccessor, schemeProvider, clientStore);
     _principalFactory = principalFactory;
     _options          = options;
     _signInManager    = signInManager;
     _userManager      = userManager;
     _tokenHandler     = tokenHandler;
 }
Esempio n. 11
0
 public UsersController(
     IAuthenticateService authenticateService,
     IRefreshTokenService refreshTokenService)
 {
     this.authenticateService = authenticateService;
     this.refreshTokenService = refreshTokenService;
 }
Esempio n. 12
0
        public TokenValidator(
            IdentityServerOptions options,
            IHttpContextAccessor context,
            IClientStore clients,
            IProfileService profile,
            IReferenceTokenStore referenceTokenStore,
            IRefreshTokenService refreshTokenService,
            ICustomTokenValidator customValidator,
            IKeyMaterialService keys,
            ISystemClock clock,
            ILogger <TokenValidator> logger)
        {
            _options             = options;
            _context             = context;
            _clients             = clients;
            _profile             = profile;
            _referenceTokenStore = referenceTokenStore;
            _refreshTokenService = refreshTokenService;
            _customValidator     = customValidator;
            _keys   = keys;
            _clock  = clock;
            _logger = logger;

            _log = new TokenValidationLog();
        }
Esempio n. 13
0
 public RefreshTokenQueryHandler(IRefreshTokenService service, ICommonService commonService,
                                 IUnitOfWork unitOfWork)
 {
     _service       = service;
     _commonService = commonService;
     _unitOfWork    = unitOfWork;
 }
 public TokenRequestValidator(
     IdentityServerOptions options,
     IIssuerNameService issuerNameService,
     IAuthorizationCodeStore authorizationCodeStore,
     IResourceOwnerPasswordValidator resourceOwnerValidator,
     IProfileService profile,
     IDeviceCodeValidator deviceCodeValidator,
     IBackchannelAuthenticationRequestIdValidator backchannelAuthenticationRequestIdValidator,
     ExtensionGrantValidator extensionGrantValidator,
     ICustomTokenRequestValidator customRequestValidator,
     IResourceValidator resourceValidator,
     IResourceStore resourceStore,
     IRefreshTokenService refreshTokenService,
     IEventService events,
     ISystemClock clock,
     ILogger <TokenRequestValidator> logger)
 {
     _logger                 = logger;
     _options                = options;
     _issuerNameService      = issuerNameService;
     _clock                  = clock;
     _authorizationCodeStore = authorizationCodeStore;
     _resourceOwnerValidator = resourceOwnerValidator;
     _profile                = profile;
     _deviceCodeValidator    = deviceCodeValidator;
     _backchannelAuthenticationRequestIdValidator = backchannelAuthenticationRequestIdValidator;
     _extensionGrantValidator = extensionGrantValidator;
     _customRequestValidator  = customRequestValidator;
     _resourceValidator       = resourceValidator;
     _resourceStore           = resourceStore;
     _refreshTokenService     = refreshTokenService;
     _events = events;
 }
        public async Task CreateAsync(AuthenticationTokenCreateContext context)
        {
            var container = new UnityContainer();

            container.RegisterType <IRefreshTokenDataSource, RefreshTokenDataSource>();
            container.RegisterType <IRefreshTokenService, RefreshTokenService>();
            IRefreshTokenService _refreshTokenService = container.Resolve <IRefreshTokenService>();

            var refreshTokenLifeTime = context.OwinContext.Get <string>("clientRefreshTokenLifeTime") ?? "60";

            var token = new FM.Portal.Core.Model.RefreshToken()
            {
                ID         = Guid.NewGuid(),
                UserID     = Guid.Parse(context.Ticket.Identity.GetUserId()),
                IssuedDate = DateTime.UtcNow,
                ExpireDate = DateTime.UtcNow.AddMinutes(Convert.ToDouble(refreshTokenLifeTime))
            };

            context.Ticket.Properties.IssuedUtc  = token.IssuedDate;
            context.Ticket.Properties.ExpiresUtc = token.ExpireDate;

            token.ProtectedTicket = context.SerializeTicket();

            var result = _refreshTokenService.Add(token);

            if (result.Success)
            {
                context.SetToken(token.ID.ToString("n"));
            }
        }
Esempio n. 16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TokenRequestValidator" /> class.
 /// </summary>
 /// <param name="options">The options.</param>
 /// <param name="authorizationCodeStore">The authorization code store.</param>
 /// <param name="resourceOwnerValidator">The resource owner validator.</param>
 /// <param name="profile">The profile.</param>
 /// <param name="deviceCodeValidator">The device code validator.</param>
 /// <param name="extensionGrantValidator">The extension grant validator.</param>
 /// <param name="customRequestValidator">The custom request validator.</param>
 /// <param name="resourceValidator">The resource validator.</param>
 /// <param name="resourceStore">The resource store.</param>
 /// <param name="refreshTokenService"></param>
 /// <param name="events">The events.</param>
 /// <param name="clock">The clock.</param>
 /// <param name="logger">The logger.</param>
 public TokenRequestValidator(IdentityServerOptions options,
                              IAuthorizationCodeStore authorizationCodeStore,
                              IResourceOwnerPasswordValidator resourceOwnerValidator,
                              IProfileService profile,
                              IDeviceCodeValidator deviceCodeValidator,
                              ExtensionGrantValidator extensionGrantValidator,
                              ICustomTokenRequestValidator customRequestValidator,
                              IResourceValidator resourceValidator,
                              IResourceStore resourceStore,
                              IRefreshTokenService refreshTokenService,
                              IEventService events,
                              ISystemClock clock,
                              ILogger <TokenRequestValidator> logger)
 {
     _logger  = logger;
     _options = options;
     _clock   = clock;
     _authorizationCodeStore = authorizationCodeStore;
     _resourceOwnerValidator = resourceOwnerValidator;
     _profile                 = profile ?? throw new ArgumentNullException(nameof(profile));
     _deviceCodeValidator     = deviceCodeValidator;
     _extensionGrantValidator = extensionGrantValidator;
     _customRequestValidator  = customRequestValidator;
     _resourceValidator       = resourceValidator;
     _resourceStore           = resourceStore;
     _events = events ?? throw new ArgumentNullException(nameof(events));
     _refreshTokenService = refreshTokenService ?? throw new ArgumentNullException(nameof(refreshTokenService));
 }
Esempio n. 17
0
 public AuthMiddleware(
     IWorkContextAccessor workContextAccessor,
     IRefreshTokenService refreshTokenService)
 {
     _workContextAccessor = workContextAccessor;
     _refreshTokenService = refreshTokenService;
 }
Esempio n. 18
0
 public TokensController(IDispatcher dispatcher, IRefreshTokenService refreshTokenService,
                         IMemoryCache cache)
     : base(dispatcher)
 {
     _refreshTokenService = refreshTokenService;
     _cache = cache;
 }
Esempio n. 19
0
 public AuthService(
     IRefreshTokenService refreshTokenService,
     IHttpContextAccessor httpContextAccessor)
 {
     _refreshTokenService = refreshTokenService;
     _owinContext         = httpContextAccessor.Current().GetOwinContext();
 }
Esempio n. 20
0
 public TokensController(IAccessTokenService accessTokenService,
                         IRefreshTokenService refreshTokenService,
                         IDispatcher dispatcher,
                         IConfiguration configuration,
                         IOptions <AppOptions> appOptions) :
     base(accessTokenService, refreshTokenService, dispatcher, configuration, appOptions)
 {
 }
 public TokenResponseGenerator(ITokenService tokenService, IRefreshTokenService refreshTokenService, IResourceStore resources, IClientStore clients, ILoggerFactory loggerFactory)
 {
     _tokenService        = tokenService;
     _refreshTokenService = refreshTokenService;
     _resources           = resources;
     _clients             = clients;
     _logger = loggerFactory.CreateLogger <TokenResponseGenerator>();
 }
Esempio n. 22
0
 public RefreshTokenProvider(IRefreshTokenService refreshTokenService, ICommandBus commandBus, int refreshTokenExpiredTimeInMinutes, int ttlChange)
 {
     this.refreshTokenService = refreshTokenService;
     this.commandBus = commandBus;
     this.expriredTime = refreshTokenExpiredTimeInMinutes;
     this.ttlChange = ttlChange;
     this.serializer = new TicketSerializer();
 }
Esempio n. 23
0
 protected CachedHttpClient(
     IJsonSerializer jsonSerializer,
     IRefreshTokenService refreshTokenService,
     ILogManager logManager,
     ICache localCache) : base(jsonSerializer, refreshTokenService, logManager)
 {
     _localCache = localCache;
 }
Esempio n. 24
0
 public RefreshTokenProvider(IRefreshTokenService refreshTokenService, ICommandBus commandBus, int refreshTokenExpiredTimeInMinutes, int ttlChange)
 {
     this.refreshTokenService = refreshTokenService;
     this.commandBus          = commandBus;
     this.expriredTime        = refreshTokenExpiredTimeInMinutes;
     this.ttlChange           = ttlChange;
     this.serializer          = new TicketSerializer();
 }
Esempio n. 25
0
 public RefreshAccessTokenCommandHandler(IHttpContextAccessor httpContextAccessor,
                                         IRefreshTokenService refreshTokenService, IOptions <JwtConfig> jwtConfigOptions)
 {
     _httpContext = httpContextAccessor.HttpContext ??
                    throw new ArgumentNullException(nameof(httpContextAccessor.HttpContext));
     _refreshTokenService = refreshTokenService ?? throw new ArgumentNullException(nameof(refreshTokenService));
     _jwtConfig           = jwtConfigOptions.Value ?? throw new ArgumentNullException(nameof(jwtConfigOptions.Value));
 }
Esempio n. 26
0
 public AuthTokenService(IAccessTokenService accessTokenService,
                         IRefreshTokenService refreshTokenService,
                         ICustomerManager clientManager)
 {
     this.accessTokenService  = accessTokenService;
     this.refreshTokenService = refreshTokenService;
     this.clientManager       = clientManager;
 }
Esempio n. 27
0
 public AuthService(UserManager userManager, IRefreshTokenService refreshTokenService, IJwtFactory jwtFactory, IJwtTokenValidator jwtTokenValidator, JwtIssuerOptions jwtIssuerOptions)
 {
     _userManager         = userManager;
     _refreshTokenService = refreshTokenService;
     _jwtFactory          = jwtFactory;
     _jwtTokenValidator   = jwtTokenValidator;
     _jwtIssuerOptions    = jwtIssuerOptions;
 }
Esempio n. 28
0
 public UserService(IUserLoginService userLoginService, IOptions <AppSettings> appSettings, IEmployeeService employeeService, IRefreshTokenService refreshTokenService, IRevokeTokenService revokeTokenService)
 {
     _userLoginService    = userLoginService;
     _employeeService     = employeeService;
     _refreshTokenService = refreshTokenService;
     _revokeTokenService  = revokeTokenService;
     _appSettings         = appSettings.Value;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="TokenResponseGenerator" /> class.
 /// </summary>
 /// <param name="tokenService">The token service.</param>
 /// <param name="refreshTokenService">The refresh token service.</param>
 /// <param name="resources">The resources.</param>
 /// <param name="clients">The clients.</param>
 /// <param name="logger">The logger.</param>
 public TokenResponseGenerator(ITokenService tokenService, IRefreshTokenService refreshTokenService, IResourceStore resources, IClientStore clients, ILogger <TokenResponseGenerator> logger)
 {
     TokenService        = tokenService;
     RefreshTokenService = refreshTokenService;
     Resources           = resources;
     Clients             = clients;
     Logger = logger;
 }
Esempio n. 30
0
 public AuthenticationService(IUserRepository userRepository, IPasswordHasher <User> passwordHasher,
                              ITokenService tokenService, IRefreshTokenService refreshTokenService)
 {
     _userRepository      = userRepository;
     _passwordHasher      = passwordHasher;
     _tokenService        = tokenService;
     _refreshTokenService = refreshTokenService;
 }
Esempio n. 31
0
 public TokenController(IAccessTokenDecoder accessTokenDecoder, IRefreshTokenDecoder refreshTokenDecoder,
                        IRefreshTokenService refreshTokenService, IMediator mediator)
 {
     _accessTokenDecoder  = accessTokenDecoder ?? throw new ArgumentNullException(nameof(accessTokenDecoder));
     _refreshTokenDecoder = refreshTokenDecoder ?? throw new ArgumentNullException(nameof(refreshTokenDecoder));
     _refreshTokenService = refreshTokenService ?? throw new ArgumentNullException(nameof(refreshTokenService));
     _mediator            = mediator ?? throw new ArgumentNullException(nameof(mediator));
 }
Esempio n. 32
0
 public UsersController(MovieRamaContext dbContext, IHashingService hashingService, IJwtService jwtService, IRefreshTokenService refreshTokenService, AuthenticationService authService)
 {
     _dbContext           = dbContext;
     _hashingService      = hashingService;
     _jwtService          = jwtService;
     _refreshTokenService = refreshTokenService;
     _authService         = authService;
 }
Esempio n. 33
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TokenResponseGenerator" /> class.
 /// </summary>
 /// <param name="options">The options.</param>
 /// <param name="tokenService">The token service.</param>
 /// <param name="refreshTokenService">The refresh token service.</param>
 /// <param name="resources">The resources.</param>
 /// <param name="clients">The clients.</param>
 /// <param name="logger">The logger.</param>
 public TokenResponseGenerator(IdentityServerOptions options, ITokenService tokenService, IRefreshTokenService refreshTokenService, IResourceStore resources, IClientStore clients, ILogger <TokenResponseGenerator> logger)
 {
     Options             = options;
     TokenService        = tokenService;
     RefreshTokenService = refreshTokenService;
     Resources           = resources;
     Clients             = clients;
     Logger = logger;
 }
Esempio n. 34
0
 protected RestHttpClientBase(
     IJsonSerializer jsonSerializer,
     IRefreshTokenService refreshTokenService,
     ILogManager logManager)
 {
     JsonSerializer       = jsonSerializer;
     _refreshTokenService = refreshTokenService;
     Logger = logManager.GetLogger(GetType().ToString());
 }
 public TokenResponseGenerator(ITokenService tokenService, IRefreshTokenService refreshTokenService, IScopeStore scopes)
 {
     _tokenService = tokenService;
     _refreshTokenService = refreshTokenService;
     _scopes = scopes;
 }
 public TokenResponseGenerator(ITokenService tokenService, IRefreshTokenService refreshTokenService)
 {
     _tokenService = tokenService;
     _refreshTokenService = refreshTokenService;
 }