ankitpokhrel / jira-cli

🔥 Feature-rich interactive Jira command line.
MIT License
3.99k stars 208 forks source link

Not working with Red Hat's jira instance #323

Closed ericcurtin closed 2 years ago

ericcurtin commented 2 years ago

Been trying to use this with issues.redhat.com but get a 403 response. Red Hat is using Jira more and more, we are even migrating from bugzilla to Jira now so any help would be appreciated as many people in the open source community use this Jira instance

https://lists.centos.org/pipermail/centos-devel/2022-March/120269.html

ankitpokhrel commented 2 years ago

Hi @ericcurtin, thank you for opening the issue. Supporting public Jira instance is something on my todo list and I will check what can I do here. Meanwhile if you can provide any helpful info or a PR to support this, please feel free to do so :)

ericcurtin commented 2 years ago

Here's some curl output if that helps:

$ curl --request GET 'https://issues.redhat.com/rest/api/3/myself' --user "ecurtin@redhat.com:$JIRA_API_TOKEN"

<html>

<head>
    <title>Forbidden (403)</title>

<!--[if IE]><![endif]-->
<script type="text/javascript">
    (function() {
        var contextPath = '';

        function printDeprecatedMsg() {
            if (console && console.warn) {
                console.warn('DEPRECATED JS - contextPath global variable has been deprecated since 7.4.0. Use `wrm/context-path` module instead.');
            }
        }

        Object.defineProperty(window, 'contextPath', {
            get: function() {
                printDeprecatedMsg();
                return contextPath;
            },
            set: function(value) {
                printDeprecatedMsg();
                contextPath = value;
            }
        });
    })();

