public HalloSecureModule(IWebTokenService webTokenService) : base(webTokenService)
 {
     Get["/secure/hallo"] = _ =>
     {
         return($"Hallo {CurrentLogon.UserName}, deze url wordt beveiligd met een JSON web token");
     };
 }
Esempio n. 2
0
        public AuthModule(
            IAuthenticationService authenticationService,
            IWebTokenService webTokenService,
            ILoggingService loggingService)
        {
            Post["/auth/token"] = _ =>
            {
                var authRequest = this.Bind <AuthenticationRequest>();

                var logon = authenticationService.GetLogonByCredentials(authRequest.Naam, authRequest.Wachtwoord);
                if (logon == null)
                {
                    loggingService.LogMessage("Inloggen mislukt");

                    return(new Response
                    {
                        StatusCode = HttpStatusCode.BadRequest,
                        ReasonPhrase = "Onbekende combinatie van gebruikersnaam en wachtwoord"
                    });
                }

                loggingService.LogMessage("Inloggen gelukt");

                var identity = logon.ToClaimsIdentity();
                var token    = webTokenService.CreateToken(identity);

                return(token);
            };
        }
Esempio n. 3
0
 public AuthService(
     UserManager <AppUser> userManager,
     IMapper mapper,
     IWebTokenService webTokenService,
     IUrlService urlService,
     IEncodingService encodingService,
     IEmailService emailService)
 {
     _userManager     = userManager;
     _mapper          = mapper;
     _webTokenService = webTokenService;
     _urlService      = urlService;
     _encodingService = encodingService;
     _emailService    = emailService;
 }
Esempio n. 4
0
 public SecureModule(IWebTokenService webTokenService)
 {
     this.WebTokenService = webTokenService;
     this.Before         += BeforeResponse;
 }