コード例 #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);
            }
        }
コード例 #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;
 }
コード例 #3
0
 public MeuPerfilViewModel()
 {
     applicationService  = DependencyService.Get <IApplicationService>();
     autenticacaoService = DependencyService.Get <IAutenticacaoService>();
     cacheService        = DependencyService.Get <ICacheService>();
     usuarioService      = DependencyService.Get <IUsuarioService>();
 }
コード例 #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);
     }
 }
コード例 #5
0
 public IdentidadeController(
     IAutenticacaoService autenticacaoService,
     IAuthenticationService autenticacaoServiceCore,
     IUser user)
 {
     _autenticacaoService = autenticacaoService;
 }
コード例 #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);
            }
        }
コード例 #7
0
 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;
 }
コード例 #9
0
 public RegistroPageViewModel(INavigationService navigationService,
                              IPageDialogService pageDialogService,
                              IAutenticacaoService autenticacao)
 {
     _navigationService = navigationService;
     _pageDialogService = pageDialogService;
     _autenticacao      = autenticacao;
 }
コード例 #10
0
 public EscolaController(IAutenticacaoService autenticacaoService,
                         IEscolaService escolaService,
                         ILogService logService)
 {
     this.autenticacaoService = autenticacaoService;
     this.escolaService       = escolaService;
     this.logService          = logService;
 }
コード例 #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));
        }
コード例 #12
0
        public LoginPageViewModel(INavigationService navigationService,
                                  IPageDialogService pageDialogService,
                                  IAutenticacaoService autenticacao)
        {
            _navigationService = navigationService;
            _pageDialogService = pageDialogService;
            _autenticacao      = autenticacao;

            OnLoginCommand = new DelegateCommand(DoLogin).ObservesCanExecute(() => AllFieldsAreValid);
        }
コード例 #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());
        }
コード例 #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);
        }
コード例 #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;
 }
コード例 #16
0
        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);
            }
        }
コード例 #17
0
 public ProdutoController(IProdutoService produtoService,
                          IAutenticacaoService autenticacaoService)
 {
     this._autenticacaoService = autenticacaoService;
     this._produtoService      = produtoService;
 }
コード例 #18
0
 public IdentidadeController(IAutenticacaoService autenticacaoServices)
 {
     _autenticacaoServices = autenticacaoServices;
 }
コード例 #19
0
 public ServicoPrestadoController(IServicoPrestadoService servPrestService,
                                  IAutenticacaoService autenticacaoService)
 {
     this._autenticacaoService = autenticacaoService;
     this._servPrestService    = servPrestService;
 }
コード例 #20
0
 public ContratoParcelaController(IContratoParcelaService contParcService,
                                  IAutenticacaoService autenticacaoService)
 {
     this._autenticacaoService = autenticacaoService;
     this._contParcService     = contParcService;
 }
コード例 #21
0
 public HomeController(IAutenticacaoService _client)
 {
     client = _client;
 }
コード例 #22
0
 public PagamentoComissaoController(IPagamentoComissaoService pgtoComissService,
                                    IAutenticacaoService autenticacaoService)
 {
     this._autenticacaoService = autenticacaoService;
     this._pgtoComissService   = pgtoComissService;
 }
コード例 #23
0
 public IdentidadeController(IAutenticacaoService autenticationService)
 {
     _autenticacaoService = autenticationService;
 }
コード例 #24
0
 public UsuarioController(IUsuarioService usuarioService,
                          IAutenticacaoService autenticacaoService)
 {
     this._autenticacaoService = autenticacaoService;
     this._usuarioService      = usuarioService;
 }
コード例 #25
0
 public AutenticacaoController(IServiceProvider serviceProvider, IAutenticacaoService autenticacaoService) : base(serviceProvider)
 {
     _autenticacaoService = autenticacaoService;
 }
コード例 #26
0
 public AutenticacaoAppService(IAutenticacaoService autenticacaoService, IMapper mapper)
 {
     _autenticacaoService = autenticacaoService;
     _mapper = mapper;
 }
コード例 #27
0
        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"
                });
            }
        }
コード例 #28
0
 public ContratoServicoController(IContratoServicoService contService,
                                  IAutenticacaoService autenticacaoService)
 {
     this._autenticacaoService = autenticacaoService;
     this._contService         = contService;
 }
コード例 #29
0
 public AutenticacaoController(IAutenticacaoService autenticacaoService) => _autenticacaoService = autenticacaoService;
コード例 #30
0
 public ContaPagarParcelaPagamentoController(IContaPagarParcelaPagamentoService contPgParcPagService,
                                             IAutenticacaoService autenticacaoService)
 {
     this._autenticacaoService  = autenticacaoService;
     this._contPgParcPagService = contPgParcPagService;
 }