This commit is contained in:
Ashwin Bharambe 2025-05-15 17:12:56 -07:00
parent fd86961c88
commit 529b12dc5e
4 changed files with 2220 additions and 2210 deletions

View file

@ -180,7 +180,7 @@ class KubernetesAuthProvider(AuthProvider):
JWT_AUDIENCE = "llama-stack"
class JWKSAuthProviderConfig(BaseModel):
class JWTAuthProviderConfig(BaseModel):
"""Configuration for JWT token authentication provider."""
# The JWKS URI for collecting public keys
@ -189,10 +189,10 @@ class JWKSAuthProviderConfig(BaseModel):
cache_ttl: int = 3600
class JWKSAuthProvider(AuthProvider):
class JWTAuthProvider(AuthProvider):
"""JWT token authentication provider that validates tokens against the JWT token."""
def __init__(self, config: JWKSAuthProviderConfig):
def __init__(self, config: JWTAuthProviderConfig):
self.config = config
self._jwks_at: float = 0.0
self._jwks: dict[str, str] = {}
@ -334,8 +334,8 @@ def create_auth_provider(config: AuthProviderConfig) -> AuthProvider:
return KubernetesAuthProvider(KubernetesAuthProviderConfig.model_validate(config.config))
elif provider_type == "custom":
return CustomAuthProvider(CustomAuthProviderConfig.model_validate(config.config))
elif provider_type == "jwks":
return JWKSAuthProvider(JWKSAuthProviderConfig.model_validate(config.config))
elif provider_type == "jwt":
return JWTAuthProvider(JWTAuthProviderConfig.model_validate(config.config))
else:
supported_providers = ", ".join([t.value for t in AuthProviderType])
raise ValueError(f"Unsupported auth provider type: {provider_type}. Supported types are: {supported_providers}")

View file

@ -23,6 +23,7 @@ classifiers = [
dependencies = [
"blobfile",
"fire",
"jose",
"httpx",
"huggingface-hub",
"jinja2>=3.1.6",

View file

@ -23,6 +23,7 @@ huggingface-hub==0.29.0
idna==3.10
jinja2==3.1.6
jiter==0.8.2
jose==1.0.0
jsonschema==4.23.0
jsonschema-specifications==2024.10.1
kubernetes==32.0.1

4418
uv.lock generated

File diff suppressed because it is too large Load diff