본문으로 건너뛰기
cccskills
무료GitHub에 공개

auth-patterns

Load for authentication or authorization changes involving BFF cookies/tokens, JWT validation, claims/user ID extraction, policies, handler access checks, impersonation, or 401/403 bugs; not for UI affordance gating alone.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(4)

  • SKILL.md5.0 KB
  • resources/api-jwt-validation.md1.3 KB
  • resources/local-authorization-provider.md5.3 KB
  • resources/user-id-extraction.md3.5 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

<!-- ABOUTME: Authentication and authorization rules for BFF cookies, JWT validation, Keycloak claims, endpoint protection, and HAL-based UI affordances. --> <!-- ABOUTME: Keeps tokens out of the browser, preserves claim extraction order, and aligns API, handler, and client authorization behavior. -->

Must-Read Docs

Top 5 Invariants

  1. The browser never sees tokens because the BFF stores them in HttpOnly cookies and forwards a Bearer token to the API.
  2. User ID extraction follows sub then nameidentifier then sid, and a missing user identifier yields 401 Unauthorized.
  3. JWT validation checks both aud and azp with a five-minute clock skew, and authorized audiences include islamu-event-api and islamu-event-blazor.
  4. Endpoint defaults are GET with [AllowAnonymous], writes with [Authorize], while resource/action checks route through AuthorizationBehavior to RuntimeAuthorizationProvider (which delegates to Cerbos gRPC PDP or FallbackAuthorizationService).
  5. HATEOAS authorization follows the Candidate, Normalize, Batch, and Materialize pipeline and fails closed, leveraging AuthorityProfile pre-resolution in local mode and making _links the only client-side source of truth for action gating.

Top 5 Anti-Patterns

  1. Storing tokens in localStorage or sessionStorage bypasses the BFF boundary and weakens browser-side security.
  2. Gating UI actions with role or claim inspection instead of HAL _links drifts from the server authorization contract.
  3. Logging raw JWTs leaks secrets into traces, logs, and support artifacts.
  4. Disabling the Tenant query filter during runtime request handling creates cross-tenant authorization and data-isolation bugs.
  5. Validating only aud or only azp allows unauthorized clients to present otherwise valid tokens.
  6. Writing a local claim-extraction helper creates a second identity chain that will silently disagree with the first about who the caller is.
  7. Resolving IUserContext from HttpContext.RequestServices inside a controller hides an ambient dependency and is rejected from compiled controller calls by ApiCompiledBoundaryTests.

Minimal Examples

// Identity derivation is a pure function of the principal and already has one authority.
// Do not write another extraction helper — see resources/user-id-extraction.md.
using Explore.Application.Authentication;

Guid? userId = principal.GetPlatformUserId();           // sub -> nameidentifier -> sid -> internal_user_id
Guid required = principal.GetRequiredPlatformUserId();  // throws UnauthorizedAccessException

// In a controller, ExploreControllerBase already exposes CurrentUserId / RequiredUserId.
// For provider-linked accounts, inject IQueryHandler<ResolveCurrentUserIdByIdentityRequest, Guid?> identityQuery.
// Provider binding wins over GUID/internal-user claims; an unlinked account has no email fallback.
Guid? resolved = await identityQuery.ResolveCurrentUserIdAsync(User, cancellationToken);
public sealed record UpdateEventCommand(Guid EventId, string Title)
    : IAuthorizedRequest<BaseCommandResponse<Guid>>;

public sealed class UpdateEventHandler(IEventRepository repository)
{
    public async Task<BaseCommandResponse<Guid>> Handle(
        UpdateEventCommand request,
        CancellationToken cancellationToken)
    {
        Event entity = await repository.GetRequiredAsync(request.EventId, cancellationToken);
        entity.Rename(request.Title);
        await repository.UpdateAsync(entity, cancellationToken);
        return new BaseCommandResponse<Guid>(entity.Id, true, "Updated");
    }
}

Verification Hooks

  • dotnet test --project tests/Event.Architecture.Tests/Event.Architecture.Tests.csproj --configuration Release --verbosity quiet -- --treenode-filter "/*/*/AuthorizationParityTests/*" --minimum-expected-tests 1 --no-progress --maximum-parallel-tests 1
  • dotnet test --project tests/Event.API.IntegrationTests/Event.API.IntegrationTests.csproj --configuration Release --verbosity quiet
  • dotnet build --configuration Release --verbosity quiet

Related Skills

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Load for Blazor/MudBlazor UI changes involving forms, dialogs, focus, keyboard navigation, landmarks, ARIA, color contrast, RTL-safe styling, or WCAG 2.2 AA tests; not for backend-only changes.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

islamu-ngo/Event82026년 10월 19일 업데이트

Load when a task asks to research, verify, compare, or look up framework/package behavior, release notes, standards, RFCs, CVEs, or unfamiliar APIs; use repository evidence first, then official docs, and not for codebase navigation alone.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

islamu-ngo/Event82026년 10월 19일 업데이트

aspire

무료

Load for Aspire AppHost work: start/stop/wait resources, inspect dashboard/logs/traces, add integrations/resources, rebuild a service, run isolated worktrees, or diagnose Aspire orchestration; not for plain dotnet apps, container-only deployments, or cloud deployment.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

islamu-ngo/Event82026년 10월 19일 업데이트

Load for Blazor BFF server work involving YARP proxy routes, cookie sessions, access-token forwarding/refresh, downstream API calls, BFF handlers, or browser-to-API auth failures; not for client component rendering or API JWT validation alone.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

islamu-ngo/Event82026년 10월 19일 업데이트

Load when editing Blazor `.razor.css`, scoped selectors, `::deep`, BEM class names, RTL/logical CSS properties, or styling nested MudBlazor components; not for global design tokens or non-Blazor CSS.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

islamu-ngo/Event82026년 10월 19일 업데이트

Load for Blazor/MudBlazor component or page changes involving render modes, dialogs, parameters/events, HAL-gated actions, generated API clients or generated record consumption, theming, or component tests; add accessibility or CSS-isolation only when touched.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

islamu-ngo/Event82026년 10월 19일 업데이트

islamu-ngo의 스킬 모두 보기

이 스킬의 문제 신고