Skip to content

Conversation

@imobachgs
Copy link
Contributor

Problems

  • CLI does not allow logging in to multiple systems #2261.
  • Any connection problem is reported as an certificate problem when it is not true. To make things worse, Agama asks the user whether to accept an insecure connection (even if that's not the problem).
  • Agama will perform an HTTP request even if it is not needed (e.g., agama auth show).

Solution

Storing one token per host

Instead of storing the token in $HOME/.agama/token, use a file ($HOME/.local/share/agama) containing all tokens (one per host). For instance:

{
  "192.168.122.145": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE3NDUzMTg2MTV9.G36w8NQ-ZCAkCQGGwjajRpd8EfkOM8fFLLfGjzTAqP0"
}

Do not ask for insecure connections

If there is a problem when connecting to the API, just report the error (no matter whether it is an SSL problem or not). The user can use the --insecure flag to disable certificate checks.

Testing

  • Added a new unit test
  • Tested manually

@imobachgs imobachgs changed the title Allow authenticating into multiple hosts feat(rust): allow authenticating into multiple hosts Apr 21, 2025
@imobachgs imobachgs marked this pull request as ready for review April 21, 2025 11:54
Copy link
Contributor

@teclator teclator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@ancorgs ancorgs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can confirm the conflict was properly resolved. I didn't check the rest, but I will rely on previous @teclator approval to say that this LGTM.

@imobachgs imobachgs merged commit 3e7a15c into master Apr 21, 2025
9 checks passed
@imobachgs imobachgs deleted the multi-host-tokens branch April 21, 2025 14:36
Copy link
Contributor

@mvidner mvidner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When there is any problem with the file storing the authentication tokens, do we tell the user where it is (agama auth login --help?) or do they have to resort to strace?

Also, my testing use cases involve multiple agamas on the same host but different ports. I hope it continues to work :)

#[error("Unexpected type on D-Bus '{0}'")]
ZVariant(#[from] zvariant::Error),
#[error("Failed to communicate with the HTTP backend '{0}'")]
#[error(transparent)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat!

@imobachgs imobachgs mentioned this pull request Apr 22, 2025
imobachgs added a commit that referenced this pull request Apr 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants