Beispiel #1
0
        public async Task InvokeAsync(HttpContext httpContext, IAutenticacaoService autenticacaoService)
        {
            //esta atribuição é feita aqui e não no construtor,
            //pelo fato de o Middleware ser singleton e o autenticacao service ser scoped.
            _autenticacaoService = autenticacaoService;

            try
            {
                await _next(httpContext);
            }
            catch (CustomHttpResponseException ex)
            {
                HandleRequestExceptionAsync(httpContext, ex.StatusCode);
            }
            catch (ValidationApiException ex)
            {
                HandleRequestExceptionAsync(httpContext, ex.StatusCode);
            }
            catch (ApiException ex)
            {
                HandleRequestExceptionAsync(httpContext, ex.StatusCode);
            }
            catch (BrokenCircuitException)
            {
                HandleCircuitBreakerExceptionAsync(httpContext);
            }
        }
Beispiel #2
0
 public AutenticarUsuarioCommandHandler(IAutenticacaoService autenticacaoService, IUsuarioRepository repository, IUsuarioCoreSSORepositorio repositoryCoreSSO, IMediator mediator)
 {
     _autenticacaoService = autenticacaoService;
     _repositoryCoreSSO   = repositoryCoreSSO;
     this.mediator        = mediator ?? throw new ArgumentNullException(nameof(mediator));
     _repository          = repository;
 }
 public MeuPerfilViewModel()
 {
     applicationService  = DependencyService.Get <IApplicationService>();
     autenticacaoService = DependencyService.Get <IAutenticacaoService>();
     cacheService        = DependencyService.Get <ICacheService>();
     usuarioService      = DependencyService.Get <IUsuarioService>();
 }
Beispiel #4
0
 public async Task InvokeAsync(HttpContext httpContext, IAutenticacaoService autenticacaoService)
 {
     _autenticacaoService = autenticacaoService;
     //as requisiçoes passa por esse metodo, se der erro ele trata se não continua
     try
     {
         await _next(httpContext);
     }
     catch (CustomHttpRequestException ex)
     {
         HandleRequestExceptionAsync(httpContext, ex.StatusCode);
     }
     catch (ValidationApiException ex)
     {
         HandleRequestExceptionAsync(httpContext, ex.StatusCode);
     }
     catch (ApiException ex)
     {
         HandleRequestExceptionAsync(httpContext, ex.StatusCode);
     }
     catch (BrokenCircuitException)
     {
         HandleCircuitBreakerExceptionAsync(httpContext);
     }
 }
 public IdentidadeController(
     IAutenticacaoService autenticacaoService,
     IAuthenticationService autenticacaoServiceCore,
     IUser user)
 {
     _autenticacaoService = autenticacaoService;
 }
Beispiel #6
0
        public async Task InvokeAsync(HttpContext httpContext, IAutenticacaoService autenticacaoService)
        {
            _authenticacaoService = autenticacaoService;
            try
            {
                await _next(httpContext);
            }
            catch (CustomHttpResponseException ex)
            {
                HandleRequestExcepitionAsync(httpContext, ex.StatusCode);
            }
            catch (BrokenCircuitException)
            {
                HandleCircuitBreackertExcepitionAsync(httpContext);
            }
            catch (RpcException ex)
            {
                //400 Bad Request	    INTERNAL
                //401 Unauthorized      UNAUTHENTICATED
                //403 Forbidden         PERMISSION_DENIED
                //404 Not Found         UNIMPLEMENTED

                var statusCode = ex.StatusCode switch
                {
                    StatusCode.Internal => 400,
                    StatusCode.Unauthenticated => 401,
                    StatusCode.PermissionDenied => 403,
                    StatusCode.Unimplemented => 404,
                    _ => 500
                };

                var httpStatusCode = (HttpStatusCode)Enum.Parse(typeof(HttpStatusCode), statusCode.ToString());
                HandleRequestExcepitionAsync(httpContext, httpStatusCode);
            }
        }
 public RevendedorService(IAutenticacaoService autenticacaoService, IRevendedorRepository revendedorRepository,
                          ICashBackClient cashBackClient, ILogger <RevendedorService> logger)
 {
     _autenticacaoService  = autenticacaoService;
     _revendedorRepository = revendedorRepository;
     _cashBackClient       = cashBackClient;
     _logger = logger;
 }
 public DiretoriaRegionalEducacaoController(IAutenticacaoService autenticacaoService,
                                            IDiretoriaRegionalEducacaoService dreService,
                                            ILogService logService)
 {
     this.autenticacaoService = autenticacaoService;
     this.dreService          = dreService;
     this.logService          = logService;
 }
