public override void Init() { _userInfoService = new UserAuthService(); //PostAuthenticateRequest += new EventHandler(MvcApplication_PostAuthenticateRequest); AuthenticateRequest += new EventHandler(MvcApplication_AuthenticateRequest); base.Init(); }
public JwtService(IUserRefreshTokenRepository refreshRepository, IProfileService profileService, IUserAuthService userService, IConfiguration configuration) { this.refreshRepository = refreshRepository; this.profileService = profileService; this.userService = userService; this.configuration = configuration; }
/// <summary> /// Constructor. /// </summary> public UserController(IUserRepository users, IUserAuthService authService, ILogger logger) : base(authService, logger) { _openId = new OpenIdRelyingParty(); _logger = logger; _users = users; }
public async Task When_CredentialsAreValid_Should_ReturnAuthenticationResult_With_SuccessCodeAndUser() { IUserAuthService service = await CreateMockService(); var authenticationResult = await service.AuthenticateAsync(CorrectUsername, CorrectPassword); Assert.AreEqual(AuthenticationResultCode.Success, authenticationResult.Code); Assert.IsNotNull(authenticationResult.User); }
public async Task When_PasswordMismatches_Should_ReturnAuthenticationResult_With_InvalidCredentialsCode() { IUserAuthService service = await CreateMockService(); var authenticationResult = await service.AuthenticateAsync(CorrectUsername, IncorrectPassword); Assert.AreEqual(AuthenticationResultCode.InvalidCredentials, authenticationResult.Code); Assert.IsNull(authenticationResult.User); }
public BasicAuthenticationHandler( IOptionsMonitor <AuthenticationSchemeOptions> options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock, IUserAuthService authService) : base(options, logger, encoder, clock) { this.authService = authService; }
public async Task Invoke(HttpContext context, IUserAuthService userService) { var accessToken = context.Request.Headers["Authorization"].FirstOrDefault()?.Split(" ").Last(); var refreshToken = context.Request.Headers["Refresh"].FirstOrDefault()?.Split(" ").Last(); if (accessToken != null) { AttachUserToContext(context, userService, accessToken, refreshToken); } await _next(context); }
private void AttachUserToContext(HttpContext context, IUserAuthService userService, string accessToken, string refreshToken) { try { var tokenHandler = new JwtSecurityTokenHandler(); var key = Encoding.ASCII.GetBytes(_appSettings.Secret); tokenHandler.ValidateToken(accessToken, new TokenValidationParameters { ValidateIssuerSigningKey = true, IssuerSigningKey = new SymmetricSecurityKey(key), ValidateIssuer = false, ValidateAudience = false, // set clockskew to zero so tokens expire exactly at token expiration time (instead of 5 minutes later) ClockSkew = TimeSpan.Zero }, out SecurityToken validatedToken); var jwtToken = (JwtSecurityToken)validatedToken; var userId = int.Parse(jwtToken.Claims.First(x => x.Type == "id").Value); // attach user to context on successful jwt validation context.Items["User"] = userService.GetById(userId); } catch { try { var tokenHandler = new JwtSecurityTokenHandler(); var key = Encoding.ASCII.GetBytes(_appSettings.Secret); tokenHandler.ValidateToken(refreshToken, new TokenValidationParameters { ValidateIssuerSigningKey = true, IssuerSigningKey = new SymmetricSecurityKey(key), ValidateIssuer = false, ValidateAudience = false, // set clockskew to zero so tokens expire exactly at token expiration time (instead of 5 minutes later) ClockSkew = TimeSpan.Zero }, out SecurityToken validatedToken); var jwtToken = (JwtSecurityToken)validatedToken; var userId = int.Parse(jwtToken.Claims.First(x => x.Type == "id").Value); // attach user to context on successful jwt validation context.Items["User"] = userService.GetById(userId); } catch { // do nothing if jwt validation fails // user is not attached to context so request won't have access to secure routes } } }
public UsersController(ILogger <UsersController> log, IMapper mapper, IUserData userData, IUserService userService, IUserAuthService userAuthService, SmtpSettings smtpSettings) { _log = log; _userData = userData; _userService = userService; _userAuthService = userAuthService; _mapper = mapper; _smtpSettings = smtpSettings; }
public AuthorizationController( IUserAuthService authService, IMapper mapper, IConfiguration config, ITokenGeneratorService jwtTokenGenerator, IOptions <JwtTokenSecretKey> secret, IOptions <JwtTokenOptions> options, DashboardDbContext context, IOptions <MainUserData> optionsMainUser ) { _authService = authService; _mapper = mapper; _config = config; _jwtTokenGenerator = jwtTokenGenerator; _context = context; _optionsMainUser = optionsMainUser; _jwtTokenSecretKey = secret.Value.jwtTokenSecretKey; _issuer = options.Value.issuer; _audience = options.Value.audience; }
public LoginCommandHandler(IAuthTokenGenerator authTokenGenerator, IRoleService roleService, IUserAuthService userAuthService) { _authTokenGenerator = authTokenGenerator; _roleService = roleService; _userAuthService = userAuthService; }
public UsersController(IUserAuthService _userAuthService) { this._userAuthService = _userAuthService; }
public AccountController(IAuthManager authRepository, IUserAuthService userAuthService, IErrorMessageService errorMessageService) { _errorMessageService = errorMessageService; _userAuthService = userAuthService; _authManager = authRepository; }
public LogAdminRequestFilter(IUserAuthService userAuthService) { this.userAuthService = userAuthService; }
public GamDroidDbService(gamdroidContext context, IUserAuthService userAuthService) { _context = context; _userAuthService = userAuthService; }
public UserController(IUserAuthService userAuthService, IUserQueryProcessor userQueryProcessor) { _userAuthService = userAuthService; _userQueryProcessor = userQueryProcessor; }
public AuthenticationService(IUserAuthService userAuthService, NavigationManager navigationManager) { _userAuthService = userAuthService; _navigationManager = navigationManager; }
public AuthController(IUserAuthService userAuthService, IMapper mapper, IOptions <AppSettings> appSettings) { _mapper = mapper; _userAuthService = userAuthService; _appSettings = appSettings.Value; }
public UserAuthController(ILoginInfo loginInfo, IUserAuthService UserAuthService) { _service = UserAuthService; }
/// <summary> /// Constructor. /// </summary> /// <param name="userAuthService"></param> protected BaseController(IUserAuthService userAuthService,ILogger logger) { UserAuthService = userAuthService; Logger = logger; }
public AuthController(IUserAuthService authService) { this._authService = authService; }
public UsersController(IUserAuthService userAuthService, IImageFileReader imageFileReader, IImageDataHelper imageDataHelper) { _userAuthService = userAuthService; _imageFileReader = imageFileReader; _imageDataHelper = imageDataHelper; }
public UserController(IssuesDBContext db, IUserAuthService userAuth, IMapper mapper) { this.db = db; this.userAuth = userAuth; this.mapper = mapper; }
public UserService(IUserAuthService userAuthService) { _userAuthService = userAuthService; }
public UserAuthController(IUserAuthService userAuthService) { _userAuthService = userAuthService; }
public LoginController(IUserAuthService userAuthService, IUsersService userService) { _userAuthService = userAuthService; _usersService = userService; }
public AuthManager(IUserAuthService userAuthService, ITokenHelper tokenHelper) { _userAuthService = userAuthService; _tokenHelper = tokenHelper; }
public UserAuthsController(IUserAuthService userAuthService, IAuthService authService) { _userAuthService = userAuthService; _authService = authService; }
public AuthController(JwtTokenGenerator jwtTokenGenerator, IUserAuthService userAuthService) { _jwtTokenGenerator = jwtTokenGenerator; _userAuthService = userAuthService; }
public AuthController(IJwtService jwt, IUserAuthService service) { jwtService = jwt; userService = service; }
public BlueprintController(IBlueprintRepository blueprints,IUserAuthService authService,ILogger logger) : base(authService,logger) { _blueprints = blueprints; }
public ScheduledActionsController(IPlantScheduledActionService scheduledActionService, IUserAuthService userAuthService) { _scheduledActionService = scheduledActionService; _userAuthService = userAuthService; }
public ChangePasswordHandler(IBudgetDbContext context, IUserAuthService userAuthService, IPasswordService passService) { _context = context; _userAuthService = userAuthService; _passService = passService; }
public UsersController(IUsersService usersService, IUserAuthService usersAuthService) { _usersService = usersService; _usersAuthService = usersAuthService; }