# Feature SI-161 - Configure scopes to be used during Token Exchange

Project: Stream Integration Basics
Status: closed
URL: https://community.openproject.org/work_packages/SI-161

## Planning

| Attribute | Value |
| --- | --- |
| Date |  |
| Priority | Medium |
| Target versions | 16.1.0 |
| Votes |  |
| List |  |
| Roadmap |  |
| Relevance |  |

## OPEN POINTS / FEEDBACK

_No work packages_

## Use cases

_No work packages_

## Features and Chunks

_No work packages_

## Bugs and other work packages

_No work packages_

## Technical Details

| Attribute | Value |
| --- | --- |
| Module | Modules and project features / File storages, Authentication / OpenID Connect (OIDC) |
| Feature Flag |  |
| Requires doc change | Yes |
| Enterprise plan | Enterprise / Corporate (COR) |

## Details

| Attribute | Value |
| --- | --- |
| Pull preview |  |
| Mockups | https://www.figma.com/design/gtLQfPe09X7XugAH8L7dTy/File-Storages-Integration?node-id=10049-3390 |
| Accessibility | No |

## People

| Attribute | Value |
| --- | --- |
| Assignee |  |
| Accountable |  |
| Product manager |  |
| Feature Lead |  |
| Developers | Jan Sandbrink |
| Designer |  |
| Ordered by |  |
| Signed off by |  |
| Interest by |  |

## Estimates and progress

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

## Description

**As** an administrator  
**I want to** define scopes that will be requested during token exchange  
**so that** I can configure my application to request as few permissions as possible for all tokens

**Acceptance criteria**

  - Additional to configuration of the storage audience it's possible to configure scopes being requested during token exchange

  - If the user chooses to use the token received during login, no scopes can be configured (because no token exchange happens)

  - If the user chooses to perform a token exchange, exactly the configured scopes will be requested
    
      - i.e. they are **not additional** to scopes configured on the OIDC provider

**Technical notes**

Standard Token exchange in Keycloak has the following traits:

  - `audience` parameter can only be used to *filter* down audiences that are already present

  - `scope` parameter can be used to request optional scopes defined on the source client

  - thus *adding* an audience happens through default or optional scopes
    
      - To make sure an audience is **only** present in an exchanged token, the token needs to have a scope that the original token didn't have (i.e. optional scopes are necessary)

**Mockup**

<a href="https://www.figma.com/design/gtLQfPe09X7XugAH8L7dTy/File-Storages-Integration?node-id=10049-3390">https://www.figma.com/design/gtLQfPe09X7XugAH8L7dTy/File-Storages-Integration?node-id=10049-3390</a>
