예제 #1
0
        public UserRepository(ICompanyRepository companyRepository, IOptions <AppSettings> appSettings,
                              ApiDBContext context) : base(context)

        {
            _companyRepository = companyRepository;
            _appSettings       = appSettings.Value;
        }
예제 #2
0
        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
            }
        }
예제 #3
0
 public BasicAuthenticationHandler(
     IOptionsMonitor <AuthenticationSchemeOptions> options,
     ILoggerFactory logger,
     UrlEncoder encoder,
     ISystemClock clock,
     IUserService userService, ApiDBContext context)
     : base(options, logger, encoder, clock)
 {
     _userService = userService;
     _context     = context;
 }
예제 #4
0
 public AccountService(
     ApiDBContext context,
     IMapper mapper,
     IOptions <AppSettings> appSettings,
     IEmailService emailService)
 {
     _context      = context;
     _mapper       = mapper;
     _appSettings  = appSettings.Value;
     _emailService = emailService;
 }
예제 #5
0
        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);
        }
예제 #6
0
 public CursoRepository(ApiDBContext context) : base(context)
 {
 }
예제 #7
0
 public StudentController()
 {
     this._db = new ApiDBContext();
 }
예제 #8
0
 public CompanyRepository(ApiDBContext context,
                          ICompanyAuditRepository companyAuditRepository) : base(context)
 {
     _companyAuditRepository = companyAuditRepository;
 }
예제 #9
0
 public AlunoRepository(ApiDBContext context) : base(context)
 {
 }
예제 #10
0
 public ClassController()
 {
     this._db = new ApiDBContext();
 }
예제 #11
0
 public BillController(ApiDBContext context)
 {
     _db = context;
 }
예제 #12
0
 public MantenimientoService(ApiDBContext _apiDBContext)
 {
     apiDBContext = _apiDBContext;
 }
예제 #13
0
 public BsRolPermiso(ApiDBContext context)
 {
     this.context = context ?? throw new ArgumentNullException(nameof(context));
 }
예제 #14
0
 public ApiService(ApiDBContext apiDBContext)
 {
     _apiDBContext = apiDBContext;
 }
 public LopsController()
 {
     this._db = new ApiDBContext();
 }
예제 #16
0
 public PayScheduleController(ApiDBContext context)
 {
     _db = context;
 }
예제 #17
0
 public TasksContext(ApiDBContext context)
 {
     _context = context;
 }
예제 #18
0
 public MeasurementService(ApiDBContext context)
 {
     _context = context;
 }
 public AddressRepository(ApiDBContext context) : base(context)
 {
 }
예제 #20
0
 public BankAccountRepository(ApiDBContext context) : base(context)
 {
 }
예제 #21
0
 public VehicleService(ApiDBContext context)
 {
     _context = context;
 }
예제 #22
0
 public SqlRevisaoRepository(ApiDBContext context)
 {
     _context = context;
 }
예제 #23
0
 public CompanyAuditRepository(ApiDBContext context) : base(context)
 {
 }
예제 #24
0
 public TurmaService(ApiDBContext context)
 {
     _context = context;
 }
 public TodoItemsController(ApiDBContext context)
 {
     _context = context;
 }
예제 #26
0
 public ConsultasService(ApiDBContext _apiDBContext)
 {
     apiDBContext = _apiDBContext;
 }
 public UsuarioRepository(ApiDBContext context) : base(context)
 {
 }
예제 #28
0
 public SqlFabricanteRepository(ApiDBContext context)
 {
     _context = context;
 }
 protected BaseRepository(ApiDBContext context)
 {
     _context = context;
 }
 public SinhViensController()
 {
     this._db = new ApiDBContext();
 }