Skip to content

[Feature Request] ForceHttpsRedirectUris option to elegantly enable container deploymentsΒ #175

Closed

Description

Initially raised by Kris (@krispenner) in #115 (comment)

Is your feature request related to a problem? Please describe.
For many people who only want to ensure https is used (instead of http) like myself as I'm running in a Docker container hosted in Azure App Service. I think a simpler option such as ForceHttpsRedirectUris = true in the configuration/options would be simpler. It would remove the need to specify the full absolute URI just to ensure https is used allowing the computed redirect URI to stay and just upgrade it to https. I'm concerned with managing the absolute URIs across configuration files and environments - relative paths as so much friendlier.

Describe the solution you'd like
Here is what I've currently done which solved my issue of http being used when in a Docker container:

services.Configure(OpenIdConnectDefaults.AuthenticationScheme,
options => {
var redirectToIdpHandler = options.Events.OnRedirectToIdentityProvider;
options.Events.OnRedirectToIdentityProvider = async context =>
{
// Call what Microsoft.Identity.Web is doing
await redirectToIdpHandler(context);

        // Override the redirect URI to be what you want
        if (context.ProtocolMessage?.RedirectUri?.StartsWith("http://") ?? false)
        {
            context.ProtocolMessage.RedirectUri = context.ProtocolMessage.RedirectUri.Replace("http://", "https://");
        }
    };

    var redirectToIdpForSignOutHandler = options.Events.OnRedirectToIdentityProviderForSignOut;
    options.Events.OnRedirectToIdentityProviderForSignOut = async context =>
    {
        // Call what Microsoft.Identity.Web is doing
        await redirectToIdpForSignOutHandler(context);

        // Override the redirect URI to be what you want
        if (context.ProtocolMessage?.PostLogoutRedirectUri?.StartsWith("http://") ?? false)
        {
            context.ProtocolMessage.PostLogoutRedirectUri = context.ProtocolMessage.PostLogoutRedirectUri.Replace("http://", "https://");
        }
    };
});

Describe alternatives you've considered
Customers are not blocked as they can set the RedirectUri and PostLogoutRedirectUri

Additional context
This is a nice to have that would avoid devs maitaining multiple appsettings.json, in particular when there are several deployment slots ...

Activity

  1. changed the title [-][Feature Request] [/-] [+][Feature Request] ForceHttpsRedirectUris option to elegantly enable container deployments[/+] on May 26, 2020
  2. added this to the milestone on Jun 2, 2020
  3. modified the milestones: , 0.1.5-preview on Jun 5, 2020
  4. krispenner commented on Jun 17, 2020

    @krispenner

    Thanks, works great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

enhancementfixedscenario: azure

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions