Fix admin groups parsing
This commit is contained in:
parent
50097ce5b3
commit
07ac2edb53
|
@ -17,10 +17,10 @@ You can run the Flask application as any other Flask app, using `flask run` insi
|
||||||
There are some settings that must/can be provided to the application:
|
There are some settings that must/can be provided to the application:
|
||||||
|
|
||||||
| Variable | Usage | Default |
|
| Variable | Usage | Default |
|
||||||
| -------------------------- | ---------------------------------------- | :-----: |
|
| -------------------------- | -------------------------------------------------------------- | :-----: |
|
||||||
| `APPLICATION_ROOT` | Base URI path for the app | `/` |
|
| `APPLICATION_ROOT` | Base URI path for the app | `/` |
|
||||||
| `HSMAN_SECRET_KEY` | Flask app secret key | |
|
| `HSMAN_SECRET_KEY` | Flask app secret key | |
|
||||||
| `HSMAN_ADMIN_GROUPS` | User groups that are considered admins | |
|
| `HSMAN_ADMIN_GROUPS` | Comma separated list of user groups that are considered admins | |
|
||||||
| `HSMAN_OIDC_CLIENT_ID` | OIDC client ID | |
|
| `HSMAN_OIDC_CLIENT_ID` | OIDC client ID | |
|
||||||
| `HSMAN_OIDC_CLIENT_SECRET` | OIDC clietn secret | |
|
| `HSMAN_OIDC_CLIENT_SECRET` | OIDC clietn secret | |
|
||||||
| `HSMAN_OIDC_URL` | OIDC server URL | |
|
| `HSMAN_OIDC_URL` | OIDC server URL | |
|
||||||
|
|
|
@ -29,6 +29,9 @@ def create_app(environment='development'):
|
||||||
app.config.from_prefixed_env(prefix="HSMAN")
|
app.config.from_prefixed_env(prefix="HSMAN")
|
||||||
config[env].configure(app)
|
config[env].configure(app)
|
||||||
app.config['APP_TZ'] = os.environ.get('TZ', 'UTC')
|
app.config['APP_TZ'] = os.environ.get('TZ', 'UTC')
|
||||||
|
app.config['ADMIN_GROUPS'] = list(
|
||||||
|
map(str.strip, app.config['ADMIN_GROUPS'].split(',')))
|
||||||
|
app.logger.debug(f"admin groups: {app.config['ADMIN_GROUPS']}")
|
||||||
|
|
||||||
app.logger.info("middleware init: mobility")
|
app.logger.info("middleware init: mobility")
|
||||||
mobility.init_app(app)
|
mobility.init_app(app)
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h3>Welcome, {{ session.userinfo.name }}</h3>
|
<h3>
|
||||||
|
Welcome, {{ session.userinfo.name }}
|
||||||
|
</h3>
|
||||||
<hr>
|
<hr>
|
||||||
<h4>authentication info</h4>
|
<h4>authentication info</h4>
|
||||||
<div class="row data">
|
<div class="row data">
|
||||||
|
@ -27,7 +29,13 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="col col-6">
|
<div class="col col-6">
|
||||||
<i class="fas fa-angle-right"></i>
|
<i class="fas fa-angle-right"></i>
|
||||||
|
{% if session.userinfo.groups[0] in config['ADMIN_GROUPS'] %}
|
||||||
|
<span class="badge badge-pill badge-warning">
|
||||||
|
{% else %}
|
||||||
|
<span class="badge badge-pill badge-dark">
|
||||||
|
{% endif %}
|
||||||
{{ session.userinfo.groups[0]}}
|
{{ session.userinfo.groups[0]}}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% for group in session.userinfo.groups[1:] |sort %}
|
{% for group in session.userinfo.groups[1:] |sort %}
|
||||||
|
@ -36,7 +44,14 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="col col-6">
|
<div class="col col-6">
|
||||||
<i class="fas fa-angle-right"></i> {{ group }}
|
<i class="fas fa-angle-right"></i>
|
||||||
|
{% if group in config['ADMIN_GROUPS'] %}
|
||||||
|
<span class="badge badge-pill badge-warning">
|
||||||
|
{% else %}
|
||||||
|
<span class="badge badge-pill badge-dark">
|
||||||
|
{% endif %}
|
||||||
|
{{ group }}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "hsman"
|
name = "hsman"
|
||||||
version = "0.9.6"
|
version = "0.9.7"
|
||||||
description = "Flask Admin webui for Headscale"
|
description = "Flask Admin webui for Headscale"
|
||||||
authors = ["Andrea Mistrali <andrea@mistrali.pw>"]
|
authors = ["Andrea Mistrali <andrea@mistrali.pw>"]
|
||||||
license = "BSD"
|
license = "BSD"
|
||||||
|
|
Loading…
Reference in New Issue