discourse/lib/onebox/mixins/github_auth_header.rb
Loïc Guitaut a633007bae
DEV: Replace Ruby numbered parameters by it where applicable (#37810)
Now that we moved to Ruby 3.4, we can use `it` instead of `_1`.
2026-02-13 13:59:07 +01:00

19 lines
473 B
Ruby

# frozen_string_literal: true
module Onebox
module Mixins
module GithubAuthHeader
def github_auth_header(github_org)
return {} if SiteSetting.github_onebox_access_tokens.blank?
org_tokens = SiteSetting.github_onebox_access_tokens.split("\n").to_h { it.split("|") }
token = org_tokens[github_org] || org_tokens["default"]
return {} if token.blank?
{ "Authorization" => "Bearer #{token}" }
end
end
end
end