Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Steph Lane 1 post 71 karma points
    2 days ago
    Steph Lane
    0

    Configuring UmbracoApiController with EntraID Bearer authentication

    I have an Umbraco v13 site where I want to secure endpoints on an UmbracoApiController with Bearer tokens generated through EntraID.

    I have added the MS Identity API authentication with the following:

    services.AddMicrosoftIdentityWebApiAuthentication(_config);
    

    A valid token is coming through, but OpenIddict is seemingly getting to it first and returning a 401 to the API request. When I add this directly after adding the Authentication service:

    services.Configure<JwtBearerOptions>(JwtBearerDefaults.AuthenticationScheme, options =>
    {
        options.Events.OnTokenValidated = context =>
        {
            return Task.CompletedTask;
        };
    });
    

    The API request then succeeds.

    What is the approach that I should be taking here? The OpenIddict token authentication looks to be to do with Member Auth more than anything, so it doesn't seem like replacing the MS Auth with that is the right path.

Please Sign in or register to post replies

Write your reply to:

Draft