예제 #1
0
        public ActionResult <AccessTokenDTO> Attest(
            [FromQuery] Attestation attestation,
            [FromServices] IInvalidatedTokenCache invalidatedCache)
        {
            if (authenticationOptions.Mechanism != userContext.AuthenticationMechanism)
            {
                return(StatusCode(StatusCodes.Status401Unauthorized));
            }

            try
            {
                if (invalidatedCache.IsInvalidated(userContext.IdNonce))
                {
                    logger.LogWarning("Id token is invalidated. 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));
            }
        }
예제 #2
0
 public BackgroundInvalidatedTokenSynchronizer(
     IInvalidatedTokenCache cache,
     IInvalidatedTokenService tokenInvalidatedService,
     ILogger <BackgroundInvalidatedTokenSynchronizer> logger)
 {
     this.cache = cache;
     this.tokenInvalidatedService = tokenInvalidatedService;
     this.logger = logger;
 }
예제 #3
0
 public TokenInvalidatedService(IOptions <AppDbOptions> dbOpts, IInvalidatedTokenCache invalidatedCache)
 {
     opts = dbOpts.Value;
     this.invalidatedCache = invalidatedCache;
 }
 public InvalidatedTokenMiddleware(RequestDelegate next, IInvalidatedTokenCache cache, ILogger <InvalidatedTokenMiddleware> logger)
 {
     this.next   = next;
     this.cache  = cache;
     this.logger = logger;
 }