# Feature ITSM-41 - Login flow for OAuth mailboxes

Project: Stream IT service management (ITSM)
Status: specified
URL: https://community.openproject.org/work_packages/ITSM-41

## Planning

| Attribute | Value |
| --- | --- |
| Date |  |
| Priority | Medium |
| Target versions | 18.1.0 |
| Votes |  |
| List |  |
| Roadmap | 2027 Q1 |
| Relevance |  |

## OPEN POINTS / FEEDBACK

_No work packages_

## Features and Chunks

_No work packages_

## Bugs and other work packages

_No work packages_

## Technical Details

| Attribute | Value |
| --- | --- |
| Module |  |
| Feature Flag |  |
| Requires doc change | No |
| Enterprise plan |  |

## Details

| Attribute | Value |
| --- | --- |
| Pull preview |  |
| Mockups |  |
| Accessibility | No |

## People

| Attribute | Value |
| --- | --- |
| Assignee |  |
| Accountable |  |
| Product manager | Nova Bonic |
| Feature Lead |  |
| Developers | OP Dev Titan Team |
| Designer | Marc Alcobé |
| Ordered by |  |
| Signed off by |  |
| Interest by |  |

## Estimates and progress

| Attribute | Value |
| --- | --- |
| PD (min) |  |
| PD (max) |  |
| Work |  |
| Labor costs |  |

## Description

## Goal

In order to enable **mail servers** that are set up with **OAuth**, we need to add a new login flow on both the instance admin and project settings levels.

## Steps

For all forms where mail servers and mailboxes (**IMAP** and **SMTP**) are configured, we need to adapt them as follows.

**Mail servers**

  - Authentication type: Plain-text password (meaning `LOGIN` or `PLAIN`) or OAuth2 (meaning `XOAUTH2`)

  - If the authentication is `OAuth2`, the options become a bit more involved. The following options are shown to the instance admin:
    
      - Authorization endpoint URL
    
      - Token endpoint URL
    
      - Authorization flow (*Authorization Code* or *Client Credentials*, defaults to Authorization Code)
    
      - If Client Credentials
        
          - Tenant ID (Microsoft-specific)
    
      - If Authorization Code
        
          - Tenant ID (Microsoft-specific)
        
          - Client ID
        
          - Client Secret
    
      - Scopes (Default: `openid profile email mail offline_access`)

**Mailboxes**

  - If the authentication is `OAuth2`, the following options are shown:
    
      - Client ID (only with *Client Credentials* flow)
    
      - Client Secret (only with *Client Credentials* flow)
    
      - *(only for incoming mail)* Email (Default: *automatic*, extracted from the `email`, `verified_email`, `username`, `preferred_username` claims)

If the authentication process involves OAuth2 and Authorization Code, the user should be redirected to their login provider to obtain a token. In all cases, the obtained credentials should be tested. The **refresh token** should also be tested, otherwise the tokens may not work later.

For <mention class="mention" data-id="81596" data-type="work_package" data-text="###ITSM-32" data-display-id="ITSM-32">\#\#\#ITSM-32</mention>, if the IMAP inbox is configured for OAuth2, the ingestion process may need to use the refresh token.
