Ejemplo n.º 1
0
        public static IServiceCollection AddSwagger(
            this IServiceCollection services,
            AuthorizationOptions authOptions,
            BrandingOptions brandingOptions
            )
        {
            services.AddSwaggerGen(options =>
            {
                options.SwaggerDoc("v1", new OpenApiInfo
                {
                    Title       = brandingOptions.ApplicationName,
                    Version     = "v1",
                    Description = "API documentation and interaction"
                });

                options.EnableAnnotations();

                if (File.Exists("IdentityServer.xml"))
                {
                    options.IncludeXmlComments("IdentityServer.xml");
                }
            });

            return(services);
        }
Ejemplo n.º 2
0
 public _Controller(
     BrandingOptions displayOptions,
     ILogger logger
     )
 {
     Branding = displayOptions;
     Logger   = logger;
 }
Ejemplo n.º 3
0
 public ClientController(
     ILogger <ClientController> logger,
     ClientService svc,
     BrandingOptions branding
     ) : base(logger)
 {
     _svc      = svc;
     _branding = branding;
 }
Ejemplo n.º 4
0
 public ConsentController(
     BrandingOptions branding,
     ILogger <ConsentController> logger,
     IIdentityServerInteractionService interaction,
     IClientStore clientStore,
     ResourceService resourceStore
     ) : base(branding, logger)
 {
     _viewSvc = new ConsentViewService(interaction, clientStore, resourceStore, logger);
 }
Ejemplo n.º 5
0
 public HomeController(
     HomeService clientService,
     BrandingOptions branding,
     AccountOptions authorizationOptions,
     ILogger <HomeController> logger
     ) : base(branding, logger)
 {
     _viewSvc = clientService;
     Options  = authorizationOptions;
 }
Ejemplo n.º 6
0
 public HomeService(
     ClientService clientSvc,
     IIdentityServerInteractionService interaction,
     IHttpContextAccessor httpContext,
     BrandingOptions branding
     )
 {
     _clientSvc   = clientSvc;
     _interaction = interaction;
     _http        = httpContext;
     _branding    = branding;
 }
Ejemplo n.º 7
0
 public GrantsController(
     BrandingOptions branding,
     ILogger <GrantsController> logger,
     IIdentityServerInteractionService interaction,
     IClientStore clients,
     IResourceStore resources
     ) : base(branding, logger)
 {
     _interaction = interaction;
     _clients     = clients;
     _resources   = resources;
 }
Ejemplo n.º 8
0
 public ResourceController(
     ILogger <ResourceController> logger,
     ResourceService svc,
     ImportService importSvc,
     IHostEnvironment env,
     BrandingOptions branding
     ) : base(logger)
 {
     _svc       = svc;
     _importSvc = importSvc;
     _env       = env;
     _branding  = branding;
 }
Ejemplo n.º 9
0
        public static IApplicationBuilder UseConfiguredSwagger(
            this IApplicationBuilder app,
            AuthorizationOptions authOptions,
            BrandingOptions brandingOptions
            )
        {
            app.UseSwagger(cfg =>
            {
                cfg.RouteTemplate = "api/{documentName}/openapi.json";
            });

            app.UseSwaggerUI(cfg =>
            {
                cfg.RoutePrefix = "api";
                cfg.SwaggerEndpoint(brandingOptions.PathBase + "/api/v1/openapi.json", $"{brandingOptions.ApplicationName} (v1)");
            });

            return(app);
        }
Ejemplo n.º 10
0
 public AccountController(
     ILogger <AccountController> logger,
     AccountViewService viewSvc,
     CookieService cookieService,
     IAccountService accountSvc,
     ClientService clientSvc,
     IAppMailClient mailer,
     BrandingOptions branding,
     AccountOptions options,
     IDistributedCache memcache,
     IIdentityServerInteractionService idInteraction
     ) : base(branding, logger)
 {
     _viewSvc     = viewSvc;
     _cookies     = cookieService;
     _accountSvc  = accountSvc;
     _clientSvc   = clientSvc;
     _options     = options;
     _cache       = memcache;
     _interaction = idInteraction;
     _mailer      = mailer;
 }
Ejemplo n.º 11
0
        public static IServiceCollection AddSwagger(
            this IServiceCollection services,
            AuthorizationOptions authOptions,
            BrandingOptions brandingOptions
            )
        {
            string xmlDoc = Assembly.GetExecutingAssembly().GetName().Name + ".xml";

            services.AddSwaggerGen(options =>
            {
                options.SwaggerDoc("v1", new OpenApiInfo
                {
                    Title       = brandingOptions.ApplicationName,
                    Version     = "v1",
                    Description = "API documentation and interaction"
                });

                options.EnableAnnotations();

#if DEBUG
                string[] files = Directory.GetFiles("bin", xmlDoc, SearchOption.AllDirectories);

                if (files.Length > 0)
                {
                    options.IncludeXmlComments(files[0]);
                }
#else
                if (File.Exists(xmlDoc))
                {
                    options.IncludeXmlComments(xmlDoc);
                }
#endif

                if (!string.IsNullOrEmpty(authOptions.Authority))
                {
                    options.AddSecurityDefinition("oauth2", new OpenApiSecurityScheme
                    {
                        Type  = SecuritySchemeType.OAuth2,
                        Flows = new OpenApiOAuthFlows
                        {
                            AuthorizationCode = new OpenApiOAuthFlow
                            {
                                AuthorizationUrl = new Uri(
                                    authOptions.SwaggerClient?.AuthorizationUrl
                                    ?? $"{authOptions.Authority}/connect/authorize"
                                    ),
                                TokenUrl = new Uri(
                                    authOptions.SwaggerClient?.TokenUrl
                                    ?? $"{authOptions.Authority}/connect/token"
                                    ),
                                Scopes = new Dictionary <string, string>
                                {
                                    { "openid", "User Access" },
                                    { AppConstants.Audience, "User Access" }
                                }
                            }
                        },
                    });

                    options.AddSecurityRequirement(new OpenApiSecurityRequirement
                    {
                        {
                            new OpenApiSecurityScheme
                            {
                                Reference = new OpenApiReference {
                                    Type = ReferenceType.SecurityScheme, Id = "oauth2"
                                }
                            },
                            new[] { authOptions.Audience }
                        }
                    });
                }
            });

            return(services);
        }