Flask-pyoidc
Flask-pyoidc copied to clipboard
Lazy Load Provider Config
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
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
Thanks for noticing. I'll explore a better approach.
@azmeuk All it needed was a check to see if _provider_configurations exists or not. Thanks for reporting
:ok_hand: This works great!
@zamzterz Any chance of a new release with this PR, to pypi?