Add support for access token based authentication
* Extend the configuration format in order to allow access_token, user_id and device_id instead of username and password * Move the matrix login logic outside of login_and_sync for clarity * Add support for access token based session resuming instead of logging in every time (thus creating a new device each time the service starts up) * Delay the startup of feed reader loops until after the matrix module has had a chance to actually check authentication This change is quite involved and there are a few caveats, namely an intentional race condition between the feed reader loops and matrix authentication, as well as significantly different behaviors depending on which authentication scheme is being used: password based authentication requires an API call while resuming a session using an access token does not.
This commit is contained in:
@ -27,12 +27,26 @@ pub struct FeedConfig {
|
||||
pub delay: u64
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
#[serde(untagged)]
|
||||
pub enum AuthConfig {
|
||||
PasswordAuthConfig {
|
||||
username: String,
|
||||
password: String,
|
||||
},
|
||||
TokenAuthConfig {
|
||||
user_id: String,
|
||||
device_id: String,
|
||||
access_token: String,
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
pub struct Config {
|
||||
pub default_room: String,
|
||||
pub feeds: Vec<FeedConfig>,
|
||||
pub username: String,
|
||||
pub password: String,
|
||||
#[serde(flatten)]
|
||||
pub auth: AuthConfig,
|
||||
pub homeserver_uri: String
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user