mirror of https://github.com/Squidex/squidex.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.0 KiB
38 lines
1.0 KiB
// ==========================================================================
|
|
// Extensions.cs
|
|
// Squidex Headless CMS
|
|
// ==========================================================================
|
|
// Copyright (c) Squidex Group
|
|
// All rights reserved.
|
|
// ==========================================================================
|
|
|
|
using System.Security.Claims;
|
|
using Squidex.Config;
|
|
using Squidex.Infrastructure.Security;
|
|
|
|
namespace Squidex.Pipeline
|
|
{
|
|
public static class Extensions
|
|
{
|
|
public static bool IsFrontendClient(this ClaimsPrincipal principal)
|
|
{
|
|
return principal.IsInClient(Constants.FrontendClient);
|
|
}
|
|
|
|
public static string GetClientId(this ClaimsPrincipal principal)
|
|
{
|
|
var clientId = principal.FindFirst(OpenIdClaims.ClientId)?.Value;
|
|
|
|
var clientIdParts = clientId?.Split(':');
|
|
|
|
if (clientIdParts?.Length != 2)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
clientId = clientIdParts[1];
|
|
|
|
return clientId;
|
|
}
|
|
}
|
|
}
|
|
|