public JwtTokenBl(IUserRefreshTokenRepository <UserRefreshToken, int> refreshRepository, IUserBl userBl, IAccountBl accountBl, IConfiguration configuration) { this.refreshRepository = refreshRepository; this.userBl = userBl; this.accountBl = accountBl; this.configuration = configuration; }
public JwtTokenServiceTests() { // This token is from jwt.io, the format: // token = base64urlEncoding(header) + '.' + base64urlEncoding(payload) + '.' + base64urlEncoding(signature) string exampleJwtToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"; var securityToken = new JwtSecurityToken(exampleJwtToken); _tokenHandler = Substitute.For <SecurityTokenHandler>(); _tokenHandler .CreateToken(Arg.Any <SecurityTokenDescriptor>()) .Returns(securityToken); _tokenHandler .WriteToken(securityToken) .Returns("the jwt token"); _jwtSettings = new JwtSettings() { Password = "******", ExpiresDays = 10 }; _refreshTokenRepository = Substitute.For <IUserRefreshTokenRepository>(); _service = new JwtTokenService(_jwtSettings, _tokenHandler, _refreshTokenRepository); }
public JwtService(IUserRefreshTokenRepository refreshRepository, IProfileService profileService, IUserAuthService userService, IConfiguration configuration) { this.refreshRepository = refreshRepository; this.profileService = profileService; this.userService = userService; this.configuration = configuration; }
public JwtService(IConfiguration config, IUserRefreshTokenRepository context) { _secret = config.GetSection("JwtConfig").GetSection("secret").Value; _secret2 = config.GetSection("JwtConfig").GetSection("secret2").Value; _expDate = config.GetSection("JwtConfig").GetSection("expirationInHours").Value; _expMonth = config.GetSection("JwtConfig").GetSection("expirationInMonths").Value; _context = context; }
/// <summary> /// Create new instance. /// </summary> public TokenService(IOptions <JwtConfiguration> options, IUserRefreshTokenRepository userRefreshTokenRepository) { _options = options?.Value ?? throw new ArgumentNullException(nameof(options)); _userRefreshTokenRepository = userRefreshTokenRepository ?? throw new ArgumentNullException(nameof(userRefreshTokenRepository)); signingKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_options.SignatureKey)); signingCredentials = new SigningCredentials(signingKey, SecurityAlgorithms.HmacSha256); }
public JwtTokenService( JwtSettings jwtSettings, SecurityTokenHandler tokenHandler, IUserRefreshTokenRepository refreshTokenRepository) { _jwtSettings = jwtSettings; _tokenHandler = tokenHandler; _refreshTokenRepository = refreshTokenRepository; }
public AdminService(IReportRepository reportRepository, IUserRepository userRepository, IUserChatRoomRepository userChatRoomRepository , IUserRefreshTokenRepository userRefreshTokenRepository, IChatRoomRepository chatRoomRepository, IMessageRepository messageRepository) { _reportRepository = reportRepository; _userRepository = userRepository; _userChatRoomRepository = userChatRoomRepository; _userRefreshTokenRepository = userRefreshTokenRepository; _chatRoomRepository = chatRoomRepository; _messageRepository = messageRepository; }
public UserService(IUserRepository userService, IUserRefreshTokenRepository tokenService, ICityRepository cityRepository, IJwtService jwtService, IOptions <JwtConfig> JwtConfig, IReportRepository reportRepository, ICountryRepository countryRepository) { _userService = userService; _tokenService = tokenService; _jwtService = jwtService; _JwtConfig = JwtConfig.Value; _reportRepository = reportRepository; _cityRepository = cityRepository; _countryRepository = countryRepository; }
public JwtTokenService( JwtSettings jwtSettings, SecurityTokenHandler tokenHandler, IUserRefreshTokenRepository refreshTokenRepository, TokenValidationParameters tokenValidationParameters) { _jwtSettings = jwtSettings; _tokenHandler = tokenHandler; _refreshTokenRepository = refreshTokenRepository; _tokenValidationParameters = tokenValidationParameters; }
public JwtTokenServiceTests() { // This token is from jwt.io, the format: // token = base64urlEncoding(header) + '.' + base64urlEncoding(payload) + '.' + base64urlEncoding(signature) string exampleJwtToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"; var securityToken = new JwtSecurityToken(exampleJwtToken); _tokenHandler = Substitute.For <SecurityTokenHandler>(); _tokenHandler .CreateToken(Arg.Any <SecurityTokenDescriptor>()) .Returns(securityToken); _tokenHandler .WriteToken(securityToken) .Returns(_fakeJwtToken); _jwtSettings = new JwtSettings() { Password = "******", JwtExpiresMinutes = 5, RefreshTokenExpiresDays = _refreshTokenExpiresDays }; _jwtTokenValidationParameters = new TokenValidationParameters { ValidateIssuerSigningKey = true, IssuerSigningKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(_jwtSettings.Password)), ValidateIssuer = false, ValidateAudience = false, RequireExpirationTime = false, ValidateLifetime = true }; _refreshTokenRepository = Substitute.For <IUserRefreshTokenRepository>(); _service = new JwtTokenService(_jwtSettings, _tokenHandler, _refreshTokenRepository, _jwtTokenValidationParameters); }
public UnitOfWork(ApplicationDbContext db) { _db = db; UserRefreshTokenRepository = new UserRefreshTokenRepository(_db); }
public UserRefreshTokenService(IUserRefreshTokenRepository userRefreshTokenRepository) { this.userRefreshTokenRepository = userRefreshTokenRepository; }
public UserRefreshTokenService(IContextProvider contextProvider) { RefreshTokenRepository = contextProvider.GetRepository <IUserRefreshTokenRepository>(); }
public LoginController(IConfiguration configuration, IUserRefreshTokenRepository userRefreshTokenRepository) { _configuration = configuration; _userRefreshTokenRepository = userRefreshTokenRepository; }
/// <summary> /// 构造函数 实现依赖注入 /// </summary> /// <param name="userRepository">仓储对象</param> public UserAppService(IUserRepository userRepository, IUserRefreshTokenRepository RefreshTokenRepository, IMenuRepository menuRepository) { _userReporitory = userRepository; _RefreshTokenRepository = RefreshTokenRepository; _menuRepository = menuRepository; }