Ejemplo n.º 1
0
        public DocumentationTokensProvider(IContentManager contentManager, ITokenEncoder tokenEncoder)
        {
            _contentManager = contentManager;
            _tokenEncoder   = tokenEncoder;

            T = NullLocalizer.Instance;
        }
        public AuthenticationModule(
            ICommandSender commandSender,
            ITokenEncoder tokenEncoder,
            IQueryProcessor queryProcessor)
        {
            Post("/api/register", async _ => {
                var command = this.Bind <RegisterUserCommand>();
                await commandSender.Send(command);
                var token = new JwtPayload(command.UserId);
                return(Negotiate
                       .WithStatusCode(HttpStatusCode.OK)
                       .WithModel(new {
                    token = tokenEncoder.Encode(token),
                    expire = token.Expire
                }));
            });

            Post("/api/login", async _ => {
                var userId = this.Request.Form.UserId;
                if (string.IsNullOrEmpty(userId))
                {
                    return(Negotiate.WithStatusCode(HttpStatusCode.Unauthorized));
                }
                var user = await queryProcessor.Query(new FindUserQuery(userId));
                if (user == null)
                {
                    return(Negotiate.WithStatusCode(HttpStatusCode.Unauthorized));
                }
                var token = new JwtPayload(userId);
                return(Negotiate
                       .WithStatusCode(HttpStatusCode.OK)
                       .WithModel(new {
                    token = tokenEncoder.Encode(token),
                    expire = token.Expire
                }));
            });
        }
Ejemplo n.º 3
0
 public EndpointTokensProvider(IContentManager contentManager, ITokenEncoder tokenEncoder)
     : base(contentManager, tokenEncoder)
 {
 }
Ejemplo n.º 4
0
 public EntityFieldTokensProvider(IContentManager contentManager, ITokenEncoder tokenEncoder)
     : base(contentManager, tokenEncoder)
 {
 }
Ejemplo n.º 5
0
 public JwtTokenValidator(ITokenEncoder tokenGenerator, IQueryProcessor queryProcessor)
 {
     this.tokenGenerator = tokenGenerator;
     this.queryProcessor = queryProcessor;
 }
Ejemplo n.º 6
0
 public EntityDefinitionTokensProvider(IContentManager contentManager, ITokenEncoder tokenEncoder)
     : base(contentManager, tokenEncoder)
 {
 }
Ejemplo n.º 7
0
 public TokenAlgorithm(TokenHashSettings settings, ITokenEncoder backpack)
 {
     _settings = settings ?? TokenHashSettings.SHA256;
     _backpack = backpack ?? throw new ArgumentNullException(nameof(backpack));
 }
Ejemplo n.º 8
0
 public AuthenticateService(IUnitOfWork uow, IMediator bus, INotificationHandler <DomainNotification> notifications, IUserRepository userRepository, ITokenEncoder tokenEncoder) : base(uow, bus, notifications)
 {
     _userRepository = userRepository;
     _tokenEncoder   = tokenEncoder;
 }
Ejemplo n.º 9
0
 public ErrorResultTokensProvider(IContentManager contentManager, ITokenEncoder tokenEncoder)
     : base(contentManager, tokenEncoder)
 {
 }