Exemple #1
0
 /// <summary>
 /// Constructor for LoginHandler
 /// </summary>
 /// <param name="configuration">SamlConfiguration</param>
 /// <param name="getFromCache">May be null unless doing artifact binding, this function will be called for artifact resolution</param>
 public SamlLoginHandler(SamlAuthenticationOptions options)
 {
     if (options == null)
     {
         throw new ArgumentNullException(nameof(options));
     }
     this.options  = options;
     configuration = options.Configuration;
     getFromCache  = options.GetFromCache;
     setInCache    = options.SetInCache;
     session       = options.Session;
 }
 /// <summary>
 /// Adds the <see cref="SamlAuthenticationMiddleware"/> into the OWIN runtime.
 /// </summary>
 /// <param name="app">The <see cref="IAppBuilder"/> passed to the configuration method</param>
 /// <param name="options">Saml2Configuration configuration options</param>
 /// <returns>The updated <see cref="IAppBuilder"/></returns>
 public static IAppBuilder UseSamlAuthentication(this IAppBuilder app, SamlAuthenticationOptions options)
 {
     if (app == null)
     {
         throw new ArgumentNullException("app");
     }
     if (options == null)
     {
         throw new ArgumentNullException("options");
     }
     app.Map(options.MetadataPath, metadataapp => {
         metadataapp.Run(new SamlMetadataWriter(options.Configuration).WriteMetadataDocument);
     });
     return(app.Use <SamlAuthenticationMiddleware>(app, options));
 }
Exemple #3
0
            public Handler(
                IDbContext context,
                UserManager <User> userManager,
                ITokenGenerator tokenGenerator,
                IConfiguration configuration,
                IOptions <DomainOptions> domainOptions) : base(context)
            {
                var section = configuration.GetSection("SsoSettings");
                var cfg     = new SamlAuthenticationOptions();

                section.Bind(cfg);
                _samlOptions    = cfg;
                _userManager    = userManager;
                _tokenGenerator = tokenGenerator;
                _domainOptions  = domainOptions;
            }
Exemple #4
0
        /// <summary>
        /// Adds the <see cref="SamlAuthenticationMiddleware"/> into the OWIN runtime.
        /// </summary>
        /// <param name="app">The <see cref="IAppBuilder"/> passed to the configuration method</param>
        /// <param name="options">Saml2Configuration configuration options</param>
        /// <returns>The updated <see cref="IAppBuilder"/></returns>
        public static IAppBuilder UseSamlAuthentication(this IAppBuilder app, SamlAuthenticationOptions options)
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            SAML2.Logging.LoggerProvider.Configuration = SAML2.Logging.LoggerProvider.Configuration ?? options.Configuration;

            app.Map(options.MetadataPath, metadataapp => {
                metadataapp.Run(new SamlMetadataWriter(options.Configuration).WriteMetadataDocument);
            });

            return(app.Use <SamlAuthenticationMiddleware>(app, options));
        }
Exemple #5
0
        public IActionResult Sso()
        {
            var section = _configuration.GetSection("SsoSettings");
            var cfg     = new SamlAuthenticationOptions();

            section.Bind(cfg);

            //specify the SAML provider url here, aka "Endpoint"
            var samlEndpoint = cfg.SamlEndpoint;

            var request = new AuthRequest(
                cfg.AppIdURI,   //put your app's "unique ID" here
                cfg.RedirectUrl //assertion Consumer Url - the redirect URL where the provider will send authenticated users
                );

            //generate the provider URL
            string url = request.GetRedirectUrl(samlEndpoint);

            //then redirect your user to the above "url" var
            //for example, like this:
            return(Redirect(url));
        }
Exemple #6
0
        public IIdpConfigurationProvider Create(SamlAuthenticationOptions options)
        {
            this.provider = new IdpConfigurationProvider(options);

            return(this.provider);
        }
 public IdpConfigurationProvider(
     SamlAuthenticationOptions options
     )
 {
     this.configuration = options.IdentityProviderConfiguration;
 }