/// <summary> /// Initializes a new instance of the <see cref="EFormidlingAccessValidator"/> class. /// </summary> public EFormidlingAccessValidator( IAccessTokenValidator validator, ILogger <IEFormidlingAccessValidator> logger) { _validator = validator; _logger = logger; }
/// <summary> /// Creates an <see cref="IRequestAuthenticator"/> instance. /// </summary> public static IRequestAuthenticator Create( IAccessTokenValidator accessTokenValidator ) { IRequestAuthenticator authenticator = new RequestAuthenticator(accessTokenValidator); return(authenticator); }
public SuspendTransfer( ILogger <SuspendTransfer> logger, IAccessTokenValidator accessTokenValidator, ITransfersService transfersService ) : base(logger) { this.accessTokenValidator = accessTokenValidator; this.transfersService = transfersService; }
public void TestFixtureSetUp() { m_authService = new AuthServiceMock( AuthServiceMock.KeyType.ECDSA_P256 ); m_accessTokenValidator = AccessTokenValidatorFactory.CreateRemoteValidator( new HttpClient(), m_authService.Host ); m_authService.SetupJwks().Wait(); }
public async Task TestGetToken_WithTenantAndUserIdAndXsrf_IsValid() { string token = await TestAccessToken.GetToken(DEV_AUTH_URL, Guid.NewGuid().ToString(), "user", "xsrf").SafeAsync(); using (var httpClient = new HttpClient()) { IAccessTokenValidator validator = AccessTokenValidatorFactory.CreateRemoteValidator(httpClient, new Uri(DEV_AUTH_URL)); Assert.DoesNotThrowAsync(async() => await validator.ValidateAsync(token).SafeAsync()); } }
public async Task TestGetToken_WithTenantID_IsValid() { string token = await TestAccessToken.GetToken(DEV_AUTH_URL, Guid.NewGuid().ToString()).ConfigureAwait(false); using (var httpClient = new HttpClient()) { IAccessTokenValidator validator = AccessTokenValidatorFactory.CreateRemoteValidator(httpClient, new Uri(DEV_AUTH_URL), new Uri(DEV_AUTH_JWK_URL)); Assert.DoesNotThrowAsync(async() => await validator.ValidateAsync(token).ConfigureAwait(false)); } }
public NotesApi( NotesDbContext dbContext, IValidator <Note> validator, IAccessTokenValidator accessTokenValidator) { this.dbContext = dbContext ?? throw new ArgumentNullException(nameof(dbContext)); this.validator = validator ?? throw new ArgumentNullException(nameof(validator)); this.accessTokenValidator = accessTokenValidator ?? throw new ArgumentNullException(nameof(accessTokenValidator)); }
private async Task RunTest( string request_authorizationHeader, Type expectedExceptionType = null, PrincipalType?expected_principalType = null ) { IAccessToken token = AccessTokenMock.Create().Object; IAccessTokenValidator tokenValidator = AccessTokenValidatorMock.Create( accessToken: ACCESS_TOKEN, accessTokenAfterValidation: token, expectedExceptionType: expectedExceptionType ).Object; IRequestAuthenticator authenticator = new RequestAuthenticator(tokenValidator); var httpRequestMessage = new HttpRequestMessage() .WithAuthHeader(request_authorizationHeader); ID2LPrincipal principal = null; Exception exception = null; try { principal = await authenticator.AuthenticateAsync( httpRequestMessage ).SafeAsync(); } catch (Exception e) { exception = e; } CheckExpectations( principal, exception, expectedExceptionType, expected_principalType); exception = null; HttpRequest httpRequest = RequestBuilder .Create() .WithAuthHeader(request_authorizationHeader); try { principal = await authenticator.AuthenticateAsync( httpRequest ).SafeAsync(); } catch (Exception e) { exception = e; } CheckExpectations( principal, exception, expectedExceptionType, expected_principalType); }
public async Task TestAccessTokenProvider_TokenIsValid() { using (var httpClient = new HttpClient()) { IAccessTokenProvider provider = TestAccessTokenProviderFactory.Create(httpClient, DEV_AUTH_URL); IAccessToken token = await provider.ProvisionAccessTokenAsync(testClaimSet, testScopes).ConfigureAwait(false); IAccessTokenValidator validator = AccessTokenValidatorFactory.CreateRemoteValidator(httpClient, new Uri(DEV_AUTH_JWKS_URL), new Uri(DEV_AUTH_JWK_URL)); Assert.DoesNotThrowAsync(async() => await validator.ValidateAsync(token.Token).ConfigureAwait(false)); } }
public void TestFixtureSetUp() { m_authService = new AuthServiceMock(AuthServiceMock.KeyType.ECDSA_P256); m_accessTokenValidator = AccessTokenValidatorFactory.CreateRemoteValidator( new HttpClient(m_authService.MockHandler), new Uri(m_authService.Host, ".well-known/jwks") ); m_authService.SetupJwks().Wait(); }
public OutgoingGrainCallAuthorizationFilter(IAccessTokenProvider accessTokenProvider, IAccessTokenValidator accessTokenValidator, OAuth2EndpointInfo oAuth2EndpointInfo, IAuthorizeHandler authorizeHandler, ILoggerFactory loggerFactory) : base(accessTokenValidator, authorizeHandler) { _accessTokenProvider = accessTokenProvider; _oAuth2EndpointInfo = oAuth2EndpointInfo; Logger = loggerFactory.CreateLogger <OutgoingGrainCallAuthorizationFilter>(); }
public async void TestAccessTokenProvider_SuppliedRSAParameters_TokenIsValid() { using (var httpClient = new HttpClient()) { IAccessTokenProvider provider = TestAccessTokenProviderFactory.Create(httpClient, DEV_AUTH_URL, TestStaticKeyProvider.TestKeyId, TestStaticKeyProvider.TestRSAParameters); IAccessToken token = await provider.ProvisionAccessTokenAsync(testClaimSet, testScopes).SafeAsync(); IAccessTokenValidator validator = AccessTokenValidatorFactory.CreateRemoteValidator(httpClient, new Uri(DEV_AUTH_URL)); Assert.DoesNotThrow(async() => await validator.ValidateAsync(token.Token).SafeAsync()); } }
public void TestFixtureSetUp() { m_authService = new AuthServiceMock(AuthServiceMock.KeyType.ECDSA_P256); m_accessTokenValidator = AccessTokenValidatorFactory.CreateRemoteValidator( new HttpClient(), m_authService.Host ); m_authService.SetupJwks().Wait(); }
public CreateTransfer( ILogger <CreateTransfer> logger, IAccessTokenValidator accessTokenValidator, ITransfersService transfersService, ICoreContext coreContext ) : base(logger) { this.accessTokenValidator = accessTokenValidator; this.transfersService = transfersService; this.coreContext = coreContext; }
public async Task TestGetToken_WithClaimAndScope_IsValid() { Claim[] claims = { new Claim(Constants.Claims.TENANT_ID, Guid.NewGuid().ToString()) }; Scope[] scopes = { new Scope("group", "resource", "permission") }; string token = await TestAccessToken.GetToken(DEV_AUTH_URL, claims, scopes).SafeAsync(); using (var httpClient = new HttpClient()) { IAccessTokenValidator validator = AccessTokenValidatorFactory.CreateRemoteValidator(httpClient, new Uri(DEV_AUTH_URL)); Assert.DoesNotThrowAsync(async() => await validator.ValidateAsync(token).SafeAsync()); } }
private void ValidateAccessToken(string encryptedUserCred) { string option = AccessTokenValidatorFactory.ACCESS_TOKEN_WCF; IAccessTokenValidator tokenValidator = AccessTokenValidatorFactory.GetAccessTokenValidator(option); TokenValidationResult result = tokenValidator.IsUserCredentialValid(encryptedUserCred); if (!result.IsValidationSuccess) { throw new TokenValidationException(result.Message, result.Status); } }
public TransferFileProxy( ILogger <TransferFileProxy> logger, IAccessTokenValidator accessTokenValidator, ICoreContext coreContext, HttpClient httpClient, Settings settings ) : base(logger) { this.accessTokenValidator = accessTokenValidator; this.coreContext = coreContext; this.httpClient = httpClient; this.settings = settings; }
public AuthService( IHexadoUserRepository hexadoUserRepository, IAccessTokenValidator accessTokenValidator, UserManager <HexadoUser> userManager, IOptions <JwtOptions> options, ITokenFactory tokenFactory) { _hexadoUserRepository = hexadoUserRepository; _accessTokenValidator = accessTokenValidator; _userManager = userManager; _options = options.Value; _tokenFactory = tokenFactory; }
static TestUtilities() { #pragma warning disable 618 IPublicKeyDataProvider publicKeyDataProvider = new InMemoryPublicKeyDataProvider(); #pragma warning restore 618 m_signer = EcDsaTokenSignerFactory .Create(publicKeyDataProvider, EcDsaTokenSignerFactory.Curve.P256); IAccessTokenValidator accessTokenValidator = AccessTokenValidatorFactory .CreateLocalValidator(publicKeyDataProvider); RequestAuthenticator = RequestAuthenticatorFactory.Create(accessTokenValidator); }
Action IBenchmark.GetRunner() { SetUp(out Uri host, out string token, out string id); IAccessTokenValidator validator = AccessTokenValidatorFactory.CreateRemoteValidator( new HttpClient(), host, null ); return(delegate { validator.ValidateAsync(token).SafeAsync().GetAwaiter().GetResult(); }); }
//Validate AccessTokenString protected virtual ValidationResult ValidateAccessTokenString(Int64 idAccessToken, string accessTokenString) { ValidationResult validationResult = new ValidationResult(true); try { //Create Validator based on its Key name : 'Keywords.UpdateAccessToken'. //The validator factory will create the validator object based on its key. IAccessTokenValidator validator = (IAccessTokenValidator)ValidatorFactory.Create(Keywords.UpdateAccessToken); //Execute validation process validationResult = validator.ValidateAccessTokenString(idAccessToken, accessTokenString); } catch { //The program will throw error if the validation object doesn't exist. And the default of validation result is true. } return(validationResult); }
public IncomingGrainCallAuthorizationFilter(IAccessTokenValidator accessTokenValidator, IAuthorizeHandler authorizeHandler, ILoggerFactory loggerFactory) : base(accessTokenValidator, authorizeHandler) { Logger = loggerFactory.CreateLogger <IncomingGrainCallAuthorizationFilter>(); }
public BlogPostController(IAccessTokenValidator tokenValidator, IBlogPostRepository blogPostRepository) { _tokenValidator = tokenValidator; _blogPostRepository = blogPostRepository; }
internal RequestAuthenticator( IAccessTokenValidator accessTokenValidator ) { m_accessTokenValidator = accessTokenValidator; }
protected GrainCallAuthorizationFilterBase(IAccessTokenValidator accessTokenValidator, IAuthorizeHandler authorizeHandler) { _authorizeHandler = authorizeHandler; _accessTokenValidator = accessTokenValidator; }
/// <summary> /// Creates an <see cref="IRequestAuthenticator"/> instance. /// </summary> public static IRequestAuthenticator Create( IAccessTokenValidator accessTokenValidator ) { IRequestAuthenticator authenticator = new RequestAuthenticator( accessTokenValidator ); return authenticator; }
internal RequestAuthenticator(IAccessTokenValidator accessTokenValidator) { m_accessTokenValidator = accessTokenValidator; }