Support oauth2#9
Open
BatoWa wants to merge 27 commits into
Open
Conversation
* Enhance control field value extraction to handle various object types and improve robustness * Enhance fetch_project_issue_fields method to handle JIRAError and fallback to createmeta endpoint for improved reliability * Enhance handle_jira_error to include detailed error message from JIRAError for improved debugging * Add troubleshooting tips for Jira synchronization issues related to permissions * Enhance JiraClient to support connection via Atlassian API gateway for scoped API tokens and improve connection verification methods * Add documentation for Jira scoped API token scopes required for Jira Cloud integration
…imbus/testbench-defect-service into fix/remove-duplicate-attributes
…improve token validation logic
…rride token cache values
…y in tables and sections
…y configuration values
… token data retrieval logic
…add refresh token management
…, update token handling, and improve documentation for conversion commands
…, improve refresh token handling, and add setup wizard for OAuth2 token retrieval
… and improve validation logic
…efect_from_issue function and update tests
…r to preserve HTTP status codes and improve error messaging
…efect-service into support-oauth2
…uthentication handling
…ling for OAuth2 support
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds OAuth2 (3LO) authentication support for Jira Cloud to the Defect Service,
alongside the existing
basic,token, andoauth1strategies. BecauseOAuth2 (and Cloud scoped API tokens) only work through the Atlassian API
gateway, this branch also introduces the gateway connection path and fixes the
URL-generation issues that come with it.
Motivation
Jira Cloud is moving toward OAuth2 / scoped API tokens, which are not accepted
by the direct site URL — they must go through
api.atlassian.com/ex/jira/{cloudId}.The service needed a first-class OAuth2 flow (token lifecycle, refresh, setup
wizard) and had to keep user-facing URLs pointing at the configured Jira site
rather than the internal gateway host.
What changed
OAuth2 authentication
auth_type = "oauth2"inJiraDefectClientConfig, withoauth2_client_id,oauth2_client_secret, andoauth2_refresh_token(env-var overridable, e.g.JIRA_OAUTH2_CLIENT_ID). Validated invalidate_config.clients/jira/jira_oauth.py: module-level token store persisted totmp/oauth2_tokens.toml, refreshed againstauth.atlassian.com/oauth/token,and injected per-request via a session
sendpatch.Gateway connection path
_connect_via_gatewayconnects throughapi.atlassian.com/ex/jira/{cloudId},resolving the cloud ID from the public
/_edge/tenant_infoendpoint.and injects the bearer token, so callers stay gateway-agnostic.
Correct user-facing URLs under the gateway (permalinks & attachments)
create_defect_from_issue/create_extended_defect_from_issue/_extract_referencesnow accept asite_url(the configuredserver_url)and build permalinks and attachment URLs against the Jira site instead of the
gateway host. Previously references pointed at
api.atlassian.com/ex/jira/….UnboundLocalErrorin_extract_referencesfor issues with noattachments.
Docs & tests
docs/clients/jira-client.md,docs/cli.md, and migration docs.test_jira_oauth.py, plusTestExtractReferencesandsite_urlcoverage intest_utils.py.Notes for reviewers
/rest/api/2/…REST base;tracking the actual API version is intentionally deferred.
tmp/oauth2_tokens.tomlandconfig.tomlremain local-only working artifacts.