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

JIRA_AUTH_TYPE has no effect #353

Closed
snogge opened this issue Apr 28, 2022 · 8 comments
Closed

JIRA_AUTH_TYPE has no effect #353

snogge opened this issue Apr 28, 2022 · 8 comments

Comments

@snogge
Copy link

snogge commented Apr 28, 2022

I'm trying to run jira init with JIRA_AUTH_TYPE=bearer, but it does not seem to have any effect

export JIRA_AUTH_TYPE=bearer
# Using Personal Access Token
export JIRA_API_TOLKEN=XXXXXXXXXXXXXXX
jira  --debug init

Select local, add server address, add username

EQUEST DETAILS
------------------------------------------------------------

GET /rest/api/2/myself HTTP/1.1
Host: jira.XXX.com
Authorization: Basic XXXXXXXXXXXXXXXXX



RESPONSE DETAILS
------------------------------------------------------------

HTTP/1.1 403 
Transfer-Encoding: chunked
Connection: keep-alive
Content-Security-Policy: frame-ancestors 'self'
Content-Type: text/html;charset=UTF-8
Date: Thu, 28 Apr 2022 13:13:21 GMT
Referrer-Policy: strict-origin-when-cross-origin
Server: nginx/1.18.0 (Ubuntu)
Set-Cookie: JSESSIONID=33B72F8A54298D305C919E1283E856D7; Path=/; Secure; HttpOnly
Strict-Transport-Security: max-age=31536000
Www-Authenticate: OAuth realm="https%3A%2F%2Fjira.XXX.com"
X-Arequestid: 913x21468273x1
X-Asessionid: 1i9r6b2
X-Authentication-Denied-Reason: CAPTCHA_CHALLENGE; login-url=https://jira.XXX.com/login.jsp
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Seraph-Loginreason: AUTHENTICATION_DENIED
X-Xss-Protection: 1; mode=block

It looks like the authentication header is wrong.

curl --oauth2-bearer XXXXXXXXXXXXXXXX https://jira.XXX.com/rest/api/2/myself 

Works and returns the expected JSON response.

Please provide following details

  1. JiraCLI Version:
    (Version="0.3.0", GitCommit="ea53355d5b72994a5b17a63e6e800ce9d8a23f4e", CommitDate="2022-01-09T19:50:19+00:00", GoVersion="go1.17.5", Compiler="gc", Platform="linux/amd64")
    
  2. Are you using Jira cloud or on-premise jira server? Also mention the version for on-premise installation.
    Jira Server v8.20.1
    
  3. What operating system are you using? Also mention version.
    Debian 10
    
  4. What terminal are you using? Also mention version.
    GNOME Terminal 3.30.2 using VTE 0.54.2 +GNUTLS
    
@ankitpokhrel
Copy link
Owner

Hi @snogge, this feature is not released yet so you need to use the build from main branch. You can either compile it locally or use following command to install (requires go1.16+).

go install github.com/ankitpokhrel/jira-cli/cmd/jira@latest

@snogge
Copy link
Author

snogge commented Apr 29, 2022

Building master made JIRA_AUTH_TYPE work, thank you.
But jira does not remember the auth type, so I have to always have it set in the environment. I think it would be better to have this in the config file as it is not likely to change.

@ankitpokhrel
Copy link
Owner

@snogge You have 2 choices here:

  1. Export JIRA_AUTH_TYPE so that it is always available in your shell.
  2. Modify the config file directly. You need to add a new entry auth_type: bearer in your config and the tool should pick this up. Unfortunately, there is no command to update config file (for now) so you will have to rely on the manual edit.

@snogge
Copy link
Author

snogge commented Apr 29, 2022

Thank you, adding it to the config file worked. I'm not a fan of setting this type of environment variables when there is a config file.
I think it would be great if auth_type:bearer was added to the config file by the setup command.

@ankitpokhrel
Copy link
Owner

I think it would be great if auth_type:bearer was added to the config file by the setup command.

Thank you for the feedback. It may not happen soon but there is a plan to work on a config command (similar to git config) that will let you control the configurations.

@TGPSKI
Copy link

TGPSKI commented May 3, 2022

Is there an example of a config file somewhere? I am stuck on this problem and without an example I am struggling to create a config file where I can change the auth type.

Edit: no longer stuck

@TGPSKI
Copy link

TGPSKI commented May 3, 2022

I'll add that running go install github.com/ankitpokhrel/jira-cli/cmd/jira@latest did not result in a working binary for bearer token type. When I cloned the repo and ran the makefile directives (build / install), then I was unblocked.

@helmecke
Copy link

helmecke commented May 5, 2022

I'll add that running go install github.com/ankitpokhrel/jira-cli/cmd/jira@latest did not result in a working binary for bearer token type. When I cloned the repo and ran the makefile directives (build / install), then I was unblocked.

You have to install from main branch with go install github.com/ankitpokhrel/jira-cli/cmd/jira@main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants