Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better Compatibility with authinfo.gpg? #103

Closed
LdBeth opened this issue May 30, 2017 · 6 comments
Closed

Better Compatibility with authinfo.gpg? #103

LdBeth opened this issue May 30, 2017 · 6 comments
Labels
bug describes a defect in supported/advertised functionality

Comments

@LdBeth
Copy link

LdBeth commented May 30, 2017

I use authinfo.gpg, a GPG encrypted authinfo file, to manage my passwords in Emacs.
Thou I've configured gpg-agent to cache the main password, running Magithub before the first time the password is entered would cause connection to GitHub API timeout.

If it is possible to make Magithub waiting GPG's password prompt before connect to GtHub API or it is actually a upstream issue of ghub?

@vermiculus
Copy link
Owner

Magithub itself doesn't handle any authentication, so this is an upstream issue.

@LdBeth
Copy link
Author

LdBeth commented May 30, 2017

Thanks. I'll report it upstream.

@LdBeth LdBeth closed this as completed May 30, 2017
@LdBeth
Copy link
Author

LdBeth commented Jun 8, 2017

Sorry for reopen this issue, but I find that this snippet caused the my problem.

magithub-core.el: line 142

(let* (error-data
             (response (with-timeout (magithub-api-timeout :timeout)
                         (condition-case err (ghub-get "/rate_limit")
                           (error (setq error-data err) :errored-out))))

ghub.el prompts for the password if authinfo is encrypted when ghub-get is called, but magithub doesn't wait for users to input the password. If they can't input the password before magithub-api-timeout, an error of timeout would appear.

I wonder if it is possible to modify the above snippet to this:

(let* (error-data
       (response (if (= magithub-api-timeout 0)
                     (ghub-get "/rate_limit")
                   (progn
                     (with-timeout (magithub-api-timeout :timeout)
                       (condition-case err (ghub-get "/rate_limit")
                         (error (setq error-data err) :errored-out)))))))

Then if magithub-api-timeout is 0, timeout will be ignored.

After all, if there is no Internet connected, another error would be catch and magithub can go offline.

@LdBeth LdBeth reopened this Jun 8, 2017
@vermiculus
Copy link
Owner

Nice catch.

Hm… I'm not sure how I feel about your snippet (since any value instead of 0 (including 0) is somewhat arbitrary). I'm wondering if there's any way to pause the clock for the timeout while you're putting in your password.

Other than that – we could also just try unlocking your authinfo before calling this code. When emacs asks you for your password, this info is cached, yes? If you ask authinfo for credentials to another account, does Emacs asks you for your authinfo password again?

@vermiculus vermiculus added the bug describes a defect in supported/advertised functionality label Jul 30, 2017
@vermiculus
Copy link
Owner

I'm currently unable to get gpg-agent to cooperate with me on this one – it may take me some time to fix it.

If you can provide a snippet though that will do the following though, I can insert it (or you can in a PR) at magithub--api-available-p right before the first let.

  1. Check if the auth-source with the necessary keys is encrypted.
  2. If it's encrypted, decrypt it (not asking for any particular credential) before moving on.

@vermiculus
Copy link
Owner

I was over-complicating this. Commit incoming 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug describes a defect in supported/advertised functionality
Projects
None yet
Development

No branches or pull requests

2 participants