## Documentation

- About
- Read First
  - What is IdentityServer
  - Installation Scenarios
- Migrations
- Bootstrapping
- Configuration & Integration
  - AdminUI Settings
  - Configuring AdminUI
  - Configuring AdminUI (NuGet)
  - Integrating with Identity Server
  - Integrating with Identity Server Custom Schema
  - Integrating with Quickstarts
  - Enabling Logging
- Installation
  - IIS
  - Azure
    - Install in Azure
    - Create Azure Web App
  - Docker
  - NuGet
- Custom Database Connections
- Custom Identity Store
  - Overview
  - Partial Implementation
  - Full Implementation
  - Tenancy With Entity Framework
  - NoSql Implementation (MongoDB)
- Custom CSP
- Users
  - Searching for Users
  - Adding Users
  - Editing Users
  - Deleting Users
  - Merge Users
  - Set User Password
  - Session Management
  - User Reports
  - Bulk User Import
- Roles
  - Creating Roles
  - Managing Roles
  - Managing Users in a Role
  - Managing Role Claims
- Claim Types
- Clients
  - Searching for Clients
  - Adding Clients
  - Adding a SAML Client
  - Adding a WS-Fed Client
  - Editing Clients
  - Deleting Clients
  - Clone Client
- Import and Export
  - Exporting Clients
  - Importing Clients
  - Importing Client Configuration with Secrets
  - Importing SAML Clients with Certificates
  - Import and Export Via the API
- Dynamic Authentication Providers
  - What is Dynamic Authentication
  - Enabling or disabling Dynamic Authentication
  - Add a Dynamic Provider
    - First Steps
    - Adding OIDC Provider
    - Adding SAML Provider
  - Edit a Dynamic Provider
    - Accessing edit view
    - Editing a OIDC Provider
    - Editing a SAML Provider
  - Deleting a Provider
  - Searching for Provider
- Resources
  - Searching for Resources
  - Creating Resources
  - Editing resources
- Webhooks
  - Webhooks
  - Endpoint Configuration
- MCP
  - Overview
  - Default Server Prompt Instructions
- User Settings Endpoints
- Access Policy
- Keys
- Auditing
- FAQs
- Troubleshooting
  - Unable to start AdminUI
  - Unable to contact IdentityServer
  - Unable to contact API
  - Unable to log in

### Custom CSP

- -Introduction
- -Configure Content Security Policy
- -Extention Methods on IContentSecurityPolicyHeaderDirective

## Introduction

AdminUI has a default conifguration for its content security policy that has its own exception to enable pieces of functionality. But sometimes you may need to modify these settings or rewrite them yourself. AdminUI has the ability when using the NuGet package to either completly override this, or optionally modify the custom configuration.

## Configure Content Security Policy

AdminUI takes the ContentSecurityPolicyOptions configured in the DI and uses that to generate the Content-Security-Policy headers needed. So all you need to do to modify this configuration is to register your own IOptionsConfigure in the DI container to run after the AdminUI one. Here is an example of how you would add sources.

    builder.Services.AddAdminUI();

    // It's important to do this after .AddAdminUI() otherewise your configuration will be overriden
    builder.Services.Configure<ContentSecurityPolicyOptions>(options =>
    {
        options.ConnectSources(src => src.AppendSources("https://localhost:5001"));
        options.FrameSources(src => src.AppendSources("https://localhost:5001"));
    });

There are many options when configuring your content security policy, here is an example of how this would look if you were to fully configure the CSP for AdminUI that you can tweak to suit your purpouses.

    builder.Services.AddAdminUI();

    // It's important to do this after .AddAdminUI() otherewise your configuration will be overriden
    builder.Services.Configure<ContentSecurityPolicyOptions>(options =>
    {
        // Script Sources
        var sources = new[]
        {
            "sha256-m7vYZMioFjSZkBJ624LmmpHUkpOVeuunnlbXQ1LB0Mk=",
            "sha256-Fp+pb/v+yuZCJgkm+swqlbikr47TxdSV0Xrlogi5FIA=",
            "sha256-1VJjjKMY+X1Fyrp0kbWYQOQaEhz3c88e4r7rp2G580E=",
            "sha256-Oe8bRaRSDq7Hj6XSvQDp87/mm5/wflOsW2zUorSRRh8=",
            "sha256-qvXZB7r452onLl++wIonI3lmPV+QeDx3zyjVyboZGVA=",
            "sha256-o4ANp0BtRtNUf4xg0UT9IcWf4ropIGXmSLXPPHsmV8U=",
            "sha256-GBLm9DsOMe2OK7kvFZUpURBKSL6NInxJHuphx7oYeXc=",
            "sha256-92oNc6FnRLeC7OVaOOD46fU/AjMcJibr9XIFcoOq9K4=",
            "sha256-4aTp6nNi+md1utmsRVHog0Y7RfhnHobeQEqOWxdIb10="
        };

        // each s is IContentSecurityPolicyHeaderDirective
        options.DefaultSources(src => src.Self());
        options.ScriptSources(src => src.Self().CustomSources(sources));
        options.StyleSources(src => src.Self().UnsafeInline());
        options.FontSources(src => src.Self());
        options.ImageSources(src => src.Self().CustomSources("data:"));
        options.FrameSources(src => src.CustomSources(authUrl, uiUrl));
        options.ObjectSources(src => src.None());
        options.FrameAncestorSources(src => src.Self());
        options.BaseUriSources(src => src.Self());
        options.ConnectSources(src => src.CustomSources(authUrl, uiUrl, $"https://www.identityserver.com/rss"));
    });

### Extention Methods on IContentSecurityPolicyHeaderDirective

To be used in the configurer Action of IFluentCspHeaderOptions methods.

1. `.None()` Specifies None Source
2. `.Self()` Specifys Self Source
3. `.CustomSources(string[])` Sets List of Custom Sources
4. `.UnsafeInline()` Sets UnsafeInline
5. `.UnsafeEval()` Sets UnsafeEval
6. `.UnsafeEvalIfDevelopment(IHostEnvironment)` Sets UnsafeEval if provided IHostEnvironment is development
7. `.WebsocketsIfDevelopment(IHostEnvironment)` Adds 'ws:' to Custom Sources if provided IHostEnvironment is development
8. `.AppendSources(string[])` Appens provide list of sources to already configured list

Previous Next