Skip to content

Commit

Permalink
Only load authnz routes when oidc enabled
Browse files Browse the repository at this point in the history
We don't construct the necessary manager, so no use exposing API routes
that won't work:
```python
        self.authnz_manager = None
        if self.config.enable_oidc:
            from galaxy.authnz import managers

            self.authnz_manager = managers.AuthnzManager(
                self, self.config.oidc_config_file, self.config.oidc_backends_config_file
            )
```

Fixes galaxyproject#18682:
```
AttributeError: 'NoneType' object has no attribute 'get_allowed_idps'
(2 additional frame(s) were not displayed)
...
  File "galaxy/web/framework/middleware/statsd.py", line 29, in __call__
    req = self.application(environ, start_response)
  File "galaxy/web/framework/base.py", line 176, in __call__
    return self.handle_request(request_id, path_info, environ, start_response)
  File "galaxy/web/framework/base.py", line 271, in handle_request
    body = method(trans, **kwargs)
  File "galaxy/web/framework/decorators.py", line 74, in call_and_format
    rval = func(self, trans, *args, **kwargs)
  File "galaxy/webapps/galaxy/controllers/authnz.py", line 210, in get_cilogon_idps
    if allowed_idps := trans.app.authnz_manager.get_allowed_idps():

Uncaught Exception
```
  • Loading branch information
mvdbeek committed Aug 12, 2024
1 parent b0705ed commit 7a06ecb
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions lib/galaxy/webapps/galaxy/buildapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,18 @@ def app_pair(global_conf, load_app_kwds=None, wsgi_preflight=True, **kwargs):
webapp.add_route("/activate", controller="user", action="activate")

# Authentication endpoints.
webapp.add_route("/authnz/", controller="authnz", action="index", provider=None)
webapp.add_route("/authnz/{provider}/login", controller="authnz", action="login", provider=None)
webapp.add_route("/authnz/{provider}/callback", controller="authnz", action="callback", provider=None)
webapp.add_route(
"/authnz/{provider}/disconnect/{email}", controller="authnz", action="disconnect", provider=None, email=None
)
webapp.add_route("/authnz/{provider}/logout", controller="authnz", action="logout", provider=None)
webapp.add_route("/authnz/{provider}/create_user", controller="authnz", action="create_user")
# Returns the provider specific logout url for currently logged in provider
webapp.add_route("/authnz/logout", controller="authnz", action="get_logout_url")
webapp.add_route("/authnz/get_cilogon_idps", controller="authnz", action="get_cilogon_idps")
if app.config.enable_oidc:
webapp.add_route("/authnz/", controller="authnz", action="index", provider=None)
webapp.add_route("/authnz/{provider}/login", controller="authnz", action="login", provider=None)
webapp.add_route("/authnz/{provider}/callback", controller="authnz", action="callback", provider=None)
webapp.add_route(
"/authnz/{provider}/disconnect/{email}", controller="authnz", action="disconnect", provider=None, email=None
)
webapp.add_route("/authnz/{provider}/logout", controller="authnz", action="logout", provider=None)
webapp.add_route("/authnz/{provider}/create_user", controller="authnz", action="create_user")
# Returns the provider specific logout url for currently logged in provider
webapp.add_route("/authnz/logout", controller="authnz", action="get_logout_url")
webapp.add_route("/authnz/get_cilogon_idps", controller="authnz", action="get_cilogon_idps")

# These two routes handle our simple needs at the moment
webapp.add_route(
Expand Down

0 comments on commit 7a06ecb

Please sign in to comment.