mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-03 11:47:35 +08:00
19 lines
473 B
Ruby
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
|