Mark Drake
06/27/2024, 8:02 PMMark Drake
06/29/2024, 1:54 PMprotherj
06/30/2024, 2:08 PMMark Drake
06/30/2024, 2:38 PMwhitter
06/30/2024, 4:48 PMIOpenIddictApplicationManager
The default frontend member client is configured here https://github.com/umbraco/Umbraco-CMS/blob/3ce2e97f5e13de0f4e69ff8943c66744d3103b27/src/Umbraco.Cms.Api.Delivery/Security/MemberApplicationManager.cs#L35
And it is added to OpenIddict inside an application starting notification https://github.com/umbraco/Umbraco-CMS/blob/3ce2e97f5e13de0f4e69ff8943c66744d3103b27/src/Umbraco.Cms.Api.Delivery/Handlers/InitializeMemberApplicationNotificationHandler.cs#L63protherj
07/01/2024, 9:38 PMAndrew McKaskill
07/05/2024, 9:56 AMMark Drake
08/09/2024, 4:32 PMMark Drake
08/09/2024, 4:32 PMexport default defineConfig({
secret: "pussyhair",
providers: [
{
id: "umbraco",
name: "Umbraco",
type: "oidc",// oidc or oauth?
issuer: "https://localhost:44336/",
clientId: "umbraco-member",
token: "https://localhost:44336/umbraco/delivery/api/v1/security/member/token",
authorization: {
params: {
scope: "openid",
response_mode: "query"
}
},
checks: ["pkce", "state"],
client: {
token_endpoint_auth_method: "none"
},
profile(profile) {
console.log(profile); // I'm here, and this is not a profile!
return {
id: profile.sub,
name: profile.name,
email: profile.email,
image: profile.picture,
};
},
},
],
cookies: {
pkceCodeVerifier: {
options: {
httpOnly: true,
sameSite: false,
path: "/",
secure: false,
},
},
}
});
Mark Drake
08/09/2024, 4:36 PMform_post
from the docs didn't work, it has to be query
.
Token Auth.js is not smart enough to differentiate between a user endpoint and a token endpoint. If you don't supply this endpoint specifically, it will error because it cannot find the user endpoint.
Client Secret actually matters to most client applications. If you provide a string here, even if empty, it blew up Auth.js and failed the challenge check at the end. The key here is to find the right configuration values so Auth.js doesn't force you to provide a client secret AT ALL.Mark Drake
08/09/2024, 6:02 PMMark Drake
08/09/2024, 6:27 PMusing System.Security.Claims;
using Microsoft.AspNetCore.Authentication;
using OpenIddict.Validation.AspNetCore;
using Umbraco.Cms.Core.DeliveryApi;
using Umbraco.Cms.Web.Common.Controllers;
namespace Humble.Umbraco_13.Website;
public class MemberController : UmbracoApiController
{
private readonly IHttpContextAccessor _httpContextAccessor;
public MemberController(IHttpContextAccessor httpContextAccessor)
{
_httpContextAccessor = httpContextAccessor;
}
// /Umbraco/Api/Member/Profile
public async Task<object> Profile()
{
ClaimsPrincipal? requestPrincipal = await GetRequestPrincipal();
var claims = requestPrincipal?.Claims;
var identity = requestPrincipal?.Identity;
return new
{
id = claims?.FirstOrDefault(x => x.Type.Equals("sub"))?.Value,
name = claims?.FirstOrDefault(x => x.Type.Equals(ClaimTypes.Name))?.Value,
email = claims?.FirstOrDefault(x => x.Type.Equals(ClaimTypes.Email))?.Value,
image = claims?.FirstOrDefault(x => x.Type.Equals("picture"))?.Value
};
}
/// <summary>
/// Ref: https://github.com/umbraco/Umbraco-CMS/blob/contrib/src/Umbraco.Cms.Api.Delivery/Services/RequestMemberAccessService.cs#L39
/// </summary>
/// <returns></returns>
private async Task<ClaimsPrincipal?> GetRequestPrincipal()
{
HttpContext httpContext = _httpContextAccessor.GetRequiredHttpContext();
// Local calls
var user = httpContext.User;
if (user.Identity.IsAuthenticated)
return user;
// Remote calls
AuthenticateResult result = await httpContext.AuthenticateAsync(OpenIddictValidationAspNetCoreDefaults.AuthenticationScheme);
return result.Succeeded
? result.Principal
: null;
}
}
Mark Drake
08/09/2024, 6:28 PMAndrew McKaskill
08/12/2024, 9:18 AMbiapar
09/11/2024, 2:50 PMA hub and casual space for you to interact with fellow community members and learn more about Umbraco!
Powered by