Watch 1
Fork 0
You've already forked mosquitto-auth-authentik

Latest commit message

Francois Caron
33bba5f 2026-08-09 12:41:04 +00:00 11 commits

Mosquitto Auth Authentik

Service d'authentification MQTT utilisant Authentik OAuth au lieu de VoightKampff.

Fonctionnement

  • Mosquitto envoie les credentials MQTT (username + password) à ce service
  • Le password est un access token OAuth Authentik
  • Le service fait l'introspection OAuth pour valider le token
  • Retourne 200 si valide, 401 sinon

Configuration

1. Créer l'application OAuth dans Authentik

Via l'API ou l'interface web :

# Provider
Name: mosquitto-auth-provider
Client type: Confidential
Client ID: mosquitto-auth-client
Grant types: client_credentials

# Application
Name: mosquitto-auth
Slug: mosquitto-auth
Provider: mosquitto-auth-provider

Récupérer le CLIENT_SECRET généré.

2. Configurer le service

cp .env.example .env
# Éditer .env avec le CLIENT_ID et CLIENT_SECRET

3. Lancer le service

docker compose up -d

4. Mettre à jour Mosquitto

Dans la config Mosquitto (mosquitto.conf), changer :

auth_opt_http_host mosquitto-auth-authentik
auth_opt_http_port 8080

Au lieu de :

auth_opt_http_host voight-kampff
auth_opt_http_port 8080

Endpoints

  • POST /mqtt/user - Authentification (username + access token)
  • POST /mqtt/acl - Contrôle d'accès aux topics
  • POST /mqtt/superuser - Vérification superuser (toujours refuse)
  • GET /health - Health check

ACL Rules

  • users/{username}/* : Accès privé à son propre namespace
  • common/* : Lecture pour tous
  • reply/* : Écriture pour tous