Beispiel #9
0
 public RegistroPageViewModel(INavigationService navigationService,
                              IPageDialogService pageDialogService,
                              IAutenticacaoService autenticacao)
 {
     _navigationService = navigationService;
     _pageDialogService = pageDialogService;
     _autenticacao      = autenticacao;
 }
Beispiel #10
0
 public EscolaController(IAutenticacaoService autenticacaoService,
                         IEscolaService escolaService,
                         ILogService logService)
 {
     this.autenticacaoService = autenticacaoService;
     this.escolaService       = escolaService;
     this.logService          = logService;
 }
Beispiel #11
0
        public AutenticacaoController(ILoggerFactory loggerFactory,
                                      IAutenticacaoService autenticacaoService)
        {
            logger = loggerFactory?.CreateLogger <AutenticacaoController>() ??
                     throw new ArgumentNullException(nameof(loggerFactory));

            this.autenticacaoService = autenticacaoService ??
                                       throw new ArgumentNullException(nameof(autenticacaoService));
        }
Beispiel #12
0
        public LoginPageViewModel(INavigationService navigationService,
                                  IPageDialogService pageDialogService,
                                  IAutenticacaoService autenticacao)
        {
            _navigationService = navigationService;
            _pageDialogService = pageDialogService;
            _autenticacao      = autenticacao;

            OnLoginCommand = new DelegateCommand(DoLogin).ObservesCanExecute(() => AllFieldsAreValid);
        }
Beispiel #13
0
        public async Task <IActionResult> VerificaAutorizacao([FromServices] IAutenticacaoService autenticacaoService, string email, string nome)
        {
            try
            {
                // TODO: Incluir o cliente no banco de dados
                await autenticacaoService.CriarAutenticacao(email, nome);
            }
            catch (Exception e)
            {
                return(UnprocessableEntity(e.Message));
            }

            return(Ok());
        }
Beispiel #14
0
        public async Task InvokeAsync(HttpContext httpContext, IAutenticacaoService autenticacaoService)
        {
            _autenticacaoService = autenticacaoService;

            if (_autenticacaoService.TokenExpirados())
            {
                if (_autenticacaoService.RefreshTokenValido().Result)
                {
                    httpContext.Response.Redirect(httpContext.Request.Path);
                }
            }

            await _next(httpContext);
        }
Beispiel #15
0
 public CheckoutService(
     ICarrinhoRepository carrinhoRepository,
     IFreteRepository freteRepository,
     IAutenticacaoService autenticacaoService,
     IPagamentoService pagamentoService,
     IMensageriaService mensageriaService,
     ILoggerService loggerService)
 {
     _carrinhoRepository  = carrinhoRepository;
     _freteRepository     = freteRepository;
     _autenticacaoService = autenticacaoService;
     _pagamentoService    = pagamentoService;
     _mensageriaService   = mensageriaService;
     _loggerService       = loggerService;
 }
        public async Task InvokeAsync(HttpContext httpContext, IAutenticacaoService autenticacaoService)
        {
            _autenticacaoService = autenticacaoService;

            try
            {
                await _next(httpContext);
            }
            catch (CustomHttpResponseException ex)
            {
                HandleRequestExpectionAsync(httpContext, ex.StatusCode);
            }
            catch (ValidationApiException ex)
            {
                HandleRequestExpectionAsync(httpContext, ex.StatusCode);
            }
            catch (ApiException ex)
            {
                HandleRequestExpectionAsync(httpContext, ex.StatusCode);
            }
            catch (BrokenCircuitException)
            {
                HandleCircuitBreakerExceptionAsync(httpContext);
            }
            catch (RpcException ex)
            {
                var statusCode = ex.StatusCode switch
                {
                    StatusCode.Internal => 400,
                    StatusCode.Unauthenticated => 401,
                    StatusCode.PermissionDenied => 403,
                    StatusCode.Unimplemented => 404,
                    _ => 500
                };

                var httpStatusCode = Enum.Parse <HttpStatusCode>(statusCode.ToString());


                HandleRequestExpectionAsync(httpContext, httpStatusCode);
            }
        }
 public ProdutoController(IProdutoService produtoService,
                          IAutenticacaoService autenticacaoService)
 {
     this._autenticacaoService = autenticacaoService;
     this._produtoService      = produtoService;
 }
Beispiel #18
0
 public IdentidadeController(IAutenticacaoService autenticacaoServices)
 {
     _autenticacaoServices = autenticacaoServices;
 }
