diff options
author | Javier Sánchez Parra <jsanchez@soleta.eu> | 2022-08-02 17:06:13 +0200 |
---|---|---|
committer | Javier Sánchez Parra <jsanchez@soleta.eu> | 2022-09-27 09:48:35 +0200 |
commit | 2cbe6b774c8ffb10129f994d51f4237586331b7e (patch) | |
tree | 071773769ba1b518436e41ccdb7e1eb96bbe0657 /ogcp/views.py | |
parent | c4aa1f2f54d312581a70ad97e09198154f3840b3 (diff) |
Retreive scopes from several ogServers
Update the configuration file format to support several ogServers and
retrieve scopes from those ogServers.
The old config file format is still supported.
Diffstat (limited to 'ogcp/views.py')
-rw-r--r-- | ogcp/views.py | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/ogcp/views.py b/ogcp/views.py index 84bcc56..1ccd39b 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -25,7 +25,7 @@ from pathlib import Path from ogcp.models import User from ogcp.forms.auth import LoginForm, UserForm, DeleteUserForm -from ogcp.og_server import OGServer +from ogcp.og_server import servers from flask_babel import lazy_gettext as _l from flask_babel import _ from ogcp import app @@ -177,17 +177,24 @@ def get_allowed_scopes(scopes, allowed_scopes): get_allowed_scopes(scope, allowed_scopes) def get_scopes(ips=set()): - r = g.server.get('/scopes') - scopes = r.json() + list_scopes = [] + for server in servers: + r = server.get('/scopes') + scopes = r.json() + server_scope = {} + server_scope['name'] = server.name + server_scope.update(scopes) + list_scopes.append(server_scope) + all_scopes = {'scope': list_scopes} if current_user.scopes: allowed_scopes = [] - get_allowed_scopes(scopes, allowed_scopes) - scopes = {'scope': allowed_scopes} + get_allowed_scopes(all_scopes, allowed_scopes) + all_scopes = {'scope': allowed_scopes} r = g.server.get('/clients') clients = r.json() - add_state_and_ips(scopes, clients['clients'], ips) + add_state_and_ips(all_scopes, clients['clients'], ips) - return scopes, clients + return all_scopes, clients def hash_password(pwd): @@ -245,7 +252,7 @@ def load_user(username): @app.before_request def load_config(): - g.server = OGServer() + g.server = servers[0] @app.errorhandler(404) def page_not_found(error): |