</script>
<script>
window.WRM=window.WRM||{};window.WRM._unparsedData=window.WRM._unparsedData||{};window.WRM._unparsedErrors=window.WRM._unparsedErrors||{};
WRM._unparsedData["com.atlassian.plugins.atlassian-plugins-webresource-plugin:context-path.context-path"]="\"\"";
WRM._unparsedData["jira.core:feature-flags-data.feature-flag-data"]="{\"enabled-feature-keys\":[\"com.atlassian.jira.agile.darkfeature.editable.detailsview\",\"nps.survey.inline.dialog\",\"com.atlassian.jira.agile.darkfeature.edit.closed.sprint.enabled\",\"jira.plugin.devstatus.phasetwo\",\"jira.frother.reporter.field\",\"atlassian.rest.xsrf.legacy.enabled\",\"jira.issue.status.lozenge\",\"com.atlassian.jira.config.BIG_PIPE\",\"com.atlassian.jira.projects.issuenavigator\",\"com.atlassian.jira.config.PDL\",\"jira.plugin.devstatus.phasetwo.enabled\",\"atlassian.aui.raphael.disabled\",\"app-switcher.new\",\"frother.assignee.field\",\"com.atlassian.jira.projects.ProjectCentricNavigation.Switch\",\"jira.onboarding.cyoa\",\"com.atlassian.jira.agile.darkfeature.kanplan.enabled\",\"com.atlassian.jira.config.ProjectConfig.MENU\",\"com.atlassian.jira.projects.sidebar.DEFER_RESOURCES\",\"com.atlassian.jira.agile.darkfeature.kanplan.epics.and.versions.enabled\",\"com.atlassian.jira.agile.darkfeature.sprint.goal.enabled\",\"jira.zdu.admin-updates-ui\",\"jira.zdu.jmx-monitoring\",\"com.atlassian.portfolio.simpleplans.dependencytab\",\"sd.sla.parallel.recalculation.disabled\",\"sd.new.settings.sidebar.location.disabled\",\"jira.zdu.cluster-upgrade-state\",\"com.atlassian.jira.email.templates.readFromJiraHome\",\"com.atlassian.jira.agile.darkfeature.splitissue\",\"com.atlassian.jira.config.CoreFeatures.LICENSE_ROLES_ENABLED\",\"jira.export.csv.enabled\"],\"feature-flag-states\":{\"com.atlassian.jira.security.endpoint.non.admin.access.screens\":false,\"com.atlassian.jira.mailHandlerImapMessageQueryLegacy\":false,\"com.atlassian.jira.webhookEventsAsyncProcessing\":true,\"com.atlassian.jira.diagnostics.perflog\":true,\"com.atlassian.jira.dbr\":true,\"com.atlassian.jira.issuetable.move.links.hidden\":true,\"com.atlassian.jira.agile.darkfeature.unlink.sprints.on.issue.move\":true,\"jira.renderer.consider.variable.format\":true,\"com.atlassian.jira.user.dbIdBasedKeyGenerationStrategy\":true,\"com.atlassian.jira.plugin.issuenavigator.jql.autocomplete.eagerlyLoaded\":false,\"com.atlassian.portfolio.dcBundling\":true,\"com.atlassian.jira.sharedEntityEditRights\":true,\"com.atlassian.jira.security.endpoint.anonymous.access.resolution\":false,\"com.atlassian.jira.agile.darkfeature.sprint.goal\":false,\"com.atlassian.jira.thumbnailsDeferredGeneration\":true,\"jira.cluster.monitoring.show.offline.nodes\":true,\"com.atlassian.jira.commentReactions\":true,\"data.pipeline.feature.jira.issue.links.export\":true,\"com.atlassian.jira.custom.csv.escaper\":true,\"com.atlassian.jira.fixedCommentDeletionNotifications\":true,\"com.atlassian.jira.allThumbnailsDeferred\":false,\"com.atlassian.jira.plugin.issuenavigator.filtersUxImprovment\":true,\"com.atlassian.jira.agile.darkfeature.kanplan.epics.and.versions\":false,\"com.atlassian.jira.jsd.mobile\":true,\"jira.customfields.cleanup.identification\":true,\"data.pipeline.feature.jira.all.exportable.custom.fields\":true,\"com.atlassian.jira.defaultValuesForSystemFields\":true,\"jira.dc.cleanup.cluser.tasks\":true,\"jira.customfields.bulk.delete\":true,\"com.atlassian.jira.issues.archiving.filters\":false,\"mail.batching.override.core\":true,\"jira.users.and.roles.page.in.react\":true,\"jira.security.csp.sandbox\":true,\"com.atlassian.jira.agile.darkfeature.velocity.chart.ui\":true,\"com.atlassian.jira.returnDefaultAvatarsForBrokenAvatars\":true,\"com.atlassian.jira.agile.darkfeature.sprint.auto.management\":false,\"jira.jql.suggestrecentfields\":false,\"com.atlassian.jira.gdpr.rtbf\":true,\"com.atlassian.jira.security.xsrf.session.token\":true,\"com.atlassian.jira.agile.darkfeature.optimistic.transitions\":true,\"com.atlassian.jira.security.project.admin.revoke.with.application.access\":true,\"com.atlassian.jiranomenclature\":true,\"com.atlassian.jira.security.endpoint.non.admin.access.avatar.system\":false,\"com.atlassian.jira.agile.darkfeature.kanplan\":false,\"com.atlassian.jira.agile.darkfeature.future.sprint.dates\":true,\"com.atlassian.jira.filtersAndDashboardsShareableWithAllGroupsAndRoles\":true,\"jira.customfields.paginated.ui\":true,\"com.atlassian.jira.agile.darkfeature.edit.closed.sprint\":false,\"jira.create.linked.issue\":true,\"com.atlassian.jira.advanced.audit.log\":true,\"jira.sal.host.connect.accessor.existing.transaction.will.create.transactions\":true,\"external.links.new.window\":true,\"jira.quick.search\":true,\"jira.jql.smartautoselectfirst\":false,\"jira.jql.membersof.ignoreGlobalPermissionsForAnonymous\":false,\"data.pipeline.feature.jira.issue.history.export\":true,\"com.atlassian.jira.security.endpoint.non.browse.projects.access.fields\":false,\"atlassian.cdn.static.assets\":true,\"jira.richeditor.bidi.warning\":true,\"mail.batching\":false,\"com.atlassian.jira.privateEntitiesEditable\":true,\"com.atlassian.jira.security.endpoint.anonymous.access.priority\":false,\"jira.priorities.per.project.edit.default\":false,\"com.atlassian.jira.agile.darkfeature.issues.in.epic.details.view\":true,\"jira.priorities.per.project.jsd\":true,\"com.atlassian.jira.plugin.issuenavigator.anonymousPreventCfData\":false,\"com.atlassian.jira.agile.darkfeature.rapid.boards.bands\":true,\"com.atlassian.jira.agile.darkfeature.flexible.boards\":true,\"com.atlassian.jira.agile.darkfeature.sprint.picker.allsprints.suggestion\":true,\"jira.dc.lock.leasing\":true,\"com.atlassian.jira.accessibility.personal.settings\":true,\"mail.batching.create.section.cf\":true,\"com.atlassian.jira.security.endpoint.non.browse.projects.access.autocompletedata\":false,\"com.atlassian.mail.server.managers.hostname.verification\":true,\"com.atlassian.advancedroadmaps.rebrand\":true,\"com.atlassian.jira.upgrade.startup.fix.index\":false,\"com.atlassian.jira.security.endpoint.anonymous.access.projectCategory\":false,\"jira.redirect.anonymous.404.errors\":true,\"com.atlassian.jira.issuetable.draggable\":true,\"com.atlassian.jira.attachments.generate.unique.suffix\":true,\"com.atlassian.jira.agile.darkfeature.kanban.hide.old.done.issues\":true,\"jira.version.based.node.reindex.service\":true,\"com.atlassian.jira.agile.darkfeature.backlog.showmore\":true,\"com.atlassian.jira.agile.darkfeature.sprint.plan\":false,\"com.atlassian.jira.security.endpoint.anonymous.access.issueLinkType\":false,\"com.atlassian.jira.security.LegacyJiraTypeResolver.WARN_ONLY\":false,\"data.pipeline.feature.jira.schema.version.2\":true,\"com.atlassian.jira.agile.darkfeature.burnupchart\":true,\"com.atlassian.jira.agile.darkfeature.velocity.sprint.picker\":false,\"com.atlassian.jira.issues.archiving.browse\":true,\"jira.instrumentation.laas\":false,\"com.atlassian.jira.security.ChartUtils.browse.projects.permission.check\":false,\"mail.batching.user.notification\":true,\"com.atlassian.jira.agile.darkfeature.dataonpageload\":true,\"data.pipeline.feature.jira.archived.issue.export\":false,\"com.atlassian.jira.projects.per.project.permission.query\":true,\"com.atlassian.jira.issues.archiving\":true,\"index.use.snappy\":true,\"jira.priorities.per.project\":true}}";
WRM._unparsedData["jira.core:default-comment-security-level-data.DefaultCommentSecurityLevelHelpLink"]="{\"extraClasses\":\"default-comment-level-help\",\"title\":\"Commenting on an Issue\",\"url\":\"https://docs.atlassian.com/jira/jcore-docs-0820/Editing+and+collaborating+on+issues#Editingandcollaboratingonissues-restrictacomment\",\"isLocal\":false}";
WRM._unparsedData["com.atlassian.analytics.analytics-client:policy-update-init.policy-update-data-provider"]="false";
WRM._unparsedData["com.atlassian.analytics.analytics-client:programmatic-analytics-init.programmatic-analytics-data-provider"]="false";
WRM._unparsedData["com.onresolve.jira.groovy.groovyrunner:web-item-response-renderer.web-item-actions-data-provider"]="[]";
WRM._unparsedData["jira.core:dateFormatProvider.allFormats"]="{\"dateFormats\":{\"meridiem\":[\"AM\",\"PM\"],\"eras\":[\"BC\",\"AD\"],\"months\":[\"January\",\"February\",\"March\",\"April\",\"May\",\"June\",\"July\",\"August\",\"September\",\"October\",\"November\",\"December\"],\"monthsShort\":[\"Jan\",\"Feb\",\"Mar\",\"Apr\",\"May\",\"Jun\",\"Jul\",\"Aug\",\"Sep\",\"Oct\",\"Nov\",\"Dec\"],\"weekdaysShort\":[\"Sun\",\"Mon\",\"Tue\",\"Wed\",\"Thu\",\"Fri\",\"Sat\"],\"weekdays\":[\"Sunday\",\"Monday\",\"Tuesday\",\"Wednesday\",\"Thursday\",\"Friday\",\"Saturday\"]},\"lookAndFeelFormats\":{\"relativize\":\"true\",\"time\":\"h:mm a\",\"day\":\"EEEE h:mm a\",\"dmy\":\"yyyy/MM/dd\",\"complete\":\"yyyy/MM/dd h:mm a\"}}";
WRM._unparsedData["jira.core:avatar-picker-data.data"]="{}";
WRM._unparsedData["jira.core:terminology-data.terminology"]="{\"terminologyEntries\":[{\"originalName\":\"sprint\",\"originalNamePlural\":\"sprints\",\"newName\":\"sprint\",\"newNamePlural\":\"sprints\",\"isDefault\":true},{\"originalName\":\"epic\",\"originalNamePlural\":\"epics\",\"newName\":\"epic\",\"newNamePlural\":\"epics\",\"isDefault\":true}],\"isTerminologyActive\":false}";
WRM._unparsedData["com.atlassian.jira.jira-header-plugin:dismissedFlags.flags"]="{\"dismissed\":[]}";
WRM._unparsedData["com.atlassian.jira.jira-header-plugin:newsletter-signup-tip-init.newsletterSignup"]="{\"signupDescription\":\"Get updates, inspiration and best practices from the team behind Jira.\",\"formUrl\":\"https://www.atlassian.com/apis/exact-target/{0}/subscribe?mailingListId=1401671\",\"signupTitle\":\"Sign up!\",\"signupId\":\"newsletter-signup-tip\",\"showNewsletterTip\":false}";
WRM._unparsedData["com.atlassian.jira.project-templates-plugin:project-templates-plugin-resources.ptAnalyticsData"]="{\"instanceCreatedDate\":\"2010-05-15\"}";
WRM._unparsedData["com.onresolve.jira.groovy.groovyrunner:behaviours-translations.behaviours-translations-data-provider"]="{\"field.title.missing.value\":\"You must enter a value for this field\"}";
WRM._unparsedData["jira.core:user-message-flags-data.adminLockout"]="{}";
WRM._unparsedData["com.atlassian.plugins.helptips.jira-help-tips:help-tip-manager.JiraHelpTipData"]="{\"anonymous\":true}";
if(window.WRM._dataArrived)window.WRM._dataArrived();</script>
<link type="text/css" rel="stylesheet" href="/s/a9a8dd738117e435715d9f16c3897e3c-CDN/-wgvjjh/820004/ufh3zt/d2ea1e882b4acc8e627b108a99724f6d/_/download/contextbatch/css/_super/batch.css" data-wrm-key="_super" data-wrm-batch-type="context" media="all">
<link type="text/css" rel="stylesheet" href="/s/c3267d3a3134f0c2037e2178b10a3b6b-CDN/-wgvjjh/820004/ufh3zt/79976dffd45d820fec3b13f36493a25d/_/download/contextbatch/css/atl.general,jira.global,jira.general,-_super/batch.css?agile_global_admin_condition=true&amp;jag=true" data-wrm-key="atl.general,jira.global,jira.general,-_super" data-wrm-batch-type="context" media="all">
<script type="text/javascript" src="/s/9a4745c572286e06b9bb218d633c7be7-CDN/-wgvjjh/820004/ufh3zt/d2ea1e882b4acc8e627b108a99724f6d/_/download/contextbatch/js/_super/batch.js?locale=en-US" data-wrm-key="_super" data-wrm-batch-type="context" data-initially-rendered></script>
<script type="text/javascript" src="/s/fa4e7ab707fcd26fdbc8b0036022821d-CDN/-wgvjjh/820004/ufh3zt/79976dffd45d820fec3b13f36493a25d/_/download/contextbatch/js/atl.general,jira.global,jira.general,-_super/batch.js?agile_global_admin_condition=true&amp;jag=true&amp;locale=en-US" data-wrm-key="atl.general,jira.global,jira.general,-_super" data-wrm-batch-type="context" data-initially-rendered></script>
<script type="text/javascript" src="/s/e3d6757f1575fe71546393b44399c999-CDN/-wgvjjh/820004/ufh3zt/ed511616479aa2fdd97d34b75b6aab34/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en-US" data-wrm-key="atl.global,-_super" data-wrm-batch-type="context" data-initially-rendered></script>
<link type="text/css" rel="stylesheet" href="/s/d569283a5164b3347fee872de90f969d-CDN/-wgvjjh/820004/ufh3zt/75263fe2057917a9c748614811c7d582/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css" data-wrm-key="jira.global.look-and-feel,-_super" data-wrm-batch-type="context" media="all">

