FEATURE: add option to encode request as json
This commit is contained in:
parent
2ec8f90bb3
commit
78bb57daf1
|
@ -7,6 +7,12 @@ login:
|
||||||
oauth2_authorize_url: ""
|
oauth2_authorize_url: ""
|
||||||
oauth2_authorize_signup_url: ""
|
oauth2_authorize_signup_url: ""
|
||||||
oauth2_token_url: ""
|
oauth2_token_url: ""
|
||||||
|
oauth2_token_request_encoding:
|
||||||
|
default: "form_encoded"
|
||||||
|
type: enum
|
||||||
|
choices:
|
||||||
|
- form_encoded
|
||||||
|
- json
|
||||||
oauth2_token_url_method:
|
oauth2_token_url_method:
|
||||||
default: "POST"
|
default: "POST"
|
||||||
type: enum
|
type: enum
|
||||||
|
|
|
@ -121,9 +121,10 @@ class ::OAuth2BasicAuthenticator < Auth::ManagedAuthenticator
|
||||||
opts[:client_options][:auth_scheme] = :request_body
|
opts[:client_options][:auth_scheme] = :request_body
|
||||||
opts[:token_params] = {
|
opts[:token_params] = {
|
||||||
headers: {
|
headers: {
|
||||||
"Authorization" => basic_auth_header,
|
"Authorization" => basic_auth_header
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
opts[:token_params][:headers]["Content-Type"] = "application/json" if SiteSetting.oauth2_token_request_encoding == "json"
|
||||||
elsif SiteSetting.oauth2_send_auth_header?
|
elsif SiteSetting.oauth2_send_auth_header?
|
||||||
opts[:client_options][:auth_scheme] = :basic_auth
|
opts[:client_options][:auth_scheme] = :basic_auth
|
||||||
else
|
else
|
||||||
|
@ -141,7 +142,8 @@ class ::OAuth2BasicAuthenticator < Auth::ManagedAuthenticator
|
||||||
{ bodies: true, formatter: OAuth2FaradayFormatter }
|
{ bodies: true, formatter: OAuth2FaradayFormatter }
|
||||||
end
|
end
|
||||||
|
|
||||||
builder.request :url_encoded # form-encode POST params
|
encoding = SiteSetting.oauth2_token_request_encoding == "form_encoded" ? :url_encoded : :json
|
||||||
|
builder.request encoding
|
||||||
builder.adapter FinalDestination::FaradayAdapter # make requests with FinalDestination::HTTP
|
builder.adapter FinalDestination::FaradayAdapter # make requests with FinalDestination::HTTP
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue