5 Commits
0.9.4 ... 0.9.7

Author SHA1 Message Date
07ac2edb53 Fix admin groups parsing 2024-07-26 16:40:36 +02:00
50097ce5b3 Bump version 2024-07-26 15:52:09 +02:00
4b28db6a13 Sort routes 2024-07-26 15:51:54 +02:00
24ca9d59f6 Bump version 2024-07-26 12:16:50 +02:00
0500a468a1 Quick fix for exit node 2024-07-26 12:16:32 +02:00
5 changed files with 36 additions and 18 deletions

View File

@@ -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 | |

View File

@@ -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)

View File

@@ -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 @@
&nbsp; &nbsp;
</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 %}

View File

@@ -71,7 +71,7 @@ def node(nodeId):
node = Node().get(nodeId) node = Node().get(nodeId)
routes = Node().routes(nodeId) routes = Node().routes(nodeId)
isExitNode = any( isExitNode = any(
(r for r in routes.routes if r.prefix.endswith('/0') and r.enabled)) (r for r in routes.routes if r.prefix.endswith('0/0') and r.enabled))
return render_template("node.html", return render_template("node.html",
routes=routes.routes, routes=routes.routes,
isExitNode=isExitNode, isExitNode=isExitNode,
@@ -118,11 +118,11 @@ def user(userName):
def routes(): def routes():
routes = Route().list() routes = Route().list()
prefixes = set( prefixes = sorted(set(
(r.prefix for r in routes.routes if not r.prefix.endswith('/0'))) (r.prefix for r in routes.routes if not r.prefix.endswith('/0'))))
exitNodes = [r.node for r in routes.routes if r.prefix.endswith( exitNodes = [r.node for r in routes.routes if r.prefix.endswith(
'/0') and r.enabled] '0/0') and r.enabled]
final = {} final = {}
for prefix in prefixes: for prefix in prefixes:

View File

@@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "hsman" name = "hsman"
version = "0.9.4" 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"