public ActionResult <AccessTokenDTO> Attest( [FromQuery] Attestation attestation, [FromServices] ITokenBlacklistCache blacklistCache) { if (authenticationOptions.Mechanism != userContext.AuthenticationMechanism) { return(StatusCode(StatusCodes.Status401Unauthorized)); } try { if (blacklistCache.IsBlacklisted(userContext.IdNonce)) { logger.LogWarning("Id token is blacklisted. IdNonce:{IdNonce} Attestation:{@Attestation}", userContext.IdNonce, attestation); return(StatusCode(StatusCodes.Status401Unauthorized)); } var token = jwtProvider.AccessToken(HttpContext, attestation); logger.LogInformation("Created Access Token. Attestation:{@Attestation} Token:{Token}", attestation, token); return(Ok(new AccessTokenDTO { AccessToken = token })); } catch (Exception e) { logger.LogError("Failed to produce access token. Attestation:{@Attestation} Error:{Error}", attestation, e.ToString()); return(StatusCode(StatusCodes.Status500InternalServerError)); } }
public ActionResult <AccessTokenDTO> Attest( [FromQuery] Attestation attestation, [FromServices] ITokenBlacklistCache blacklistCache) { if (authenticationOptions.Mechanism != userContext.AuthenticationMechanism) { return(StatusCode(StatusCodes.Status401Unauthorized)); } try { if (blacklistCache.IsBlacklisted(userContext.IdNonce)) { return(StatusCode(StatusCodes.Status401Unauthorized)); } var token = jwtProvider.AccessToken(HttpContext, attestation); return(Ok(new AccessTokenDTO { AccessToken = token })); } catch (Exception e) { logger.LogError("Could not produce access token. Error:{Error}", e.ToString()); return(StatusCode(StatusCodes.Status500InternalServerError)); } }
public BackgroundTokenBlacklistSynchronizer( ITokenBlacklistCache cache, ITokenBlacklistService tokenBlacklistService, ILogger <BackgroundTokenBlacklistSynchronizer> logger) { this.cache = cache; this.tokenBlacklistService = tokenBlacklistService; this.logger = logger; }
public TokenBlacklistService(IOptions <AppDbOptions> dbOpts, ITokenBlacklistCache blacklistCache, ILogger <TokenBlacklistService> logger) { opts = dbOpts.Value; this.blacklistCache = blacklistCache; this.logger = logger; }
public TokenBlacklistMiddleware(RequestDelegate next, ITokenBlacklistCache cache, ILogger <TokenBlacklistMiddleware> logger) { this.next = next; this.cache = cache; this.logger = logger; }
public TokenBlacklistService(IOptions <AppDbOptions> dbOpts, ITokenBlacklistCache blacklistCache) { opts = dbOpts.Value; this.blacklistCache = blacklistCache; }