public static Guid Id(this IPrincipal principal) { string?id = principal.GetValueFromClaim(LeafClaimTypes.UserId); if (id == null) { throw new InvalidOperationException("No Id claim found."); } return(Guid.Parse(id)); }