Skip to main content

Authorization client

Project description

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!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

oraczenhq_authorization-0.0.2.tar.gz (2.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

oraczenhq_authorization-0.0.2-py3-none-any.whl (2.4 kB view details)

Uploaded Python 3

File details

Details for the file oraczenhq_authorization-0.0.2.tar.gz.

File metadata

  • Download URL: oraczenhq_authorization-0.0.2.tar.gz
  • Upload date:
  • Size: 2.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for oraczenhq_authorization-0.0.2.tar.gz
Algorithm Hash digest
SHA256 73350d43e9ad563c79c96629ce5d3feba9c01898c76587d0399dc4c3d3975a37
MD5 bd0d255ecb8a8cced41242e18641f2f5
BLAKE2b-256 24cc88a8bea6d2c1c8c1b1aaa2debd8ce60032788a77cd578c3d548ae2b266bc

See more details on using hashes here.

File details

Details for the file oraczenhq_authorization-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for oraczenhq_authorization-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 24dfe36edd0fd1c4f4399a1fb7a36aa52ab8e3d7054a4d9172acca75886f817a
MD5 33ca3f36d087c2b919670408894d43c5
BLAKE2b-256 b5f63d3086ef5138e68b95d4e27efaa234906a341ac313ac81fd4583027cec71

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page