public BaseSamlAuthenticateController(
     IOptions <SamlIdpOptions> samlIdpIOptions,
     IUserRepository userRepository)
 {
     _samlIdpOptions = samlIdpIOptions.Value;
     _userRepository = userRepository;
 }
        public async Task ConfiguringCollections_DoesNotSetTheCollectionButAddsTheItems()
        {
            var samlIdpOptions = new SamlIdpOptions();

            Assert.AreEqual(8, samlIdpOptions.DefaultClaimMapping.Count);

            var samlPath = $"{ConfigurationKeys.IdentityServerPath}:{nameof(ExtendedIdentityServerOptions.Saml)}";
            var defaultClaimMappingPath = $"{samlPath}:{nameof(SamlIdpOptions.DefaultClaimMapping)}";
            var configurationBuilder    = new ConfigurationBuilder();

            configurationBuilder.AddInMemoryCollection(new Dictionary <string, string>
            {
                { $"{defaultClaimMappingPath}:First-key", "First-value" },
                { $"{defaultClaimMappingPath}:Second-key", "Second-value" },
                { $"{defaultClaimMappingPath}:Third-key", "Third-value" }
            });
            var configuration = configurationBuilder.Build();

            var services = new ServiceCollection();

            services.Configure <SamlIdpOptions>(configuration.GetSection(samlPath));
            await using (var serviceProvider = services.BuildServiceProvider())
            {
                var configuredSamlIdpOptions = serviceProvider.GetRequiredService <IOptions <SamlIdpOptions> >().Value;
                Assert.AreEqual(11, configuredSamlIdpOptions.DefaultClaimMapping.Count);
            }
        }
Beispiel #3
0
 public SingleSignOnController(
     ISingleSignOnHandler singleSignOnHandler,
     IEntityDescriptorStore entityDescriptorStore,
     IOptions <SamlIdpOptions> options)
 {
     _singleSignOnHandler   = singleSignOnHandler;
     _entityDescriptorStore = entityDescriptorStore;
     _options = options.Value;
 }
Beispiel #4
0
        public static void UseSamlIdp(this IAppBuilder app, SamlIdpOptions options)
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }

            app.Use <SamlIdpMiddleware>(app, options);
        }
Beispiel #5
0
        public void SamlIdpOwinExtensions_UseSamlIdp()
        {
            var app = Substitute.For <IAppBuilder>();

            var options = new SamlIdpOptions();

            app.UseSamlIdp(options);

            app.Received().Use(typeof(SamlIdpMiddleware), app, options);
        }
 public SingleSignOnHandler(
     IEntityDescriptorStore entityDescriptorStore,
     IRelyingPartyRepository relyingPartyRepository,
     IEnumerable <IAuthenticator> authenticators,
     IUserRepository userRepository,
     IOptions <SamlIdpOptions> options)
 {
     _entityDescriptorStore  = entityDescriptorStore;
     _relyingPartyRepository = relyingPartyRepository;
     _authenticators         = authenticators;
     _userRepository         = userRepository;
     _options = options.Value;
 }
Beispiel #7
0
        public void Configuration(IAppBuilder app)
        {
#if DEBUG
            app.UseErrorPage();
#endif
            app.UseWelcomePage("/");

            app.Map("/core", coreApp =>
            {
                var options = new IdentityServerOptions
                {
                    SiteName = "Embedded IdentityServer",

                    Factory = new IdentityServerServiceFactory()
                              .UseInMemoryScopes(StandardScopes.All)
                              .UseInMemoryClients(Clients.Get())
                              .UseInMemoryUsers(Users.Get()),

                    RequireSsl = false,

                    AuthenticationOptions = new AuthenticationOptions
                    {
                        EnableAutoCallbackForFederatedSignout = true,
                        EnableSignOutPrompt = false
                    },

                    SigningCertificate = SigningCertificate
                };
                coreApp.UseIdentityServer(options);
            });

            app.Map("/saml", samlApp =>
            {
                samlApp.UseCookieAuthentication(new CookieAuthenticationOptions
                {
                    AuthenticationType = "Cookies"
                });

                samlApp.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
                {
                    Authority    = "http://localhost:12345/core",
                    ClientId     = "samlidp",
                    ClientSecret = "b2a5509386414dc38d48a3897de9e519",
                    RedirectUri  = "http://localhost:12345/saml",
                    ResponseType = "code id_token token",
                    Scope        = "openid",
                    SignInAsAuthenticationType = "Cookies"
                });

                var options = new SamlIdpOptions
                {
                    AuthenticationType = OpenIdConnectAuthenticationDefaults.AuthenticationType,
                    SigningCertificate = SigningCertificate,
                    ServiceProviders   =
                    {
                        new ServiceProvider
                        {
                            EntityId = new EntityId("urn:auth0:tgit:test"),
                            AssertionConsumerServiceUri = new Uri("https://tgit.au.auth0.com/login/callback")
                        }
                    }
                };
                samlApp.UseSamlIdp(options);
            });
        }
Beispiel #8
0
 public MetadataHandler(IOptions <SamlIdpOptions> options)
 {
     _options = options.Value;
 }