Skip to content
grant-management logo

Grant管理(Grant Management)開発ガイド

grant-management

Grant管理(Grant Management)機能の開発・修正を行う際に使用。AuthorizationGrant、ConsentClaims、同意管理、Grant管理API実装時に役立つ。

SKILL.md

Full skill instructions

Grant管理(Grant Management)開発ガイド

ドキュメント

  • documentation/​docs/​content_03_concepts/​03-authentication-authorization/​concept-05-grant-management.md - Grant管理概念
  • documentation/​openapi/​swagger-grant-management-ja.yaml - Grant管理API仕様(OpenAPI)

機能概要

Grant管理は、認可コンテキストを管理する層。

  • AuthorizationGrant: ユーザー、認証、クライアント、スコープの複合構造
  • AuthorizationGranted: 永続化されたGrant(created_at/​updated_at含む)
  • ConsentClaims: 同意情報の管理
  • Scopeベース同意: クライアント別にscopeを記録
  • Grant管理API: 管理者向けのGrant一覧取得・詳細取得・取り消しAPI

モジュール構成

libs/
├── idp-server-core/                         # Grantコア
│   └── .../​grant_management/
│       ├── AuthorizationGranted.java        # 永続化Grant(created_at/​updated_at含む)
│       ├── AuthorizationGrantedIdentifier.java
│       ├── AuthorizationGrantedQueries.java # クエリパラメータ(limit上限1000)
│       ├── AuthorizationGrantedRepository.java
│       ├── AuthorizationGrantedQueryRepository.java
│       ├── grant/
│       │   ├── AuthorizationGrant.java      # 認可Grant
│       │   ├── GrantIdTokenClaims.java
│       │   └── GrantUserinfoClaims.java
│       └── consent/
│           └── ConsentClaims.java           # 同意情報
│
├── idp-server-core-adapter/                 # DB実装
│   └── .../​grant_management/
│       ├── AuthorizationGrantedDataSource.java
│       ├── AuthorizationGrantedQueryDataSource.java
│       ├── ModelConverter.java              # DB→モデル変換
│       ├── PostgresqlExecutor.java
│       └── MysqlExecutor.java
│
├── idp-server-control-plane/                # Grant管理API定義
│   └── .../​management/​oidc/​grant/
│       ├── OrgGrantManagementApi.java       # APIインターフェース
│       ├── GrantManagementContext.java
│       ├── GrantManagementContextBuilder.java
│       ├── handler/
│       │   ├── OrgGrantManagementHandler.java
│       │   ├── GrantManagementService.java
│       │   ├── GrantFindListService.java
│       │   ├── GrantFindService.java
│       │   └── GrantRevocationService.java  # Grant取り消し+トークン削除
│       └── io/
│           ├── GrantManagementRequest.java
│           ├── GrantManagementResponse.java
│           ├── GrantManagementResult.java
│           └── GrantManagementStatus.java
│
├── idp-server-use-cases/                    # EntryService
│   └── .../​control_plane/​organization_manager/
│       └── OrgGrantManagementEntryService.java
│
└── idp-server-springboot-adapter/           # REST API
    └── .../​control_plane/​restapi/​organization/
        └── OrganizationGrantManagementV1Api.java

Grant管理API(Organization Level)

エンドポイント

メソッドパス説明権限
GET/​v1/​management/​organizations/​{org-id}/​tenants/​{tenant-id}/​grantsGrant一覧取得GRANT_READ
GET/​v1/​management/​organizations/​{org-id}/​tenants/​{tenant-id}/​grants/​{grant-id}Grant詳細取得GRANT_READ
DELETE/​v1/​management/​organizations/​{org-id}/​tenants/​{tenant-id}/​grants/​{grant-id}Grant取り消しGRANT_DELETE

クエリパラメータ(一覧取得)

パラメータ説明
user_idユーザーIDでフィルタ
client_idクライアントIDでフィルタ
from作成日時の開始範囲(ISO 8601)
to作成日時の終了範囲(ISO 8601)
limit最大件数(デフォルト20、上限1000)
offsetスキップ件数

dry_runモード

DELETE時に ?dry_run=true を指定すると、実際の削除を行わずシミュレーション結果を返す。

Grant取り消し時の動作

Grant削除時に、同じuser+clientの全トークン(アクセストークン、リフレッシュトークン)も削除される(Auth0スタイル)。

AuthorizationGranted構造

public class AuthorizationGranted {
    AuthorizationGrantedIdentifier identifier;
    AuthorizationGrant authorizationGrant;
    LocalDateTime createdAt;
    LocalDateTime updatedAt;

    public Map<String, Object> toMap() {
        // id, user, client, scopes, created_at, updated_at を返す
    }
}

AuthorizationGrant構造

