Skip to content

Supprot Calims in Token & IsAuthenticated check in aspnet core #5

@DKarzhounikGDT

Description

@DKarzhounikGDT

DESCRIPTION

It would be good if it could support mocks for IS4
so that code samples below could work

if (!context.User.Identity.IsAuthenticated) { throw new ArgumentException(nameof(context)); }

OR
public long GetCurrentEmployeeId() { var claims = httpContextAdapter.GetUserClaims(); var employeeId = claims.FirstOrDefault(x => x.Type == ClaimConstants.EmployeeId); if (employeeId == null) { throw new ArgumentException(string.Format(ExceptionConstants.EmptyValueInToken, JwtClaimTypes.Subject)); } var result = employeeId.Value.ToIntOrThrow(); return result; }

ADDITIONAL CONTEXT

POC in GITLAB

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions