spakky-openfga¶
Spakky Auth relation 인가를 위한 OpenFGA provider API입니다.
패키지 루트¶
OpenFGA relationship authorization provider plugin for Spakky Auth.
PLUGIN_NAME = Plugin(name='spakky-openfga')
module-attribute
¶
Plugin identifier for the OpenFGA auth provider package.
IOpenFgaCheckClient
¶
Bases: ABC
Boundary used by the auth provider to execute OpenFGA checks.
OpenFgaCheckRequest(*, user, relation, object)
dataclass
¶
OpenFgaCheckResult(*, allowed)
dataclass
¶
Provider-local check result.
allowed
instance-attribute
¶
Whether OpenFGA allowed the tuple check.
OpenFgaSdkCheckClient(config)
¶
Bases: IOpenFgaCheckClient
Synchronous OpenFGA SDK-backed check client.
Source code in plugins/spakky-openfga/src/spakky/plugins/openfga/client.py
check(request)
¶
Execute an OpenFGA check request with the official SDK.
Source code in plugins/spakky-openfga/src/spakky/plugins/openfga/client.py
OpenFgaConfig()
¶
Bases: BaseSettings
Runtime config for OpenFGA check-only authorization.
Source code in plugins/spakky-openfga/src/spakky/plugins/openfga/config.py
api_url = DEFAULT_OPENFGA_API_URL
class-attribute
instance-attribute
¶
OpenFGA API URL.
store_id = ''
class-attribute
instance-attribute
¶
OpenFGA store id used for check requests.
authorization_model_id = None
class-attribute
instance-attribute
¶
Optional authorization model id for check requests.
principal_type = DEFAULT_OPENFGA_USER_TYPE
class-attribute
instance-attribute
¶
OpenFGA object type prepended to principal ids without a type prefix.
tenant_separator = DEFAULT_OPENFGA_TENANT_SEPARATOR
class-attribute
instance-attribute
¶
Separator used to embed tenant refs into checked object ids.
include_tenant_in_object = True
class-attribute
instance-attribute
¶
Whether tenant refs are prefixed into OpenFGA object strings.
relation_check_available = True
class-attribute
instance-attribute
¶
Whether OpenFGA relationship checking is available at runtime.
AbstractOpenFgaError
¶
OpenFgaProviderUnavailableError
¶
OpenFgaReferenceMappingError
¶
OpenFgaAuthProvider(client, config)
¶
Bases: IRelationChecker, IAuthorizationPolicyEvaluator
OpenFGA check-only provider for ReBAC authorization decisions.
Source code in plugins/spakky-openfga/src/spakky/plugins/openfga/provider.py
check_relation(request)
¶
Check whether the subject has a relation to a resource.
Source code in plugins/spakky-openfga/src/spakky/plugins/openfga/provider.py
evaluate_policy(request)
¶
Map resource/action policy evaluation to an OpenFGA relation check.
Source code in plugins/spakky-openfga/src/spakky/plugins/openfga/provider.py
openfga_auth_provider_contribution()
¶
Return the auth capabilities contributed by spakky-openfga.
Source code in plugins/spakky-openfga/src/spakky/plugins/openfga/provider.py
플러그인 진입점¶
Plugin initialization for the OpenFGA auth provider.
initialize(app)
¶
Register OpenFGA check client and auth provider bindings.
Source code in plugins/spakky-openfga/src/spakky/plugins/openfga/main.py
Auth Provider¶
OpenFGA-backed auth provider for relationship authorization.
OpenFgaAuthProvider(client, config)
¶
Bases: IRelationChecker, IAuthorizationPolicyEvaluator
OpenFGA check-only provider for ReBAC authorization decisions.
Source code in plugins/spakky-openfga/src/spakky/plugins/openfga/provider.py
check_relation(request)
¶
Check whether the subject has a relation to a resource.
Source code in plugins/spakky-openfga/src/spakky/plugins/openfga/provider.py
evaluate_policy(request)
¶
Map resource/action policy evaluation to an OpenFGA relation check.
Source code in plugins/spakky-openfga/src/spakky/plugins/openfga/provider.py
openfga_auth_provider_contribution()
¶
Return the auth capabilities contributed by spakky-openfga.
Source code in plugins/spakky-openfga/src/spakky/plugins/openfga/provider.py
Client / Config¶
OpenFGA check client boundary and SDK adapter.
OpenFgaCheckRequest(*, user, relation, object)
dataclass
¶
OpenFgaCheckResult(*, allowed)
dataclass
¶
Provider-local check result.
allowed
instance-attribute
¶
Whether OpenFGA allowed the tuple check.
IOpenFgaCheckClient
¶
Bases: ABC
Boundary used by the auth provider to execute OpenFGA checks.
OpenFgaSdkCheckClient(config)
¶
Bases: IOpenFgaCheckClient
Synchronous OpenFGA SDK-backed check client.
Source code in plugins/spakky-openfga/src/spakky/plugins/openfga/client.py
check(request)
¶
Execute an OpenFGA check request with the official SDK.
Source code in plugins/spakky-openfga/src/spakky/plugins/openfga/client.py
Configuration for OpenFGA relationship checks.
OpenFgaConfig()
¶
Bases: BaseSettings
Runtime config for OpenFGA check-only authorization.
Source code in plugins/spakky-openfga/src/spakky/plugins/openfga/config.py
api_url = DEFAULT_OPENFGA_API_URL
class-attribute
instance-attribute
¶
OpenFGA API URL.
store_id = ''
class-attribute
instance-attribute
¶
OpenFGA store id used for check requests.
authorization_model_id = None
class-attribute
instance-attribute
¶
Optional authorization model id for check requests.
principal_type = DEFAULT_OPENFGA_USER_TYPE
class-attribute
instance-attribute
¶
OpenFGA object type prepended to principal ids without a type prefix.
tenant_separator = DEFAULT_OPENFGA_TENANT_SEPARATOR
class-attribute
instance-attribute
¶
Separator used to embed tenant refs into checked object ids.
include_tenant_in_object = True
class-attribute
instance-attribute
¶
Whether tenant refs are prefixed into OpenFGA object strings.
relation_check_available = True
class-attribute
instance-attribute
¶
Whether OpenFGA relationship checking is available at runtime.
에러¶
추가 모듈¶
Constants for the spakky-openfga plugin.
OPENFGA_AUTH_PROVIDER_ID = 'provider:spakky-openfga'
module-attribute
¶
Stable auth provider id advertised by spakky-openfga.
DEFAULT_OPENFGA_API_URL = 'http://localhost:8080'
module-attribute
¶
Default OpenFGA API URL for local development.
DEFAULT_OPENFGA_USER_TYPE = 'user'
module-attribute
¶
Default OpenFGA object type used for AuthContext principals.
DEFAULT_OPENFGA_TENANT_SEPARATOR = '/'
module-attribute
¶
Separator used when tenant refs are embedded into OpenFGA object ids.
SPAKKY_OPENFGA_CONFIG_ENV_PREFIX = 'SPAKKY_OPENFGA_'
module-attribute
¶
Environment variable prefix for OpenFGA provider settings.