<script type="text/javascript" src="/rest/api/1.0/shortcuts/820004/e171f49a08fe723ba5eb9870dfe42746/shortcuts.js"></script>

    <meta name="application-name" content="JIRA" data-name="jira" data-version="8.20.4">
</head>
<body id="jira" class="aui-layout aui-style-default page-type-message " data-version="8.20.4" >

<!-- HTTPError403 -->
    <div class="aui-page-panel" ><div class="aui-page-panel-inner">
            <main role="main" id="main" class="aui-page-panel-content" >
                    <div class="aui-page-header" ><div class="aui-page-header-inner">
                            <div class="aui-page-header-main" >
                                    <h1>Forbidden (403)</h1>
                                </div>
                        </div></div>
                    <div class="aui-message aui-message-warning warning">
                            <p>Encountered a <code>&quot;403 - Forbidden&quot;</code> error while loading this page.</p>
                            <p>Basic Authentication Failure - Reason : AUTHENTICATION_DENIED</p>
                            <p><a href="/secure/MyJiraHome.jspa">Go to Jira home</a></p>
                        </div>
                </main>
        </div></div>
</body>
</html>
weshayutin commented 2 years ago

I'm at Red Hat as well trying the same thing. I was writing a python client when BAM found this awesome tool.

AFAICT... you can not log into RH's jira instance w/ a username. The following works in python jira = JIRA(server="https://issues.redhat.com", token_auth="JIRA_API_TOKEN") # token auth only afaict.