Beispiel #19
0
 public ServicoPrestadoController(IServicoPrestadoService servPrestService,
                                  IAutenticacaoService autenticacaoService)
 {
     this._autenticacaoService = autenticacaoService;
     this._servPrestService    = servPrestService;
 }
Beispiel #20
0
 public ContratoParcelaController(IContratoParcelaService contParcService,
                                  IAutenticacaoService autenticacaoService)
 {
     this._autenticacaoService = autenticacaoService;
     this._contParcService     = contParcService;
 }
 public HomeController(IAutenticacaoService _client)
 {
     client = _client;
 }
Beispiel #22
0
 public PagamentoComissaoController(IPagamentoComissaoService pgtoComissService,
                                    IAutenticacaoService autenticacaoService)
 {
     this._autenticacaoService = autenticacaoService;
     this._pgtoComissService   = pgtoComissService;
 }
Beispiel #23
0
 public IdentidadeController(IAutenticacaoService autenticationService)
 {
     _autenticacaoService = autenticationService;
 }
 public UsuarioController(IUsuarioService usuarioService,
                          IAutenticacaoService autenticacaoService)
 {
     this._autenticacaoService = autenticacaoService;
     this._usuarioService      = usuarioService;
 }
 public AutenticacaoController(IServiceProvider serviceProvider, IAutenticacaoService autenticacaoService) : base(serviceProvider)
 {
     _autenticacaoService = autenticacaoService;
 }
Beispiel #26
0
 public AutenticacaoAppService(IAutenticacaoService autenticacaoService, IMapper mapper)
 {
     _autenticacaoService = autenticacaoService;
     _mapper = mapper;
 }
        public object Post(
            [FromBody] Usuario usuario,
            [FromServices] IAutenticacaoService autenticacaoService,
            [FromServices] SigningConfigurations signingConfigurations,
            [FromServices] TokenConfigurations tokenConfigurations)
        {
            bool    credenciaisValidas = false;
            Usuario usuarioBase        = null;

            if (usuario != null && !String.IsNullOrWhiteSpace(usuario.Email))
            {
                usuarioBase        = autenticacaoService.Entity().Where(user => user.Email == usuario.Email).Single();
                credenciaisValidas = (usuarioBase != null &&
                                      usuario.Email == usuarioBase.Email &&
                                      usuario.Senha == usuarioBase.Senha);
            }

            if (credenciaisValidas)
            {
                if (Session.IsUsuarioLogado(usuario.Email))
                {
                    return(new
                    {
                        authenticated = false,
                        message = "Usuário logado"
                    });
                }

                ClaimsIdentity identity = new ClaimsIdentity(
                    new GenericIdentity(usuario.Email, "Email"),
                    new[] {
                    new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString("N")),
                    new Claim(JwtRegisteredClaimNames.UniqueName, usuario.Email)
                }
                    );

                DateTime dataCriacao   = DateTime.Now;
                DateTime dataExpiracao = dataCriacao +
                                         TimeSpan.FromSeconds(tokenConfigurations.Seconds);

                var handler       = new JwtSecurityTokenHandler();
                var securityToken = handler.CreateToken(new SecurityTokenDescriptor
                {
                    Issuer             = tokenConfigurations.Issuer,
                    Audience           = tokenConfigurations.Audience,
                    SigningCredentials = signingConfigurations.SigningCredentials,
                    Subject            = identity,
                    NotBefore          = dataCriacao,
                    Expires            = dataExpiracao
                });
                var token = handler.WriteToken(securityToken);

                return(new
                {
                    authenticated = true,
                    created = dataCriacao.ToString("yyyy-MM-dd HH:mm:ss"),
                    expiration = dataExpiracao.ToString("yyyy-MM-dd HH:mm:ss"),
                    accessToken = token,
                    message = "OK",
                    IdUsuario = usuarioBase.Id
                });
            }
            else
            {
                return(new
                {
                    authenticated = false,
                    message = "Email ou senha inválidos"
                });
            }
        }
Beispiel #28
0
 public ContratoServicoController(IContratoServicoService contService,
                                  IAutenticacaoService autenticacaoService)
 {
     this._autenticacaoService = autenticacaoService;
     this._contService         = contService;
 }
Beispiel #29
0
 public AutenticacaoController(IAutenticacaoService autenticacaoService) => _autenticacaoService = autenticacaoService;
Beispiel #30
0
 public ContaPagarParcelaPagamentoController(IContaPagarParcelaPagamentoService contPgParcPagService,
                                             IAutenticacaoService autenticacaoService)
 {
     this._autenticacaoService  = autenticacaoService;
     this._contPgParcPagService = contPgParcPagService;
 }