Skip to main content

Thank you for the update.
With your new changes, the usage pattern of your library's singleton service has changed.

Now, before calling OpenFgaServiceSingleton.get_service(), you need to set the configuration via OpenFgaServiceSingleton.config = <YourConfigInstance>.
No configuration argument is accepted in get_service() anymore.


⏩ Updated Basic Setup & Usage

Step 1. Set configuration and initialize

from your_library import OpenFgaConfig, OpenFgaServiceSingleton

# 1. Create configuration as before
fga_config = OpenFgaConfig(
    store_name="my-store",
    model_version="1",
    model_obj={},  # your FGA model dict
    api_url="http://localhost:8080",  # or your FGA API endpoint
    redis_host="localhost",
    redis_password=None,
    redis_port="6379",
)

# 2. Set configuration on the singleton class BEFORE get_service()
OpenFgaServiceSingleton.config = fga_config

# 3. Now get the service
service = OpenFgaServiceSingleton.get_service()

# 4. Continue as before
await service.setup_store()
await service.setup_auth_model()
auth_model = await service.read_auth_model()
print(auth_model)

Example Usage: List objects

# Get the (already initialized) singleton service
fga = OpenFgaServiceSingleton.get_service()

# List object IDs of type 'doc' where 'user:alice' has 'reader' access
object_ids = await fga.list_objects("user:alice", "reader", "doc")
print(object_ids)

🔍 What changed?

  • You MUST set OpenFgaServiceSingleton.config = <YourConfig> before you try to instantiate the service.
  • If get_service() is called before .config is set, you get an Exception:

    "OpenFgaConfig must be set before getting the service instance."

  • Passing config in get_service(config) is no longer supported.

📦 Reusable Example

from your_library import OpenFgaConfig, OpenFgaServiceSingleton

fga_config = OpenFgaConfig(
    store_name="my-store",
    model_version="1",
    model_obj={},
    api_url="http://localhost:8080"
)
OpenFgaServiceSingleton.config = fga_config

service = OpenFgaServiceSingleton.get_service()
await service.setup_store()
await service.setup_auth_model()
auth_model = await service.read_auth_model()

object_ids = await service.list_objects("user:alice", "reader", "doc")
print(object_ids)

Be sure to always set .config before .get_service()!


Let me know if you would like an updated full documentation, code template, or anything else!

Metadata

Release files for oraczenhq-authorization 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for oraczenhq-authorization 0.0.3
File Size Uploaded
oraczenhq_authorization-0.0.3.tar.gz 4.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for oraczenhq-authorization 0.0.3
File Interpreter ABI Platform
oraczenhq_authorization-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 10.2 kB

Release files / oraczenhq_authorization-0.0.3.tar.gz

Download URL oraczenhq_authorization-0.0.3.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
bff20754303cc26eb9ede18dd1430f13c354df416ef13d40b9ba8a16329fb5f9
BLAKE2b-256 checksum
How to use checksums
5ab61220c32b2cb99f1131541ae8bbb670e4359ddf75148f2bd24fa75e4c4071
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.3

Release files / oraczenhq_authorization-0.0.3-py3-none-any.whl

Download URL oraczenhq_authorization-0.0.3-py3-none-any.whl
Size 5.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4df0fa6d5e2291621660f16fe44233eaeb776d65a7aa1dd73533324088017ddb
BLAKE2b-256 checksum
How to use checksums
818a55701c828d99b1a4d1e5de7b47e6c4a638bcf71dfbadd748070a22029ce6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.3

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page