{"id":18760558,"url":"https://github.com/evrone/atlassian-jwt","last_synced_at":"2025-09-11T23:12:29.855Z","repository":{"id":66228425,"uuid":"247074630","full_name":"evrone/atlassian-jwt","owner":"evrone","description":"Bitbucket fork for atlassian-jwt gem","archived":false,"fork":false,"pushed_at":"2020-03-13T14:19:42.000Z","size":27,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-09-08T19:15:21.913Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/evrone.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-03-13T13:13:25.000Z","updated_at":"2020-03-13T14:19:44.000Z","dependencies_parsed_at":"2023-04-23T16:48:15.023Z","dependency_job_id":null,"html_url":"https://github.com/evrone/atlassian-jwt","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/evrone/atlassian-jwt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evrone%2Fatlassian-jwt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evrone%2Fatlassian-jwt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evrone%2Fatlassian-jwt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evrone%2Fatlassian-jwt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/evrone","download_url":"https://codeload.github.com/evrone/atlassian-jwt/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evrone%2Fatlassian-jwt/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274704577,"owners_count":25334404,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-11T02:00:13.660Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T18:13:09.234Z","updated_at":"2025-09-11T23:12:29.843Z","avatar_url":"https://github.com/evrone.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Atlassian::Jwt\n\nIn order to access the\n[Atlassian Connect REST APIs](https://developer.atlassian.com/cloud/jira/platform/rest/)\nan app authenticates using a JSON Web Token (JWT). The token is\ngenerated using the app's secret key and contains a *claim* which\nincludes the app's key and a hashed version of the API URL the\napp is accessing. This gem simplifies generating the claim.\n\nThis gem provides helpers for generating Atlassian specific JWT\nclaims. It also exposes the [ruby-jwt](https://github.com/jwt/ruby-jwt)\ngem's `encode` and `decode` methods.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'atlassian-jwt'\n```\n\nAnd then execute:\n\n```sh\nbundle\n```\n\nOr install it yourself as:\n\n```sh\ngem install atlassian-jwt\n```\n\n## Generating a JWT Token\n\n```ruby\nrequire 'atlassian/jwt'\n\n# The URL of the API call, must include the query string, if any\nurl = 'https://jira.atlassian.com/rest/api/latest/issue/JRA-9'\n# The key of the app as defined in the app description\nissuer = 'com.atlassian.example'\n# The HTTP Method (GET, POST, etc) of the API call\nhttp_method = 'get'\n# The shared secret returned when the app is installed\nshared_secret = '...'\n\nclaim = Atlassian::Jwt.build_claims(issuer, url, http_method)\njwt = JWT.encode(claim, shared_secret)\n```\n\nIf the base URL of the API is not at the root of the site,\ni.e. `https://site.atlassian.net/jira/rest/api`, you will need to pass\nin the base URL to `build_claims`:\n\n```ruby\nurl = 'https://site.atlassian.net/jira/rest/api/latest/issue/JRA-9'\nbase_url = 'https://site.atlassian.net'\n\nclaim = Atlassian::Jwt.build_claims(issuer, url, http_method, base_url)\n```\n\nThe generated JWT can then be passed in an `Authorization` header or\nin the query string:\n\n```ruby\n# Header\nuri = URI('https://site.atlassian.net/rest/api/latest/issue/JRA-9')\nhttp = Net::HTTP.new(uri.host, uri.port)\nrequest = Net::HTTP::Get.new(uri.request_uri)\nrequest.initialize_http_header({'Authorization' =\u003e \"JWT #{jwt}\"})\nresponse = http.request(request)\n```\n\n```ruby\n# Query String\nuri = URI(\"https://site.atlassian.net/rest/api/latest/issue/JRA-9?jwt=#{jwt}\")\nhttp = Net::HTTP.new(uri.host, uri.port)\nrequest = Net::HTTP::Get.new(uri.request_uri)\nresponse = http.request(request)\n```\n\nBy default the issue time of the claim is now and the expiration is 60\nseconds in the future, these can be overridden:\n\n```ruby\nclaim = Atlassian::Jwt.build_claims(\n  issuer,\n  url,\n  http_method,\n  base_url,\n  (Time.now - 60.seconds).to_i,\n  (Time.now + 1.day).to_i\n)\n```\n\n## Decoding a JWT token\n\nThe JWT from the server is usually returned as a param. The underlying\nRuby JWT gem returns an array, with the first element being the claims\nand the second being the JWT header, which contains information about\nhow the JWT was encoded.\n\n```ruby\nclaims, jwt_header = Atlassian::Jwt.decode(params[:jwt], shared_secret)\n```\n\nBy default, the JWT gem verifies that the JWT is properly signed with\nthe shared secret and raises an error if it's not. However, sometimes it\nis necessary to read the JWT first to determine which shared secret is\nneeded. In this case, use `nil` for the shared secret and follow it with\n`false` to tell the gem to to verify the signature.\n\n```ruby\nclaims, jwt_header = Atlassian::Jwt.decode(params[:jwt], nil, false)\n```\n\nSee the [ruby-jwt doc](https://github.com/jwt/ruby-jwt) for additional\ndetails.\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies.\n\nRun `rake spec` to run the tests.\n\nRun `bin/console` for an interactive prompt that allows you to experiment.\n\nRun `bundle exec rake install` to install this gem to your local machine.\n\nTo release a new version, update the version number in `version.rb`, and\nthen run `bundle exec rake release`. It will create a git tag for the\nversion, push git commits and tags, and push the `.gem` file to\n[rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on Bitbucket at:\nhttps://bitbucket.org/atlassian/atlassian-jwt-ruby\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevrone%2Fatlassian-jwt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fevrone%2Fatlassian-jwt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevrone%2Fatlassian-jwt/lists"}