Flask-pyoidc icon indicating copy to clipboard operation
Flask-pyoidc copied to clipboard

Lazy Load Provider Config

Open infohash opened this issue 1 year ago • 5 comments

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:

  • Issue: gh-171

infohash avatar Feb 29 '24 13:02 infohash

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

azmeuk avatar Mar 07 '24 18:03 azmeuk

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

infohash avatar Mar 07 '24 20:03 infohash

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

infohash avatar Mar 08 '24 11:03 infohash

:ok_hand: This works great!

azmeuk avatar Mar 08 '24 19:03 azmeuk

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

warrenhead avatar Jun 05 '24 09:06 warrenhead