public class AuthorizationGrant {
    TenantIdentifier tenantIdentifier;
    User user;
    Authentication authentication;
    RequestedClientId requestedClientId;
    ClientAttributes clientAttributes;
    GrantType grantType;
    Scopes scopes;
    GrantIdTokenClaims idTokenClaims;
    GrantUserinfoClaims userinfoClaims;
    CustomProperties customProperties;
    AuthorizationDetails authorizationDetails;
    ConsentClaims consentClaims;
}

Grantが作成されるタイミング

  • Authorization Code Flowでの同意時
  • Password Grantでのトークン発行時(スコープはマージされる)
  • その他のGrant Typeでのトークン発行時

E2Eテスト

e2e/​src/​tests/
├── usecase/​standard/
│   └── standard-05-grant-revocation.test.js   # Grant取り消しE2E
└── scenario/​control_plane/​organization/
    └── organization_grant_management.test.js  # Grant管理APIテスト

コマンド

# ビルド
./​gradlew :libs:idp-server-core:compileJava
./​gradlew :libs:idp-server-control-plane:compileJava

# E2Eテスト
cd e2e && npm test -- src/​tests/​usecase/​standard/​standard-05-grant-revocation.test.js
cd e2e && npm test -- src/​tests/​scenario/​control_plane/​organization/​organization_grant_management.test.js

トラブルシューティング

Grantが見つからない

  • AuthorizationGrantedが正しく生成されているか確認
  • ユーザー、認証、クライアント情報が揃っているか確認
  • Password Grantの場合、ResourceOwnerPasswordCredentialsGrantServiceでGrant作成ロジックを確認

Grant取り消し後もトークンが有効

  • GrantRevocationServiceでdeleteByUserAndClientが呼ばれているか確認
  • トランザクションが正しくコミットされているか確認

created_at/​updated_atがレスポンスに含まれない

  • ModelConverter.parseLocalDateTime()が正しくパースしているか確認
  • DBからのtimestamp形式を確認(LocalDateTimeParserで対応)

More Security skills

supabase logo
Security

supabase

Handles the full Supabase workflow from schema changes to deployment, with built-in security guardrails that catch common traps like RLS...

2.7K 308.9K
View

Comprehensive guides and best practices for Neon Serverless Postgres, covering setup, connection methods, authentication, and platform APIs.

98 216.2K
View

Guide for setting up and using Firebase Authentication. Use this skill when the user's app requires user sign-in, user management, or secure data access using auth rules.

462 163.8K
View

A skill to evaluate how secure Firestore security rules are. Use this when Firestore security rules are updated to ensure that the generated rules are extremely secure and robust.

462 127.7K
View

Official skill for integrating Firebase AI Logic (Gemini API) into web applications. Covers setup, multimodal inference, structured output, and security.

462 125.1K
View

Complete Better Auth server and client setup with database adapters, session management, plugins, and security configuration.

222 118.2K
View

Deploy and manage projects on Vercel using token-based authentication. Use when working with Vercel CLI using access tokens rather than interactive login — e.g. "deploy to vercel", "set up vercel", "add environment variables to vercel".

31.9K 116.1K
View
cloudflare logo
Security

cloudflare

Complete Cloudflare platform integration with decision trees for compute, storage, AI, networking, security, and infrastructure-as-code.

3K 110.7K
View

Run Azure compliance and security audits with azqr plus Key Vault expiration checks. Covers best-practice assessment, resource review, policy/compliance validation, and security posture checks. WHEN: compliance scan, security audit, BEFORE running azqr (compliance cli tool), Azure best practices, Key Vault expiration check, expired certificates, expiring secrets, orphaned resources, compliance assessment.

253 103K
View
gws-gmail logo
Security

gws-gmail

Send, read, and manage Gmail messages, drafts, labels, and account settings.

31.2K 78.9K
View

Comprehensive website auditing across 230+ rules in 21 categories including SEO, performance, security, and accessibility.

94 72.3K
View
gws-shared logo
Security

gws-shared

Shared authentication, CLI syntax, and output formatting patterns for gws Google Workspace commands.

31.2K 63.4K
View

Security AI tools

StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
GeoSpy logo
Security

GeoSpy

GeoSpy: Pricing, Features, FAQs, and Alternatives for AI Teams

Free
View

Detect AI-generated voices to protect against audio fraud.

Paid
View

Ensure Your Content's Originality with AI Plagiarism Checker

Freemium
View
Img Upscaler logo
Security

Img Upscaler

Upscale images by 400% without quality loss

Freemium
View
AICheatCheck logo
Security

AICheatCheck

Accurately Detect AI-Generated Content with TheChecker.AI

Free
View
D
Security

Detect GPT

Chrome extension that detects and flags AI-generated content

Free
View