예제 #1
0
        public async Task <ClaimsIdentity> GetIdentityByLoginPair(
            string userName,
            string password)
        {
            try
            {
                using (var scope = _serviceScopeFactory.CreateScope())
                {
                    _authClientService = scope.ServiceProvider.GetRequiredService <IAuthClientService>();

                    var claims = new List <Claim>();

                    var authClient = await _authClientService.GetAuthClientByName(userName);

                    if (authClient == null || !HashHelpers.VerifyHashedPassword(authClient.PasswordHash, password))
                    {
                        throw new LogicException(ExceptionMessage.InvalidCredentials);
                    }

                    claims.Add(new Claim("role", "user"));

                    var claimIdentity = new ClaimsIdentity(new GenericIdentity(authClient.UserId.ToString()), claims);

                    return(await Task.FromResult(claimIdentity));
                }
            }
            catch (Exception ex)
            {
                return(await Task.FromResult <ClaimsIdentity>(null));
            }
        }
예제 #2
0
        public ConnectController(
            IAuthDataProvider _IValidationDataProvider,
            IAuthLoginService _IAuthLoginService,
            IAuthTokenService _IAuthTokenService,
            IAuthScopeService _IAuthScopeService,
            IAuthClientService _IAuthClientService,
            IRepository <AuthScope> _AuthScopeRepository,
            IRepository <AuthClient> _AuthClientRepository)
        {
            this._IValidationDataProvider = _IValidationDataProvider;
            this._IAuthLoginService       = _IAuthLoginService;

            this._IAuthTokenService  = _IAuthTokenService;
            this._IAuthScopeService  = _IAuthScopeService;
            this._IAuthClientService = _IAuthClientService;

            this._AuthScopeRepository  = _AuthScopeRepository;
            this._AuthClientRepository = _AuthClientRepository;
        }
예제 #3
0
 public AuthManageController(
     IAuthDataProvider _IValidationDataProvider,
     IAuthLoginService _IAuthLoginService,
     IAuthTokenService _IAuthTokenService,
     IAuthScopeService _IAuthScopeService,
     IAuthClientService _IAuthClientService,
     IEFRepository <AuthScope> _AuthScopeRepository,
     IEFRepository <AuthClient> _AuthClientRepository,
     IEFRepository <ReqLogEntity> _ReqLogModelRepository,
     IEFRepository <CacheHitLogEntity> _CacheHitLogRepository,
     ICacheProvider _cache)
 {
     this._IValidationDataProvider = _IValidationDataProvider;
     this._IAuthLoginService       = _IAuthLoginService;
     this._IAuthTokenService       = _IAuthTokenService;
     this._IAuthScopeService       = _IAuthScopeService;
     this._IAuthClientService      = _IAuthClientService;
     this._AuthScopeRepository     = _AuthScopeRepository;
     this._AuthClientRepository    = _AuthClientRepository;
     this._ReqLogModelRepository   = _ReqLogModelRepository;
     this._CacheHitLogRepository   = _CacheHitLogRepository;
     this._cache = _cache;
 }