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
Flask extension for Pusher

Flask-Pusher Flask extension for Pusher. It is a thin wrapper around the official client, binding Flask app to Pusher client. Installation Install Fla

Iuri de Silvio 9 May 29, 2021
Flask Sitemapper is a small Python 3 package that generates XML sitemaps for Flask applications.

Flask Sitemapper Flask Sitemapper is a small Python 3 package that generates XML sitemaps for Flask applications. This allows you to create a nice and

6 Jan 06, 2023
flask-reactize is a boostrap to serve any React JS application via a Python back-end, using Flask as web framework.

flask-reactize Purpose Developing a ReactJS application requires to use nodejs as back end server. What if you want to consume external APIs: how are

Julien Chomarat 4 Jan 11, 2022
A basic JSON-RPC implementation for your Flask-powered sites

Flask JSON-RPC A basic JSON-RPC implementation for your Flask-powered sites. Some reasons you might want to use: Simple, powerful, flexible and python

Cenobit Technologies 272 Jan 04, 2023
A flask extension using pyexcel to read, manipulate and write data in different excel formats: csv, ods, xls, xlsx and xlsm.

Flask-Excel - Let you focus on data, instead of file formats Support the project If your company has embedded pyexcel and its components into a revenu

247 Dec 27, 2022
Set up a modern flask web server by running one command.

Build Flask App · Set up a modern flask web server by running one command. Installing / Getting started pip install build-flask-app Usage build-flask-

Kushagra Bainsla 5 Jul 16, 2022
Flask-Rebar combines flask, marshmallow, and swagger for robust REST services.

Flask-Rebar Flask-Rebar combines flask, marshmallow, and swagger for robust REST services. Features Request and Response Validation - Flask-Rebar reli

PlanGrid 223 Dec 19, 2022
A python package for integrating ripozo with Flask

flask-ripozo This package provides a dispatcher for ripozo so that you can integrate ripozo with Flask. As with all dispatchers it is simply for getti

Vertical Knowledge 14 Dec 03, 2018
SQLAlchemy database migrations for Flask applications using Alembic

Flask-Migrate Flask-Migrate is an extension that handles SQLAlchemy database migrations for Flask applications using Alembic. The database operations

Miguel Grinberg 2.2k Dec 28, 2022
Harmony, a discord clone, allows users to chat with other users in real time via servers, channels, and direct messages

Harmony, a discord clone, allows users to chat with other users in real time via servers, channels, and direct messages

Seth Holland 3 Feb 03, 2022
iloveflask is a Python library to collect functions that help a flask developer generate reports, config files and repeat code.

I Love Flask iloveflask is a Python library to collect functions that help a flask developer generate reports, config files and repeat code. Installat

2 Dec 29, 2021
REST API with mongoDB and Flask.

Flask REST API with mongoDB py 3.10 First, to install all dependencies: python -m pip install -r requirements.txt Second, into the ./src/ folder, cop

Luis Quiñones Requelme 3 Mar 05, 2022
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
YAML-formatted plain-text file based models for Flask backed by Flask-SQLAlchemy

Flask-FileAlchemy Flask-FileAlchemy is a Flask extension that lets you use Markdown or YAML formatted plain-text files as the main data store for your

Siddhant Goel 20 Dec 14, 2022
A fairly common feature in web applications to have links that open a popover when hovered

Add Popovers to Links in Flask App It is a fairly common feature in web applications to have links that open a popover when hovered. Twitter does this

Gitau Harrison 1 Jan 22, 2022
This is a Flask web app which predicts fare of Flight ticket

Flight Fare Prediction: Table of Content Demo Overview Motivation Installation Deployement on Heroku Directory Tree Bug / Feature Request Future scope

Ayshwarya 1 Jan 24, 2022
A gRpc server like Flask (像Flask一样的gRpc服务)

Mask A gRpc server just like Flask. Install Mask support pypi packages, you can simply install by: pip install mask Document Mask manual could be fou

吴东 16 Jun 14, 2022
A simple application builder. Made with python.

Python Flask Server Template Check the Github Repository for updates Flask is an application builder. It is very common in Python but can also be used

1 Jan 09, 2022
Python web-app (Flask) to browse Tandoor recipes on the local network

RecipeBook - Tandoor Python web-app (Flask) to browse Tandoor recipes on the local network. Designed for use with E-Ink screens. For a version that wo

5 Oct 02, 2022