Authentification OAuth2 sur le client FairEmail avec LemonLDAP::NG

Prérequis

Avoir un serveur mail configuré avec les mécanismes d'authentification oauthbearer et xoauth2
Pour Dovecot : https://doc.dovecot.org/2.4.5/core/config/auth/databases/oauth2.html

Ajout d'un Relying Party dans LemonLDAP::NG

Dans le manager LemonLDAP::NG, vous devez créer un nouveau OpenID Connect Relying Party.

OpenID Connect Relying Parties puis, Add OpenID Connect Relying Party
 

OpenID Connect RP Name: rp-fairmail

  • Basic 

Public client: On
Client ID: <set_client_id>
Allowed redirection addresses for login: https://oauth.faircode.eu/

  • Options > Advanced

Bypass consent: On
Use refresh tokens: On

  • Options > Security

Require PKCE: required
Invalidate refresh tokens after use: On
Allow offline access: On
Allow Native SSO for Mobile App: On
Allow OAuth2.0 Password Grant: On
Allow OAuth2.0 Client Credentials Grant: On

Configuration du client Fairmail

Dans FairMail, l'ajout d'un nouveau provider OAuth doit se faire manuellement

Since version 1.1859 there is support for custom OAuth. To use custom OAuth, an XML file containing the server and OAuth data, like the client secret, should be created and imported. Please see here about how the XML file should look like. The XML file can be imported via a button in the debug panel of the miscellaneous settings of the app. To show the debug panel, debug mode mode should temporarily be enabled. After importing, you can use the quick setup wizard to configure an account.

Créer un fichier provider.xml en remplaçant, les clefs name, description, id, link,   host, authorizationEndpoint, clientId et tokenEndpoint.
Importez-le dans votre ordiphone et dans les miscellaneous settings cochez temporairement la case debug mode et importer votre provider custom

<?xml version="1.0" encoding="utf-8"?>
<providers>
 <provider
   name="Exemple"
   alt="true"
   description="exemple.com"
   id="ssoexemple"
   link="https://sogo.exemple.com"
   maxtls="1.2"
   partial="false"
   useip="false">
   <imap
     host="mail.exemple.com"
     port="143"
     starttls="true" />
   <smtp
     host="mail.exemple.com"
     port="587"
     starttls="true" />
   <oauth
     askAccount="true"
     authorizationEndpoint="https://sso.exemple.com/oauth2/authorize"
     clientId="CLIENT_ID"
     enabled="true"
     prompt="login"
     redirectUri="https://oauth.faircode.eu/"
     scopes="profile,openid,email,offline_access"
     tokenEndpoint="https://sso.exemple.com/oauth2/token"
     pcke="true"
     tokenScopes="true">
   </oauth>
 </provider>
</providers>

Add new comment