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
4141user_id = "@user:example.com"
4242```
4343
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
4545`user_id` and you don't have a [`/.well-known`][well_known_entry] entry, then
4646you can explicitly specify the homeserver URL to use:
4747
config.example.toml +1
@@ -2,6 +2,7 @@ default_profile = "default"
22
33[profiles.default]
44user_id = "@user:matrix.org"
5password_file = "/path/to/password"
56url = "https://matrix.org"
67
78[settings]
docs/iamb.5 +3 −1
@@ -4,7 +4,7 @@
44.\" information, see <https://manpages.bsd.lv/mdoc.html>.
55.\"
66.\" You can preview this file with:
7.\" $ man ./docs/iamb.1
7.\" $ man ./docs/iamb.5
88.Dd Mar 24, 2024
99.Dt IAMB 5
1010.Os
@@ -75,6 +75,8 @@ object.
7575.It Sy user_id
7676The user ID to use when connecting to the server.
7777For 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.
7880.It Sy url
7981The URL of the user's server.
8082(For example "https://matrix.org" for "@user:matrix.org".)
src/config.rs +1
@@ -792,6 +792,7 @@ pub enum Layout {
792792#[derive(Clone, Deserialize)]
793793pub struct ProfileConfig {
794794 pub user_id: OwnedUserId,
795 pub password_file: Option<PathBuf>,
795796 pub url: Option<Url>,
796797 pub settings: Option<Tunables>,
797798 pub dirs: Option<Directories>,
src/main.rs +11
@@ -812,6 +812,17 @@ async fn login(worker: &Requester, settings: &ApplicationSettings) -> IambResult
812812 return Ok(());
813813 }
814814
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
815826 loop {
816827 let login_style =
817828 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 {
218218 profile_name: "test".into(),
219219 profile: ProfileConfig {
220220 user_id: user_id!("@user:example.com").to_owned(),
221 password_file: None,
221222 url: None,
222223 settings: None,
223224 dirs: None,