Glauth management ui created with python/flask

Related tags

Flaskglauth-ui
Overview

glauth-ui

Glauth-UI is a small flask web app i created to manage the minimal glauth ldap server. I created this as i wanted to use glauth for authentication in several service at home and at work, but since it is readonly there is no way for users to configure their own password for example.

Since i knew a bit of python and wanted to learn flask i thought i create a small webapp that acts as a management ui for glauth.

This should be considered as a prove of concept and some glauth features arent implemented yet as i have no use for them (yet). There are probably a lot of bugs in this and if you are using it you should limit the usage to the local network only.

Current features:

  • Stores Data (Glauth Settings, Users, Groups) in a SQL DB (Sqlite, MySQL, PostgreSQL are supported)
  • Generates a glauth compatible config.cfg file on every change to the db
  • Small UI for Endusers to change their password, name and email or reset their password (if forgotten).
  • Admin UI for managing settings and creating users and groups
  • eMail support for forgotten passwords and new user creation

Missing features:

  • Not all glauth settings and user options can be configured, following featurs and Options are missing:
    • API
    • Backend: nameformat, groupformat, sshkeyattr
    • User: loginShell, homeDir, sshkeys, passappsha256, otpsecret, yubikey

Installation:

The best installation method atm is to build the docker image with the included Dockerfile.

  1. Clone Repository
git clone https://github.com/sonicnkt/glauth-ui.git glauth-ui
  1. Run docker build
cd glauth-ui
docker build -t glauthui:latest . 

  1. Create container

docker-compose.yaml

version: '3.8'
services:
  glauthui:
    image: glauthui:latest
    container_name: glauthui
    restart: unless-stopped
    ports:
      - 80:5000
    volumes:
      # Mount Folder that contains DB and config file outside the container
      - './docker-data:/home/ldap/db'
    environment:
      - SECRET_KEY=mysuperlongsecretkeythatnobodywillguess
      # MAIL CONFIG
      - MAIL_SERVER=mail.example.com
      - MAIL_PORT=587
      - MAIL_USE_TLS=1
      - MAIL_USERNAME=username
      - MAIL_PASSWORD=password
      - [email protected]

docker-compose up #-d

On first startup (or if DB is empty) a sample database will be created with 2 users and 4 groups. Use the username "j_doe" and password "dogood" to login and have access to the administration interface.

This should be run behind a reverse proxy like nginx that handles https!

  1. Point glauth to the config.cfg created by glauth-ui

Environment Variables:

These can be set using environment variables using docker.

SECRET_KEY=

Should be a long random string to protect against CSRF attacks and should definatly be set in a production environment.

APPNAME=

Short name that will be displayed in the webapp and emails. Default = Glauth UI

ORGANISATION=

Longer organisations name that will show up in emails. Default = LDAP Management Team

ADMIN_GROUP=glauth_admin

Name of the glauth/ldap group which members have admin access to the ui (This can't be an included/nested group atm and must be assigned directly to the user)

FLASK_DEBUG=

Enable Debugging mode in Flask, never enable this for production environment! Default = False

MAIL_SERVER=mail.example.com
MAIL_PORT=587
MAIL_USE_TLS=1
MAIL_USERNAME=username
MAIL_PASSWORD=password
[email protected]

Configure your email provider, MAIL_ADMIN will show up as sender. Default = [email protected]

DATABASE_URL=

Sets the Databsae URI, Default is a sqlite app.db in the apps db/ subdirectory. For MySQL/Maria DB use mysql+pymysql://<user>:<password>@<server>:<port>/<db>. See also (https://flask-sqlalchemy.palletsprojects.com/en/2.x/config/#connection-uri-format) for more Options.

GLAUTH_CFG_PATH=

Sets the Glauth config.cfg path, Default is config.cfg in the apps db/ subdirectory.


Usage:

Login View: Login

After you spun up the container you can login with the sample user j_doe and the password dogood.

Main View: Login

In the main view normal user can change their names and email adress or change their password. Administrators also have access to a email test function and the admin interface.

Main Admin View: Login

In the Admin Interface you can configure your glauth settings, users and groups.

Admin User View: Login

Creating new users: Login

When you create a new user you have the option to send an invite link per mail, the account is disabled until they created their password.

If the password field is left blank when creating new users it will be autogenerated and displayed to the admin but only if the Invite Option is not enabled. Otherwise a random password and a token is generated for users to set their own.

Users without an email adress are not allowed to log into the ui (service accounts).

Admin Group View: Login

Creating new groups: Login

When you create a new group you can select if it is a primary group.

Editing secondary groups: Login

When you edit a non primary group you can assign users and set to include this group in other groups or configure the included groups.

Editing primary groups: Login

When you edit a primary group you can assign users and set which secondary groups it includes. Primary groups can't be included in other primary groups or secondary groups.

Editing glauth settings: Login

You can also change several glauth settings from the ui. These are also stored in the db and are used when generating a new config file so make sure these are correct. Changing those settings require you to restart glauth.

The glauth watchconfig option is missing here, it is automatically added as it is a dependancy for this to work correctly.


This would generate the following config.cfg:

## GLAUTH config backend configuration file

# General configuration
watchconfig = true
debug = true

[ldap]
  enabled = true
  listen = "0.0.0.0:389"

[ldaps]
  enabled = false

# Backend configuration
[backend]
  datastore = "config"
  baseDN = "dc=glauth-example,dc=com"


## LDAP Users configuration
[[users]]
  name = "j_doe"
  givenname = "Jane"
  sn = "Doe"
  mail = "[email protected]"
  unixid = 5001
  primarygroup = 5501
  passsha256 = "6478579e37aff45f013e14eeb30b3cc56c72ccdc310123bcdf53e0333e3f416a"
  otherGroups = [ 5551,5552,5553 ]

[[users]]
  name = "search"
  unixid = 5002
  primarygroup = 5502
  passsha256 = "125844054e30fabcd4182ae69c9d7b38b58d63c067be10ab5ab883d658383316"

[[users]]
  name = "jo_doe"
  givenname = "John"
  sn = "Doe"
  mail = "[email protected]"
  unixid = 5004
  primarygroup = 5501
  passsha256 = "3c8580d143af4b0585a84e7497978aafe550f8687ea52ceb180e8f884fd3319d"
  otherGroups = [ 5551,5552 ]
  disabled = True

## LDAP Groups configuration
[[groups]]
  name = "people"
  unixid = 5501
  # primary user group

[[groups]]
  name = "svcaccts"
  unixid = 5502
  # service accounts

[[groups]]
  name = "glauth_admin"
  unixid = 5551

[[groups]]
  name = "vpn"
  unixid = 5552
  includegroups = [ 5501 ]

[[groups]]
  name = "xmpp"
  unixid = 5553
  includegroups = [ 5501 ]
  # Prosody XMPP Users
Owner
Nils Thiele
Nils Thiele
a flask profiler which watches endpoint calls and tries to make some analysis.

Flask-profiler version: 1.8 Flask-profiler measures endpoints defined in your flask application; and provides you fine-grained report through a web in

Mustafa Atik 718 Dec 20, 2022
A team blog based on Flask

A team blog based on Flask This project isn't supported at the moment, please see a newer pypress-tornado Thanks for flask_website and newsmeme at [ht

老秋 549 Nov 10, 2022
Brandnew-flask is a CLI tool used to generate a powerful and mordern flask-app that supports the production environment.

Brandnew-flask is still in the initial stage and needs to be updated and improved continuously. Everyone is welcome to maintain and improve this CLI.

brandonye 4 Jul 17, 2022
A Cyberland server written in Python with Flask.

Cyberland What is Cyberland Cyberland is a textboard that offers no frontend. Most of the time, the user makes their own front end. The protocol, as f

Maxime Bouillot 9 Nov 26, 2022
Small flask based opds catalog designed to serve a directory via OPDS

teenyopds Small flask based opds catalog designed to serve a directory via OPDS, it has currently only been verified to work with KyBook 3 on iOS but

Adam Furbee 4 Jul 14, 2022
Rate Limiting extension for Flask

Flask-Limiter Flask-Limiter provides rate limiting features to flask routes. It has support for a configurable backend for storage with current implem

Ali-Akber Saifee 922 Jan 08, 2023
Adds Injector support to Flask.

Flask-Injector Adds Injector support to Flask, this way there's no need to use global Flask objects, which makes testing simpler. Injector is a depend

Alec Thomas 246 Dec 28, 2022
Flask Multiple Database Login

Flask Multiple Database Login Handle login with flask using two diferent databases: UE | European; BR | Brazilian; These databases are separed to resp

Jose Pedro 1 Dec 16, 2021
Beautiful Interactive tables in your Flask templates.

flask-tables Beautiful interactive tables in your Flask templates Resources Video demonstration: Go to YouTube video. Learn how to use this code: Go t

Miguel Grinberg 209 Jan 05, 2023
MongoEngine flask extension with WTF model forms support

Flask-MongoEngine Info: MongoEngine for Flask web applications. Repository: https://github.com/MongoEngine/flask-mongoengine About Flask-MongoEngine i

MongoEngine 815 Jan 03, 2023
The Snoopy boilerplate in flask framework for development enterprise application.

Snoopy What is snoopy! The "Snoopy" boilerplate in flask framework for development enterprise application. Motivation In my 10 years of development ex

Bekhzod 2 Sep 29, 2022
Flask-redmail - Email sending for Flask

Flask Red Mail: Email Sending for Flask Flask extension for Red Mail What is it?

Mikael Koli 11 Sep 23, 2022
Intranet de la Rez Flask web app

IntraRez Application Flask de l'Intranet de la Rez. Exigences Python : Probablement = 3.10 à terme, pour l'instant = 3.8 suffit ; Autres packages Li

3 Jul 03, 2022
Alexa Skills Kit for Python

Program the Amazon Echo with Python Flask-Ask is a Flask extension that makes building Alexa skills for the Amazon Echo easier and much more fun. Flas

John Wheeler 1.9k Dec 30, 2022
Flask Boilerplate - Paper Kit Design | AppSeed

Flask Paper Kit Open-Source Web App coded in Flask Framework - Provided by AppSeed Web App Generator. App Features: SQLite database SQLAlchemy ORM Ses

App Generator 86 Nov 29, 2021
Flask Web DRY full-stack framework by Problem Fighter

In the name of God, the Most Gracious, the Most Merciful. PF-Flask-Web Documentation Install and update using pip: pip install -U PF-Flask-Web Please

Problem Fighter 2 Jan 20, 2022
SeaSurf is a Flask extension for preventing cross-site request forgery (CSRF).

Flask-SeaSurf SeaSurf is a Flask extension for preventing cross-site request forgery (CSRF). CSRF vulnerabilities have been found in large and popular

Max Countryman 183 Dec 28, 2022
A simple demo of using aiogram + async sqlalchemy 1.4+

aiogram-and-sqlalchemy-demo A simple demo of using aiogram + async sqlalchemy 1.4+ Used tech: aiogram SQLAlchemy 1.4+ PostgreSQL as database asyncpg a

Aleksandr 68 Dec 31, 2022
An easy way to build your flask skeleton.

Flider What is Flider Flider is a lightweight framework that saves you time by creating a MVC compliant file structure and includes basic commonly use

Trevor Engen 8 Nov 17, 2022
A clean and simple blog system based on Flask and MongoDB

CleanBlog A clean and simple blog system based on Flask and MongoDB You can access CleanBlog This is the source code of Flask Tutorial Pro,you can buy

shin 107 Oct 06, 2022