The other types of auth do NOT work.. https://jira.readthedocs.io/examples.html#

jira = JIRA(

basic_auth=("admin", "admin"), # a username/password tuple [Not recommended]

# basic_auth=("email", "API token"),  # Jira Cloud: a username/token tuple
# token_auth="API token",  # Self-Hosted Jira (e.g. Server): the PAT token
# auth=("admin", "admin"),  # a username/password tuple for cookie auth [Not recommended]

)

I'm looking in your code base where the config file is generated, but I don't see it and I don't see an example config posted. Pretty sure if you if you can auth w/: EXAMPLE: jira = JIRA(server="https://issues.redhat.com", token_auth="JIRA_API_TOKEN") This will work w/ RH's jira server.

I don't think given the config setup w/ username we will be able to authenticate, it will work only if we send token_auth.

~/go/bin/jira init --debug
? Installation type: Local
? Link to Jira server: https://issues.redhat.com
? Login username: zzzzzzz
⠼ Verifying login details...

REQUEST DETAILS
------------------------------------------------------------

GET /rest/api/2/myself HTTP/1.1
Host: issues.redhat.com
Authorization: Basic d25zdGI<snip>TWZpd2J<snip>

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

HTTP/1.1 401 Unauthorized
Content-Length: 14255
Cache-Control: max-age=0, no-cache, no-store
Connection: keep-alive
Content-Security-Policy: frame-ancestors 'self'
Content-Type: text/html;charset=UTF-8
Date: Sat, 12 Mar 2022 00:54:42 GMT
Expires: Sat, 12 Mar 2022 00:54:42 GMT
Pragma: no-cache
Referrer-Policy: strict-origin-when-cross-origin
Set-Cookie: d3f827c9bc9ac2c34ede13503553b11e=680addaaa31b742e2b0797f7b496e1da; path=/; HttpOnly; Secure; SameSite=None
Strict-Transport-Security: max-age=31536000
Www-Authenticate: OAuth realm="https%3A%2F%2Fissues.redhat.com"
X-Anodeid: rh1-jira-prod-2
X-Arequestid: 54x23013886x1
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Rh-Edge-Cache-Status: Miss from child, Miss from parent
X-Rh-Edge-Reference-Id: 0.76f02217.1647046482.e40a332
X-Rh-Edge-Request-Id: e40a332
X-Seraph-Loginreason: AUTHENTICATED_FAILED
X-Xss-Protection: 1; mode=block

