public AuthenticationService(IHttpContextProvider context) { if (context == null) { throw new ArgumentNullException("context"); } this.context = context.Get(); }
private void Init(IHttpContextProvider contextProvider) { if (contextProvider == null) { throw new ArgumentNullException("contextProvider"); } this.contextProvider = contextProvider; context = contextProvider.Get(); }
public UserInfo GetAuthInfo() { var currentContext = _httpContextProvider.Get(); var currentPrincipal = currentContext.User; if (currentPrincipal == null) { throw new InvalidOperationException("Current user principal is not defined."); } var jwtClaimsModel = JwtClaimsModel.Parse(currentPrincipal); return(jwtClaimsModel.GetUserInfo()); }
public AuthSession Authorize(UserAuthData userAuthData) { if (userAuthData == null) { throw new ArgumentNullException(nameof(userAuthData)); } var jwtToken = _jwtTokenProvider.GetToken(userAuthData); _httpContextProvider .Get() .Response .Headers .Add(_jwtHttpSettings.HeaderName, jwtToken.TokenValue); return(new AuthSession(jwtToken.TokenId)); }