Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Lazy Load Provider Config #173

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

infohash
Copy link
Contributor

Adds lazy loading of provider config to allow blueprint views to be decorated by auth decorators without initializing auth first. This will provide flexibility to import auth instance in blueprint modules before the Flask app instance becomes ready.

Fixes:

Adds lazy loading of provider config to allow blueprint views to be decorated by auth decorators
@azmeuk
Copy link

azmeuk commented Mar 7, 2024

I just tested. If endpoints are decorated before the call to init_app then a TypeError is raised:

endpoints.py:108: in <module>
    @auth.oidc_auth("default")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <flask_pyoidc.flask_pyoidc.OIDCAuthentication object at 0x7a2fdbe79ad0>, provider_name = 'default'

    def oidc_auth(self, provider_name: str):

>       if provider_name not in self._provider_configurations:
E       TypeError: argument of type 'NoneType' is not iterable

@infohash infohash marked this pull request as draft March 7, 2024 20:35
@infohash
Copy link
Contributor Author

infohash commented Mar 7, 2024

Thanks for noticing. I'll explore a better approach.

@infohash infohash marked this pull request as ready for review March 8, 2024 11:36
@infohash
Copy link
Contributor Author

infohash commented Mar 8, 2024

@azmeuk All it needed was a check to see if _provider_configurations exists or not. Thanks for reporting

@azmeuk
Copy link

azmeuk commented Mar 8, 2024

👌 This works great!

@warrenhead
Copy link

@zamzterz Any chance of a new release with this PR, to pypi?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants