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

Read authinfo for user and password information #52

Open
FrancescElies opened this issue Jun 29, 2017 · 5 comments
Open

Read authinfo for user and password information #52

FrancescElies opened this issue Jun 29, 2017 · 5 comments

Comments

@FrancescElies
Copy link
Contributor

Hi,

I found the following issue, but I am not sure if I am missing something, does anyone know what is going on?

Thanks in advance for your help.

Context

Problem: es-mode does not read .authinfo but a es-mode block in org-mode does.

Description

The following works really nice in org-mode buffer

Buffer content:

#+srcname: list indices
#+BEGIN_SRC es
GET /_cat/indices?v&pretty
#+END_SRC

Outcome:

#+RESULTS: list indices
#+begin_example
health status index                         uuid                   pri rep docs.count docs.deleted store.size pri.store.size
yellow open   .watcher-history-3-2017.06.28 2t3Io9wRRN6shonkQZkXvA   1   1       2094            0      1.6mb          1.6mb
yellow open   .monitoring-es-2-2017.06.28   _YJHpwPfTcKGxDiM-TGNJQ   1   1      32073          110     14.4mb         14.4mb
...
#+end_example

In this case the src-block reads the content of authinfo and uses it to set the headers in the request.

But if I do the same request in es-mode it does not work, see Steps to Test.

Steps to Test

  1. Pull elasticsearch image from docker and run it

    docker pull elasticsearch
    docker run -p 9200:9200 -e "http.host=0.0.0.0" -e "transport.host=127.0.0.1" docker.elastic.co/elasticsearch/elasticsearch:5.4.3
    
  2. This image has a default user and password, add the following line to ~/.authinfo.gpg

    machine localhost login elastic password changeme port 9200
    
  3. Open scratch buffer and set es-mode

  4. Insert the following text

GET /_cat/indices?v&pretty
  1. Execute it C-c C-c
  2. I see:
{
  "error" : {
    "root_cause" : [
      {
        "type" : "security_exception",
        "reason" : "missing authentication token for REST request [/_cat/indices?v&pretty]",
        "header" : {
          "WWW-Authenticate" : "Basic realm=\"security\" charset=\"UTF-8\""
        }
      }
    ],
    "type" : "security_exception",
    "reason" : "missing authentication token for REST request [/_cat/indices?v&pretty]",
    "header" : {
      "WWW-Authenticate" : "Basic realm=\"security\" charset=\"UTF-8\""
    }
  },
  "status" : 401
}
@dakrone
Copy link
Owner

dakrone commented Jun 29, 2017

Problem: es-mode does not read .authinfo but a es-mode block in org-mode does.

I believe this may be due to es-mode using a different http request library than org-mode does, but I can look into this!

@FrancescElies
Copy link
Contributor Author

Thanks for your answer, by the way I was gladly surprised that it worked with .authinfo.gpg 👍
Is there any other way of setting user and password for the requests?
I'll also investigate this a bit more and report back any findings.

All best and thanks

@dakrone
Copy link
Owner

dakrone commented Jul 4, 2017

(for my reference) looks like I could use the auth-source library to access the .authinfo.gpg file to get the credentials needed https://www.gnu.org/software/emacs/manual/html_mono/auth.html

@FrancescElies
Copy link
Contributor Author

Closing, I am not using this since a long time and I feel nothing will happen here, thanks for your help.

@dakrone
Copy link
Owner

dakrone commented Dec 4, 2019

I'd prefer to leave this open, I do think it would be an interesting feature, and you never know when I (or someone!) would have time to work on it.

@dakrone dakrone reopened this Dec 4, 2019
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

No branches or pull requests

2 participants