public async Task InitializeAsync(string token)
        {
            if (token.Empty())
            {
                await DisconnectAsync();
            }
            JwtDetails jwt = null;

            try
            {
                var maybeJwt = _jwtHandler.Parse(token);
                if (maybeJwt.HasNoValue)
                {
                    await DisconnectAsync();

                    return;
                }
                jwt = maybeJwt.Value;
            }
            catch
            {
                await DisconnectAsync();

                return;
            }
            await Groups.AddAsync(Context.ConnectionId, jwt.Subject);
        }
 public AuthenticationService(SignInManager <ApplicationUser> signInManager, UserManager <ApplicationUser> userManager, JwtDetails jwtDetails, RoleManager <IdentityRole> roleManager, IHttpContextAccessor httpContextAccessor)
 {
     _signInManager       = signInManager;
     _userManager         = userManager;
     _jwtDetails          = jwtDetails;
     _roleManager         = roleManager;
     _httpContextAccessor = httpContextAccessor;
 }
예제 #3
0
        public static INeverEmptyPantryBuilder AddJwtDetails(this INeverEmptyPantryBuilder builder)
        {
            var jwtDetails = new JwtDetails();

            builder.Configuration.GetSection("JwtDetails").Bind(jwtDetails);
            builder.Services.AddSingleton(jwtDetails);
            builder.JwtDetails = jwtDetails;

            return(builder);
        }
 public AuthenticateService(IOptions <JwtDetails> jwtDetails, IHttpContextAccessor httpContextAccessor)
 {
     _jwtDetails          = jwtDetails.Value;
     _httpContextAccessor = httpContextAccessor;
 }