Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Documentation] B2C support for redirect_uri #3087

Open
4 tasks
karpikpl opened this issue Oct 15, 2024 · 0 comments
Open
4 tasks

[Documentation] B2C support for redirect_uri #3087

karpikpl opened this issue Oct 15, 2024 · 0 comments
Labels
documentation Improvements or additions to documentation needs attention untriaged

Comments

@karpikpl
Copy link

Documentation related to component

I've been looking for documentation on how to configure redirect_uri for B2C but it seems to be missing.
There's the "CallbackPath": "/signin-oidc" but no RedirectUri is used in public client?

public string? GetCurrentRedirectUri(MergedOptions mergedOptions)

Please check all that apply

  • typo
  • [ x] documentation doesn't exist
  • documentation needs clarification
  • error(s) in the example
  • needs an example

Description of the issue

When you run the B2C app behind a proxy (like app service behind azure front door) the redirect URL needs to be configured for the proxy, not for the web app.

Redirect can be changed in code, but for other MSAL libraries that can be set in configuration.

Is this the intended way of handling this?

        // Ensure correct redirect URI handling
        options.Events.OnRedirectToIdentityProvider = async context =>
        {
            await parentHandler(context);

            var request = context.Request;
            var forwardedHost = request.Headers["X-Forwarded-Host"].FirstOrDefault();
            var forwardedProto = request.Headers["X-Forwarded-Proto"].FirstOrDefault();

            var scheme = forwardedProto ?? request.Scheme;
            var host = forwardedHost ?? request.Host.Host;
            var port = request.Host.Port ?? -1;

            var uriBuilder = new UriBuilder(scheme, host, port)
            {
                Path = context.Options.CallbackPath.HasValue ? context.Options.CallbackPath.Value : "/signin-oidc",
            };

            var logger = context.HttpContext.RequestServices.GetRequiredService<ILogger<MyApp>>();

            logger.LogInformation("Redirecting to {redirectUri}", context.ProtocolMessage.RedirectUri);
            logger.LogInformation("AFD built URL would be: {redirectUri}", uriBuilder.Uri);

            context.ProtocolMessage.RedirectUri = uriBuilder.Uri.ToString();
        };
    });
@karpikpl karpikpl added documentation Improvements or additions to documentation needs attention untriaged labels Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation needs attention untriaged
Projects
None yet
Development

No branches or pull requests

1 participant