Skip to content

Commit

Permalink
Merge pull request #64 from iFargle/inpage-search
Browse files Browse the repository at this point in the history
v0.6.0
  • Loading branch information
iFargle authored Mar 30, 2023
2 parents a098843 + 7cef7f4 commit 87d39e8
Show file tree
Hide file tree
Showing 30 changed files with 1,027 additions and 391 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ ENV TZ="UTC"
ENV COLOR="blue-grey"
ENV HS_SERVER=http://localhost/
ENV KEY=""
ENV SCRIPT_NAME=/
# ENV SCRIPT_NAME=/
ENV DOMAIN_NAME=http://localhost
ENV AUTH_TYPE=""
ENV LOG_LEVEL="Info"
Expand Down
38 changes: 30 additions & 8 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ pipeline {
label 'linux-x64'
}
environment {
APP_VERSION = 'v0.5.6'
HS_VERSION = "v0.20.0" // Version of Headscale this is compatible with
APP_VERSION = 'v0.6.0'
HS_VERSION = "v0.21.0" // Version of Headscale this is compatible with
BUILD_DATE = ''
BUILDER_NAME = "multiarch-${env.BRANCH_NAME}"
BUILDER_NAME = "multiarch-${env.BUILD_TAG}"


DOCKERHUB_CRED = credentials('dockerhub-ifargle-pat')

Expand All @@ -21,14 +22,11 @@ pipeline {
timestamps()
}
stages {
stage ('Jenkins ENV') {
stage('Build ENV') {
steps {

sh 'printenv'
script { BUILD_DATE = java.time.LocalDate.now() }
}
}
stage('Create Build ENV') {
steps {
sh """
# Create the builder:
docker buildx create --name $BUILDER_NAME --driver-opt=image=moby/buildkit
Expand Down Expand Up @@ -85,6 +83,30 @@ pipeline {
}
}
}
stage('Pull Test') {
steps {
script {
if (env.BRANCH_NAME == 'main') {
sh """
docker pull git.sysctl.io/albert/headscale-webui:latest
docker pull registry-1.docker.io/ifargle/headscale-webui:latest
docker pull ghcr.io/ifargle/headscale-webui:latest
docker pull git.sysctl.io/albert/headscale-webui:${APP_VERSION}
docker pull registry-1.docker.io/ifargle/headscale-webui:${APP_VERSION}
docker pull ghcr.io/ifargle/headscale-webui:${APP_VERSION}
"""
}
else {
sh """
docker pull git.sysctl.io/albert/headscale-webui:testing
docker pull ghcr.io/ifargle/headscale-webui:testing
docker pull git.sysctl.io/albert/headscale-webui:${env.BRANCH_NAME}
docker pull ghcr.io/ifargle/headscale-webui:${env.BRANCH_NAME}
"""
}
}
}
}
}
post {
always {
Expand Down
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
---
# Features
1. Enable/Disable routes and exit nodes
* Manage failover routes as well
2. Add, move, rename, and remove machines
3. Add and remove users/namespaces
4. Add and expire PreAuth keys
Expand All @@ -32,8 +33,13 @@
* Enable / disable routes and exit nodes
* Add and delete machine tags
7. Basic and OIDC Authentication
* OIDC Authentication tested with Authelia
* OIDC Authentication tested with Authelia and Keycloak
8. Change your color theme! See MaterializeCSS Documentation for Colors for examples.
9. Search your machines and users.
* Machines have tags you can use to filter search:
* `tag:tagname` Searches only for specific tags
* `machine:machine-name` Searches only for specific machines
* `user:user-name` Searches only for specific users


---
Expand All @@ -42,16 +48,11 @@

---
# Screenshots:
Overview Page:
![Overview](screenshots/oidc_overview.png)
Users Page:
![Overview](screenshots/overview.png)
![Routes](screenshots/routes.png)
![Machines](screenshots/machines.png)
![Users](screenshots/users.png)
Machine Information:
![Add a new machine](screenshots/machines_expanded.png)
Machines Page:
![Machine Details](screenshots/machines.png)
Settings Page showing an API Key Test:
![API Key Test](screenshots/settings.png)
![Settings](screenshots/settings.png)

---
# Tech used:
Expand Down
4 changes: 1 addition & 3 deletions SETUP.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
*PR's to help expand and improve documentation are always welcome!*
* Thanks to @FredericIV for assistance with Keycloak and Caddy
* Thanks to @qiangyt for assistance with general reverse proxy fixes and nginx

# Installation and Setup
* Use [docker-compose.yml](docker-compose.yml) as an example
Expand All @@ -17,7 +15,7 @@
* `TZ` - Set this to your current timezone. Example: `Asia/Tokyo`
* `COLOR` Set this to your preferred color scheme. See the [MaterializeCSS docs](https://materializecss.github.io/materialize/color.html#palette) for examples. Only set the "base" color -- ie, instead of `blue-gray darken-1`, just use `blue-gray`.
* `HS_SERVER` is the URL for your Headscale control server.
* `SCRIPT_NAME` is your "Base Path" for hosting. For example, if you want to host on http://localhost/admin, set this to `/admin`
* `SCRIPT_NAME` is your "Base Path" for hosting. For example, if you want to host on http://localhost/admin, set this to `/admin`, otherwise remove this variable entirely.
* `KEY` is your encryption key. Set this to a random value generated from `openssl rand -base64 32`
* `AUTH_TYPE` can be set to `Basic` or `OIDC`. See the [Authentication](#Authentication) section below for more information.
* `LOG_LEVEL` can be one of `Debug`, `Info`, `Warning`, `Error`, or `Critical` for decreasing verbosity. Default is `Info` if removed from your Environment.
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ services:
- COLOR=red # Use the base colors (ie, no darken-3, etc) -
- HS_SERVER=https://headscale.$DOMAIN # Reachable endpoint for your Headscale server
- DOMAIN_NAME=https://headscale.$DOMAIN # The base domain name for this container.
- SCRIPT_NAME=/admin # This is your applications base path (wsgi requires the name "SCRIPT_NAME")
- SCRIPT_NAME=/admin # This is your applications base path (wsgi requires the name "SCRIPT_NAME"). Remove if you are hosing at the root /
- KEY="YourKeyBetweenQuotes" # Generate with "openssl rand -base64 32" - used to encrypt your key on disk.
- AUTH_TYPE=oidc # AUTH_TYPE is either Basic or OIDC. Empty for no authentication
- LOG_LEVEL=info # Log level. "DEBUG", "ERROR", "WARNING", or "INFO". Default "INFO"
Expand Down
29 changes: 20 additions & 9 deletions headscale.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# pylint: disable=wrong-import-order

import requests, json, os, logging
import requests, json, os, logging, yaml
from cryptography.fernet import Fernet
from datetime import timedelta, date
from dateutil import parser
Expand All @@ -19,8 +19,21 @@
##################################################################
# Functions related to HEADSCALE and API KEYS
##################################################################

def get_url(): return os.environ['HS_SERVER']
def get_url(inpage=False):
if not inpage:
return os.environ['HS_SERVER']
config_file = ""
try:
config_file = open("/etc/headscale/config.yml", "r")
app.logger.info("Opening /etc/headscale/config.yml")
except:
config_file = open("/etc/headscale/config.yaml", "r")
app.logger.info("Opening /etc/headscale/config.yaml")
config_yaml = yaml.safe_load(config_file)
if "server_url" in config_yaml:
return str(config_yaml["server_url"])
app.logge.warning("Failed to find server_url in the config. Falling back to ENV variable")
return os.environ['HS_SERVER']

def set_api_key(api_key):
# User-set encryption key
Expand Down Expand Up @@ -194,9 +207,8 @@ def move_user(url, api_key, machine_id, new_user):
return response.json()

def update_route(url, api_key, route_id, current_state):
action = ""
if current_state == "True": action = "disable"
if current_state == "False": action = "enable"
action = "disable" if current_state == "True" else "enable"

app.logger.info("Updating Route %s: Action: %s", str(route_id), str(action))

# Debug
Expand Down Expand Up @@ -299,9 +311,8 @@ def get_routes(url, api_key):
}
)
return response.json()

##################################################################
# Functions related to NAMESPACES
# Functions related to USERS
##################################################################

# Get all users in use
Expand Down Expand Up @@ -370,7 +381,7 @@ def add_user(url, api_key, data):
return {"status": status, "body": response.json()}

##################################################################
# Functions related to PREAUTH KEYS in NAMESPACES
# Functions related to PREAUTH KEYS in USERS
##################################################################

# Get all PreAuth keys associated with a user "user_name"
Expand Down
15 changes: 15 additions & 0 deletions helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,21 @@ def key_check():
def get_color(import_id, item_type = ""):
""" Sets colors for users/namespaces """
# Define the colors... Seems like a good number to start with
if item_type == "failover":
colors = [
"teal lighten-1",
"blue lighten-1",
"blue-grey lighten-1",
"indigo lighten-2",
"brown lighten-1",
"grey lighten-1",
"indigo lighten-2",
"deep-orange lighten-1",
"yellow lighten-2",
"purple lighten-2",
]
index = import_id % len(colors)
return colors[index]
if item_type == "text":
colors = [
"red-text text-lighten-1",
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "headscale-webui"
version = "v0.5.6"
version = "v0.6.0"
description = "A simple web UI for small-scale Headscale deployments."
authors = ["Albert Copeland <[email protected]>"]
license = "AGPL"
Expand Down
Loading

0 comments on commit 87d39e8

Please sign in to comment.