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 |
| 41 | 41 | user_id = "@user:example.com" |
| 42 | 42 | ``` |
| 43 | 43 | |
| 44 | | If you homeserver is located on a different domain than the server part of the |
| 44 | If your homeserver is located on a different domain than the server part of the |
| 45 | 45 | `user_id` and you don't have a [`/.well-known`][well_known_entry] entry, then |
| 46 | 46 | you can explicitly specify the homeserver URL to use: |
| 47 | 47 | |
config.example.toml
+1
| @@ -2,6 +2,7 @@ default_profile = "default" |
| 2 | 2 | |
| 3 | 3 | [profiles.default] |
| 4 | 4 | user_id = "@user:matrix.org" |
| 5 | password_file = "/path/to/password" |
| 5 | 6 | url = "https://matrix.org" |
| 6 | 7 | |
| 7 | 8 | [settings] |
docs/iamb.5
+3 −1
| @@ -4,7 +4,7 @@ |
| 4 | 4 | .\" information, see <https://manpages.bsd.lv/mdoc.html>. |
| 5 | 5 | .\" |
| 6 | 6 | .\" You can preview this file with: |
| 7 | | .\" $ man ./docs/iamb.1 |
| 7 | .\" $ man ./docs/iamb.5 |
| 8 | 8 | .Dd Mar 24, 2024 |
| 9 | 9 | .Dt IAMB 5 |
| 10 | 10 | .Os |
| @@ -75,6 +75,8 @@ object. |
| 75 | 75 | .It Sy user_id |
| 76 | 76 | The user ID to use when connecting to the server. |
| 77 | 77 | For example "user" in "@user:matrix.org". |
| 78 | .It Sy password_file |
| 79 | The path to the file containing the password to use when connecting to the server. |
| 78 | 80 | .It Sy url |
| 79 | 81 | The URL of the user's server. |
| 80 | 82 | (For example "https://matrix.org" for "@user:matrix.org".) |
src/config.rs
+1
| @@ -792,6 +792,7 @@ pub enum Layout { |
| 792 | 792 | #[derive(Clone, Deserialize)] |
| 793 | 793 | pub struct ProfileConfig { |
| 794 | 794 | pub user_id: OwnedUserId, |
| 795 | pub password_file: Option<PathBuf>, |
| 795 | 796 | pub url: Option<Url>, |
| 796 | 797 | pub settings: Option<Tunables>, |
| 797 | 798 | pub dirs: Option<Directories>, |
src/main.rs
+11
| @@ -812,6 +812,17 @@ async fn login(worker: &Requester, settings: &ApplicationSettings) -> IambResult |
| 812 | 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 | 826 | loop { |
| 816 | 827 | let login_style = |
| 817 | 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 | 218 | profile_name: "test".into(), |
| 219 | 219 | profile: ProfileConfig { |
| 220 | 220 | user_id: user_id!("@user:example.com").to_owned(), |
| 221 | password_file: None, |
| 221 | 222 | url: None, |
| 222 | 223 | settings: None, |
| 223 | 224 | dirs: None, |