Esempio 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
                }));
            });
        }
Esempio n. 3
0
 public EndpointTokensProvider(IContentManager contentManager, ITokenEncoder tokenEncoder)
     : base(contentManager, tokenEncoder)
 {
 }
Esempio n. 4
0
 public EntityFieldTokensProvider(IContentManager contentManager, ITokenEncoder tokenEncoder)
     : base(contentManager, tokenEncoder)
 {
 }
Esempio n. 5
0
 public JwtTokenValidator(ITokenEncoder tokenGenerator, IQueryProcessor queryProcessor)
 {
     this.tokenGenerator = tokenGenerator;
     this.queryProcessor = queryProcessor;
 }
Esempio n. 6
0
 public EntityDefinitionTokensProvider(IContentManager contentManager, ITokenEncoder tokenEncoder)
     : base(contentManager, tokenEncoder)
 {
 }
Esempio n. 7
0
 public TokenAlgorithm(TokenHashSettings settings, ITokenEncoder backpack)
 {
     _settings = settings ?? TokenHashSettings.SHA256;
     _backpack = backpack ?? throw new ArgumentNullException(nameof(backpack));
 }
Esempio n. 8
0
 public AuthenticateService(IUnitOfWork uow, IMediator bus, INotificationHandler <DomainNotification> notifications, IUserRepository userRepository, ITokenEncoder tokenEncoder) : base(uow, bus, notifications)
 {
     _userRepository = userRepository;
     _tokenEncoder   = tokenEncoder;
 }
Esempio n. 9
0
 public ErrorResultTokensProvider(IContentManager contentManager, ITokenEncoder tokenEncoder)
     : base(contentManager, tokenEncoder)
 {
 }