public async Task GivenCreatingToken_SignItWithHmacSecret(string hmacSecret)
        {
            Environment.SetEnvironmentVariable("HmacSecret", hmacSecret);
            IAccessToken token = await _accessTokenCreator.CreateAsync("*****@*****.**", CancellationToken.None);

            Assert.DoesNotThrow(() => ValidateTokenWithSecret(token, hmacSecret));
        }
Beispiel #2
0
        public async Task <GetAccessTokenResponse> ExecuteAsync(GetAccessTokenRequest tokenRequest,
                                                                CancellationToken cancellationToken)
        {
            IAuthenticationToken token = await _tokenReader.ReadAsync(tokenRequest.Token, cancellationToken);

            if (NoMatchingTokenIsFound(token) || TokenHasExpired(token))
            {
                return(UnauthorisedResponse());
            }

            IAccessToken accessToken = await _accessTokenCreator.CreateAsync(token.EmailAddress, cancellationToken);

            await _tokenDeleter.DeleteAsync(tokenRequest.Token, cancellationToken);

            return(AuthorisedResponse(accessToken));
        }