Commit 499f83af29

499f83af29f332720a6f3a2ee3671fdfd6658ca8

parent: c6d42d038f

Unregistered key

zivarah <brianmlyles@gmail.com> · 2026-07-24 18:01 UTC
committer: <noreply@github.com>

Support login via a configured password file (#558)

Layout: unified · split

README.md +1 −1
@@ -41,7 +41,7 @@ You can create a basic configuration in `$CONFIG_DIR/iamb/config.toml` that look
41user_id = "@user:example.com" 41user_id = "@user:example.com"
42``` 42```
43 43
44If you homeserver is located on a different domain than the server part of the 44If your homeserver is located on a different domain than the server part of the
45`user_id` and you don't have a [`/.well-known`][well_known_entry] entry, then 45`user_id` and you don't have a [`/.well-known`][well_known_entry] entry, then
46you can explicitly specify the homeserver URL to use: 46you can explicitly specify the homeserver URL to use:
47 47
config.example.toml +1
@@ -2,6 +2,7 @@ default_profile = "default"
2 2
3[profiles.default] 3[profiles.default]
4user_id = "@user:matrix.org" 4user_id = "@user:matrix.org"
5password_file = "/path/to/password"
5url = "https://matrix.org" 6url = "https://matrix.org"
6 7
7[settings] 8[settings]
docs/iamb.5 +3 −1
@@ -4,7 +4,7 @@
4.\" information, see <https://manpages.bsd.lv/mdoc.html>. 4.\" information, see <https://manpages.bsd.lv/mdoc.html>.
5.\" 5.\"
6.\" You can preview this file with: 6.\" You can preview this file with:
7.\" $ man ./docs/iamb.1 7.\" $ man ./docs/iamb.5
8.Dd Mar 24, 2024 8.Dd Mar 24, 2024
9.Dt IAMB 5 9.Dt IAMB 5
10.Os 10.Os
@@ -75,6 +75,8 @@ object.
75.It Sy user_id 75.It Sy user_id
76The user ID to use when connecting to the server. 76The user ID to use when connecting to the server.
77For example "user" in "@user:matrix.org". 77For example "user" in "@user:matrix.org".
78.It Sy password_file
79The path to the file containing the password to use when connecting to the server.
78.It Sy url 80.It Sy url
79The URL of the user's server. 81The URL of the user's server.
80(For example "https://matrix.org" for "@user:matrix.org".) 82(For example "https://matrix.org" for "@user:matrix.org".)
src/config.rs +1
@@ -792,6 +792,7 @@ pub enum Layout {
792#[derive(Clone, Deserialize)] 792#[derive(Clone, Deserialize)]
793pub struct ProfileConfig { 793pub struct ProfileConfig {
794 pub user_id: OwnedUserId, 794 pub user_id: OwnedUserId,
795 pub password_file: Option<PathBuf>,
795 pub url: Option<Url>, 796 pub url: Option<Url>,
796 pub settings: Option<Tunables>, 797 pub settings: Option<Tunables>,
797 pub dirs: Option<Directories>, 798 pub dirs: Option<Directories>,
src/main.rs +11
@@ -812,6 +812,17 @@ async fn login(worker: &Requester, settings: &ApplicationSettings) -> IambResult
812 return Ok(()); 812 return Ok(());
813 } 813 }
814 814
815 if let Some(ref password_file) = settings.profile.password_file {
816 if let Err(e) = std::fs::read_to_string(password_file)
817 .map(|password| worker.login(LoginStyle::Password(password)))
818 {
819 println!("Failed to log in using password file {password_file:?}: {e}");
820 println!("Continuing on to interactive login");
821 } else {
822 return Ok(());
823 }
824 }
825
815 loop { 826 loop {
816 let login_style = 827 let login_style =
817 match read_response("Please select login type: [p]assword / [s]ingle sign on") 828 match read_response("Please select login type: [p]assword / [s]ingle sign on")
src/tests.rs +1
@@ -218,6 +218,7 @@ pub fn mock_settings() -> ApplicationSettings {
218 profile_name: "test".into(), 218 profile_name: "test".into(),
219 profile: ProfileConfig { 219 profile: ProfileConfig {
220 user_id: user_id!("@user:example.com").to_owned(), 220 user_id: user_id!("@user:example.com").to_owned(),
221 password_file: None,
221 url: None, 222 url: None,
222 settings: None, 223 settings: None,
223 dirs: None, 224 dirs: None,