element-hq / element-hq/element-android

[SDK] Add delegate function to allow dynamic setting of headers for all requests from outside the SDK code

Open
#8,427 0 comments 0 reactions 0 assignees View on GitHub
matrix-sdk O-Uncommon S-Tolerable T-Enhancement
Dominant language
Kotlin
Stars
3.7k
Forks
917
PR merge metrics
No merged PRs in 30d

Description

### Description

**What would you like to do?**
Whenever a request is made to the matrix server from the matrix SDK (e.g. send message) then would like a delegate method to be called (which can be hooked into from the app) and extra headers can be set.

**Why would you like to do it?**
Set extra request headers for security.

**How would you like to achieve it?**
In the app be able to hook into a "onRequestBuild" delegate function and define your own dynamic headers...
matrixSdk.onRequestBuild = (requestBuilder: Request.Builder) {
requestBuilder.header("My-Authorization", "Bearer ${token}")
requestBuilder.header("Another-One", "another value")
requestBuilder.header("Local-Time", Datetime.now())
}

**Have you considered any alternatives?**
Yes only alternative is to copy all the SDK code into the app then make the adjustments directly to the SDK.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.