OIDC로 모델 접근 제어하기

OIDC로 모델 접근 제어하기 (Control Model Access with OIDC)

JWT Auth는 LiteLLM Enterprise 라이선스가 필요한 엔터프라이즈 기능이에요. 무료 30일 체험을 시작하거나 데모를 예약할 수 있어요. Enterprise가 제공하는 기능도 확인해 보세요.

control_model_access_jwt

출처: 문서

본문

예시 토큰 (Example Token)

Azure AD:

{
  "sub": "1234567890",
  "name": "John Doe",
  "email": "[email protected]",
  "roles": ["basic_user"] # 👈 ROLE
}

Keycloak:

{
  "sub": "1234567890",
  "name": "John Doe",
  "email": "[email protected]",
  "resource_access": {
    "litellm-test-client-id": {
      "roles": ["basic_user"] # 👈 ROLE
    }
  }
}

프록시 구성 (Proxy Configuration)

Azure AD:

general_settings:
  enable_jwt_auth: True 
  litellm_jwtauth:
    user_roles_jwt_field: "roles" # the field in the JWT that contains the roles 
    user_allowed_roles: ["basic_user"] # roles that map to an 'internal_user' role on LiteLLM 
    enforce_rbac: true # if true, will check if the user has the correct role to access the model
    role_permissions: # control what models are allowed for each role
    - role: internal_user
      models: ["anthropic-claude"]

model_list:
    - model: anthropic-claude
      litellm_params:
        model: claude-sonnet-5
    - model: openai-gpt-4o
      litellm_params:
        model: gpt-5.6-terra

Keycloak:

general_settings:
  enable_jwt_auth: True 
  litellm_jwtauth:
    user_roles_jwt_field: "resource_access.litellm-test-client-id.roles" # the field in the JWT that contains the roles
    user_allowed_roles: ["basic_user"] # roles that map to an 'internal_user' role on LiteLLM 
    enforce_rbac: true # if true, will check if the user has the correct role to access the model
    role_permissions: # control what models are allowed for each role
    - role: internal_user
      models: ["anthropic-claude"]

model_list:
    - model: anthropic-claude
      litellm_params:
        model: claude-sonnet-5
    - model: openai-gpt-4o
      litellm_params:
        model: gpt-5.6-terra

동작 원리 (How it works)

  1. JWT_PUBLIC_KEY_URL 지정 — OpenID 공급자의 공개 키 엔드포인트예요. Azure AD의 경우 https://login.microsoftonline.com/{tenant_id}/discovery/v2.0/keys이고, Keycloak의 경우 {keycloak_base_url}/realms/{your-realm}/protocol/openid-connect/certs예요.
  2. JWT 역할을 LiteLLM 역할로 매핑user_roles_jwt_fielduser_allowed_roles로 수행해요. 현재 역할 매핑은 internal_user만 지원돼요.
  3. 모델 접근 지정role_permissions: 각 역할이 접근할 수 있는 모델을 제어해요.
    • role: 접근을 제어할 LiteLLM 역할. 허용 역할 = ["internal_user", "proxy_admin", "team"]
    • models: 해당 역할이 접근할 수 있는 모델 목록.
    • model_list: 프록시의 상위 모델 목록. 더 알아보기
  4. 모델 검사 — 프록시는 수신한 JWT에 대해 검증 검사를 실행해요. 코드

더 알아보기 (Learn more)