public UserRepository(ICompanyRepository companyRepository, IOptions <AppSettings> appSettings, ApiDBContext context) : base(context) { _companyRepository = companyRepository; _appSettings = appSettings.Value; }
private async Task attachAccountToContext(HttpContext context, ApiDBContext dataContext, string token) { try { var tokenHandler = new JwtSecurityTokenHandler(); var key = Encoding.ASCII.GetBytes(_appSettings.Secret); tokenHandler.ValidateToken(token, 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 accountId = int.Parse(jwtToken.Claims.First(x => x.Type == "id").Value); // attach account to context on successful jwt validation context.Items["Account"] = await dataContext.Accounts.FindAsync(accountId); } catch { // do nothing if jwt validation fails // account is not attached to context so request won't have access to secure routes } }
public BasicAuthenticationHandler( IOptionsMonitor <AuthenticationSchemeOptions> options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock, IUserService userService, ApiDBContext context) : base(options, logger, encoder, clock) { _userService = userService; _context = context; }
public AccountService( ApiDBContext context, IMapper mapper, IOptions <AppSettings> appSettings, IEmailService emailService) { _context = context; _mapper = mapper; _appSettings = appSettings.Value; _emailService = emailService; }
public async Task Invoke(HttpContext context, ApiDBContext dataContext) { var token = context.Request.Headers["Authorization"].FirstOrDefault()?.Split(" ").Last(); if (token != null) { await attachAccountToContext(context, dataContext, token); } await _next(context); }
public CursoRepository(ApiDBContext context) : base(context) { }
public StudentController() { this._db = new ApiDBContext(); }
public CompanyRepository(ApiDBContext context, ICompanyAuditRepository companyAuditRepository) : base(context) { _companyAuditRepository = companyAuditRepository; }
public AlunoRepository(ApiDBContext context) : base(context) { }
public ClassController() { this._db = new ApiDBContext(); }
public BillController(ApiDBContext context) { _db = context; }
public MantenimientoService(ApiDBContext _apiDBContext) { apiDBContext = _apiDBContext; }
public BsRolPermiso(ApiDBContext context) { this.context = context ?? throw new ArgumentNullException(nameof(context)); }
public ApiService(ApiDBContext apiDBContext) { _apiDBContext = apiDBContext; }
public LopsController() { this._db = new ApiDBContext(); }
public PayScheduleController(ApiDBContext context) { _db = context; }
public TasksContext(ApiDBContext context) { _context = context; }
public MeasurementService(ApiDBContext context) { _context = context; }
public AddressRepository(ApiDBContext context) : base(context) { }
public BankAccountRepository(ApiDBContext context) : base(context) { }
public VehicleService(ApiDBContext context) { _context = context; }
public SqlRevisaoRepository(ApiDBContext context) { _context = context; }
public CompanyAuditRepository(ApiDBContext context) : base(context) { }
public TurmaService(ApiDBContext context) { _context = context; }
public TodoItemsController(ApiDBContext context) { _context = context; }
public ConsultasService(ApiDBContext _apiDBContext) { apiDBContext = _apiDBContext; }
public UsuarioRepository(ApiDBContext context) : base(context) { }
public SqlFabricanteRepository(ApiDBContext context) { _context = context; }
protected BaseRepository(ApiDBContext context) { _context = context; }
public SinhViensController() { this._db = new ApiDBContext(); }