dorinclisu / fastapi-auth0

FastAPI authentication and authorization using auth0.com
MIT License
230 stars 39 forks source link

Make namespace an environment variable #6

Closed raaidarshad closed 3 years ago

raaidarshad commented 3 years ago

I don't see an issue template format and I haven't contributed much to OSS yet so forgive me if this is messy.

First, this is a great package! It worked very well for me, and I'd love to help make it even better.

I think it would make sense to set auth0_rule_namespace via environment (or through some other means, but environment is what seems simplest to me). I'd be happy to make a PR with the changes. This would allow users to set their own namespace for the rule in auth0. It would just change this line:

https://github.com/dorinclisu/fastapi-auth0/blob/66578c4c8d8c922646be83fad8f9486a518127cf/src/fastapi_auth0/auth.py#L15 to be: auth0_rule_namespace: str = os.getenv('AUTH0_RULE_NAMESPACE', 'https://github.com/dorinclisu/fastapi-auth0')

Do you think that'd work fine? If so, I'd be thrilled to make a PR for it (I know it's very small but I figure I'd start small).

dorinclisu commented 3 years ago

Hmm yes, I think it would work.

dorinclisu commented 3 years ago

Available from 0.2.0 (https://github.com/dorinclisu/fastapi-auth0/releases/tag/0.2.0)

Zaffer commented 2 years ago

Why don't we just pass this in as an option when declaring the Auth0 class? Just make it a parameter?

dorinclisu commented 2 years ago

Because the data model referencing this variable is not declared in the main Auth0 class. I think you could do it somehow with workarounds but with really ugly code.