Ejemplo n.º 1
0
 public AuthController(IAuthService authService, IJWTSettings jwtSettings, IAccountService accountService, IMasterService masterService)
 {
     _authService    = authService;
     _jwtSettings    = jwtSettings;
     _accountService = accountService;
     _masterService  = masterService;
 }
Ejemplo n.º 2
0
 public AuthController(IAuthService authService,
                       IUserService userService,
                       IJWTSettings jwtSettings)
 {
     _jwtSettings = jwtSettings;
     _authService = authService;
     _userService = userService;
 }
Ejemplo n.º 3
0
 public TokenDecoder(IJWTSettings jwtSettings)
 {
     this.jwtSettings          = jwtSettings;
     this.validationParameters = new TokenValidationParameters
     {
         ValidateIssuerSigningKey = true,
         IssuerSigningKey         = jwtSettings.GetSecurityKey(),
         ValidateIssuer           = false,
         ValidateAudience         = false
     };
 }
Ejemplo n.º 4
0
        private async Task <string> GenerateToken(User user, IJWTSettings jwtSettings)
        {
            var tokenHandler    = new JwtSecurityTokenHandler();
            var key             = Encoding.ASCII.GetBytes(jwtSettings.Key);
            var tokenDescriptor = new SecurityTokenDescriptor {
                Subject = new ClaimsIdentity(new Claim[] {
                    new Claim(ClaimTypes.NameIdentifier, user.Id.ToString()),
                    new Claim(ClaimTypes.Name, user.Email),
                    new Claim(ClaimTypes.Role, user.Role)
                }),
                Issuer             = "",
                Expires            = DateTime.Now.AddDays(jwtSettings.ExpiryDays),
                SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key),
                                                            SecurityAlgorithms.HmacSha512Signature)
            };
            var token = tokenHandler.CreateToken(tokenDescriptor);

            return(await Task.FromResult(tokenHandler.WriteToken(token)));
        }
Ejemplo n.º 5
0
 public JWTService(IJWTSettings jwtSettings)
 {
     _jwtSettings = jwtSettings;
 }
Ejemplo n.º 6
0
 public JWTService(IJWTSettings settings)
 {
     _key    = settings.Key;
     _issuer = settings.Issuer;
 }
Ejemplo n.º 7
0
 public AuthorizationController(IJWTSettings jwtSettings, DiscordService discordService, CampaignSaberContext campaignSaberContext)
 {
     _jwtSettings          = jwtSettings;
     _discordService       = discordService;
     _campaignSaberContext = campaignSaberContext;
 }
Ejemplo n.º 8
0
 public JWTValidator(RequestDelegate next, IJWTSettings jwtSettings)
 {
     _next        = next;
     _jwtSettings = jwtSettings;
 }
Ejemplo n.º 9
0
 public GoogleTokenValidator(IJWTSettings settings)
 {
     this.settings = settings;
 }
Ejemplo n.º 10
0
 public JWTService(IJWTSettings jwtSettings, IJwtDecoder jwtDecoder, IJwtEncoder jwtEncoder)
 {
     _key     = jwtSettings.Key;
     _decoder = jwtDecoder;
     _encoder = jwtEncoder;
 }