public static void AddAccessKey(this AuthenticationConfiguration configuration, SimpleSecurityTokenHandler.ValidateTokenDelegate validateTokenDelegate, AuthenticationOptions options) { configuration.AddMapping(new AuthenticationOptionMapping { TokenHandler = new SecurityTokenHandlerCollection { new SimpleSecurityTokenHandler(validateTokenDelegate) }, Options = options }); }
public static void AddAccessKey(this AuthenticationConfiguration configuration, SimpleSecurityTokenHandler handler, AuthenticationOptions options) { configuration.AddMapping(new AuthenticationOptionMapping { TokenHandler = new SecurityTokenHandlerCollection { handler }, Options = options }); }
public static void AddCodeMappingsFromAssemblies(this Configuration @this, IEnumerable<Assembly> assemblies) { var mapper = new ModelMapper(); foreach (var mappingAssembly in assemblies) { mapper.AddMappings(mappingAssembly.GetTypes()); } @this.AddMapping(mapper.CompileMappingForAllExplicitlyAddedEntities()); }
public static void AddBasicAuthentication(this AuthenticationConfiguration configuration, BasicAuthenticationSecurityTokenHandler.ValidateUserNameCredentialDelegate validationDelegate, bool retainPassword = false) { var handler = new BasicAuthenticationSecurityTokenHandler(validationDelegate); handler.RetainPassword = retainPassword; configuration.AddMapping(new AuthenticationOptionMapping { TokenHandler = new SecurityTokenHandlerCollection { handler }, Options = AuthenticationOptions.ForAuthorizationHeader(scheme: "Basic") }); }
/// <summary> /// Call this method to add class mappings and any MembershipReboot configuration. /// This method must be called after a call to Configure(). /// </summary> /// <param name="configuration"></param> public static void ConfigureMembershipReboot(this Configuration configuration) { // Hack to check if Configure() has been called. Should find a better way. string dialectName; if (!configuration.Properties.TryGetValue("dialect", out dialectName)) { throw new InvalidOperationException("Could not find the dialect in the configuration. Have you called the Configuration.Configure() method?"); } // Register the generators registry class. configuration.LinqToHqlGeneratorsRegistry<MembershipRebootLinqToHqlGeneratorsRegistry>(); // Add mappings for the classes. var mapper = new ModelMapper(); mapper.AddMappings(Assembly.GetAssembly(typeof(UserAccountMapping)).GetExportedTypes()); var mapping = mapper.CompileMappingForAllExplicitlyAddedEntities(); configuration.AddMapping(mapping); }
public static void AddMsftJsonWebToken(this AuthenticationConfiguration configuration, string issuer, string audience, X509Certificate2 signingCertificate) { var validationParameters = new TokenValidationParameters() { AllowedAudience = audience, SigningToken = new X509SecurityToken(signingCertificate), ValidIssuer = issuer, ValidateExpiration = true }; var handler = new JWTSecurityTokenHandlerWrapper(validationParameters); configuration.AddMapping(new AuthenticationOptionMapping { TokenHandler = new SecurityTokenHandlerCollection { handler }, Options = AuthenticationOptions.ForAuthorizationHeader(JwtConstants.Bearer), Scheme = AuthenticationScheme.SchemeOnly(JwtConstants.Bearer) }); }
public static void PerformAutomaticMappingByAttribute(this DefaultFactoryMapper mapper) { // Map extent types to factory var types = AppDomain.CurrentDomain.GetAssemblies().SelectMany(x => x.GetTypes()); foreach (var type in types) { foreach ( var customAttribute in type.GetCustomAttributes(typeof(AssignFactoryForExtentTypeAttribute), false)) { var factoryAssignmentAttribute = customAttribute as AssignFactoryForExtentTypeAttribute; if (factoryAssignmentAttribute != null) { mapper.AddMapping( type, scope => (IFactory)scope.Resolve(factoryAssignmentAttribute.FactoryType)); Debug.WriteLine($"Assigned extent type '{type.FullName}' to '{factoryAssignmentAttribute.FactoryType}'"); } } } }
public static void AddJsonWebToken(this AuthenticationConfiguration configuration, string issuer, string audience, string signingKey, AuthenticationOptions options) { var config = new SecurityTokenHandlerConfiguration(); var registry = new WebTokenIssuerNameRegistry(); registry.AddTrustedIssuer(issuer, issuer); config.IssuerNameRegistry = registry; var issuerResolver = new WebTokenIssuerTokenResolver(); issuerResolver.AddSigningKey(issuer, signingKey); config.IssuerTokenResolver = issuerResolver; config.AudienceRestriction.AllowedAudienceUris.Add(new Uri(audience)); var handler = new JsonWebTokenHandler(); handler.Configuration = config; configuration.AddMapping(new AuthenticationOptionMapping { TokenHandler = new SecurityTokenHandlerCollection { handler }, Options = options }); }
public static void PerformMappingForConfigurationOfExtentLoaders( this ManualConfigurationToExtentStorageMapper map) { // Map configurations to extent loader var types = AppDomain.CurrentDomain.GetAssemblies().SelectMany(x => x.GetTypes()); foreach (var type in types) { foreach ( var customAttribute in type.GetCustomAttributes(typeof(ConfiguredByAttribute), false)) { var configuredByAttribute = customAttribute as ConfiguredByAttribute; if (configuredByAttribute != null) { map.AddMapping(configuredByAttribute.ConfigurationType, scope => (IExtentStorage)scope.Resolve(type)); Debug.WriteLine( $"Extent loader '{configuredByAttribute.ConfigurationType}' is configured by '{type.FullName}'"); } } } }
public static void AddMsftJsonWebToken( this AuthenticationConfiguration configuration, string issuer, string audience, X509Certificate2 signingCert, AuthenticationOptions options, AuthenticationScheme scheme) { var validationParameters = new TokenValidationParameters() { AllowedAudience = audience, SigningToken = new X509SecurityToken(signingCert), ValidIssuer = issuer, ValidateExpiration = true }; var handler = new JWTSecurityTokenHandlerWrapper(validationParameters); configuration.AddMapping(new AuthenticationOptionMapping { TokenHandler = new SecurityTokenHandlerCollection { handler }, Options = options, Scheme = scheme }); }
public static void AddSaml11(this AuthenticationConfiguration configuration, SecurityTokenHandlerConfiguration handlerConfiguration, AuthenticationOptions options) { var handler = new HttpSamlSecurityTokenHandler(); handler.Configuration = handlerConfiguration; configuration.AddMapping(new AuthenticationOptionMapping { TokenHandler = new SecurityTokenHandlerCollection { handler }, Options = options }); }
public static void AddMapping(this IKeyMappingService mapping, IEntity owner, int serverID) { mapping.AddMapping(owner.EntityType, owner.EntityID, serverID); }
public static void AddBasicAuthentication(this AuthenticationConfiguration configuration, BasicAuthenticationSecurityTokenHandler.ValidateUserNameCredentialDelegate validationDelegate, AuthenticationOptions options, string realm = "localhost", bool retainPassword = false) { var handler = new BasicAuthenticationSecurityTokenHandler(validationDelegate); handler.RetainPassword = retainPassword; configuration.AddMapping(new AuthenticationOptionMapping { TokenHandler = new SecurityTokenHandlerCollection { handler }, Options = options, Scheme = AuthenticationScheme.SchemeAndRealm("Basic", realm) }); }
public static void AddJsonWebToken( this AuthenticationConfiguration configuration, TokenValidationParameters validationParameters, AuthenticationOptions options, AuthenticationScheme scheme, Dictionary<string, string> claimMappings = null) { var handler = new JwtSecurityTokenHandlerWrapper(validationParameters, claimMappings); configuration.AddMapping(new AuthenticationOptionMapping { TokenHandler = new SecurityTokenHandlerCollection { handler }, Options = options, Scheme = scheme }); }
public static void AddClientCertificate(this AuthenticationConfiguration configuration, SecurityTokenHandler handler) { configuration.AddMapping(new AuthenticationOptionMapping { TokenHandler = new SecurityTokenHandlerCollection { handler }, Options = AuthenticationOptions.ForClientCertificate() }); }
public static void AddBasicAuthentication(this AuthenticationConfiguration configuration, Func<string, string, bool> validationDelegate, Func<string, string[]> roleDelegate, string realm = "localhost", bool retainPassword = false) { var handler = new BasicAuthenticationWithRoleSecurityTokenHandler(validationDelegate, roleDelegate); handler.RetainPassword = retainPassword; configuration.AddMapping(new AuthenticationOptionMapping { TokenHandler = new SecurityTokenHandlerCollection { handler }, Options = AuthenticationOptions.ForAuthorizationHeader(scheme: "Basic"), Scheme = AuthenticationScheme.SchemeAndRealm("Basic", realm) }); }
public static void AddClientCertificate(this AuthenticationConfiguration configuration, ClientCertificateMode mode, params string[] values) { var handler = new ClientCertificateHandler(mode, values); configuration.AddMapping(new AuthenticationOptionMapping { TokenHandler = new SecurityTokenHandlerCollection { handler }, Options = AuthenticationOptions.ForClientCertificate() }); }
public static void AddSaml2AndJwt(this AuthenticationConfiguration configuration, string issuerThumbprint, X509Certificate2 signingCertificate, string issuerName, string audienceUri, X509CertificateValidator certificateValidator, AuthenticationOptions options, AuthenticationScheme scheme, X509Certificate2 encryptionCertificate) { var validationParameters = new TokenValidationParameters() { AllowedAudience = audienceUri, SigningToken = new X509SecurityToken(signingCertificate), ValidIssuer = issuerName, }; var jwtHandler = new JwtSecurityTokenHandlerWrapper(validationParameters); var samlHandlerConfig = CreateSaml2SecurityTokenHandlerConfiguration(issuerThumbprint, issuerName, audienceUri, certificateValidator, encryptionCertificate); var saml2Handler = new HttpSaml2SecurityTokenHandler() { Configuration = samlHandlerConfig }; configuration.AddMapping(new AuthenticationOptionMapping { TokenHandler = new SecurityTokenHandlerCollection { jwtHandler, saml2Handler }, Options = options, Scheme = scheme }); }