✗ Received unexpected response '401 Unauthorized' from jira. Please try again.
weshayutin commented 2 years ago

actually.. this is awesome.. @ankitpokhrel @ericcurtin THIS pull request fixes this issue :) https://github.com/ankitpokhrel/jira-cli/pull/313

ankitpokhrel commented 2 years ago

Hi @weshayutin @ericcurtin I see that the redhat's public installation allows you to generate PAT so yes, #313 will fix the issue. I will try to get this feature merged soon.

ericcurtin commented 2 years ago

Oh cool thanks everyone 👍

ankitpokhrel commented 2 years ago

This should be done with #327. Please feel free to report any issues.

weshayutin commented 2 years ago

@ankitpokhrel most things seem to be working.. but on main.. after config I now get

panic: interface conversion: interface {} is nil, not string

goroutine 1 [running]:
github.com/ankitpokhrel/jira-cli/internal/config.(*JiraCLIConfig).decipherEpicMeta(0xc000168480, 0xc0007d9c60)
        /home/whayutin/git/JIRA/jira-cli/internal/config/generator.go:438 +0x4a5
github.com/ankitpokhrel/jira-cli/internal/config.(*JiraCLIConfig).configureMetadata(0xc000168480)
        /home/whayutin/git/JIRA/jira-cli/internal/config/generator.go:415 +0x3b8
github.com/ankitpokhrel/jira-cli/internal/config.(*JiraCLIConfig).Generate(0xc00055fd88)
    /home/whayutin/git/JIRA/jira-cli/internal/config/generator.go:110 +0x86
github.com/ankitpokhrel/jira-cli/internal/cmd/init.initialize(0xc000439680, {0xc7e6fb, 0x0, 0x0})
    /home/whayutin/git/JIRA/jira-cli/internal/cmd/init/init.go:43 +0xde
github.com/spf13/cobra.(*Command).execute(0xc000439680, {0x13f6c18, 0x0, 0x0})
    /home/whayutin/git/JIRA/jira-cli/vendor/github.com/spf13/cobra/command.go:860 +0x5f8
github.com/spf13/cobra.(*Command).ExecuteC(0xc000438a00)
    /home/whayutin/git/JIRA/jira-cli/vendor/github.com/spf13/cobra/command.go:974 +0x3bc
main.main()
    /home/whayutin/git/JIRA/jira-cli/cmd/jira/main.go:12 +0x1e
ankitpokhrel commented 2 years ago

Hi @weshayutin could you please create a new issue with more details on how to reproduce the issue? I just checked against issues.redhat.com and it worked fine for me.