|
|
|
@@ -160,9 +160,9 @@ module Ci::CloudAccountManageable |
|
|
|
state = SecureRandom.hex(8) |
|
|
|
# redirect_uri eg: |
|
|
|
# https://localhost:3000/login/oauth/authorize?client_id=94976481-ad0e-4ed4-9247-7eef106007a2&redirect_uri=http%3A%2F%2F121.69.81.11%3A80%2Flogin&response_type=code&state=9cab990b9cfb1805 |
|
|
|
redirect_uri = CGI.escape("#{@cloud_account.drone_url}/login") |
|
|
|
clientId = client_id(oauth) |
|
|
|
grant_url = "#{Gitea.gitea_config[:domain]}/login/oauth/authorize?client_id=#{clientId}&redirect_uri=#{redirect_uri}&response_type=code&state=#{state}" |
|
|
|
# redirect_uri = CGI.escape("#{@cloud_account.drone_url}/login") |
|
|
|
# clientId = client_id(oauth) |
|
|
|
grant_url = "#{@cloud_account.drone_url}/login" |
|
|
|
logger.info "[gitea] grant_url: #{grant_url}" |
|
|
|
|
|
|
|
conn = Faraday.new(url: grant_url) do |req| |
|
|
|
@@ -179,7 +179,7 @@ module Ci::CloudAccountManageable |
|
|
|
|
|
|
|
def drone_oauth_user!(url, state) |
|
|
|
logger.info "[drone] drone_oauth_user url: #{url}" |
|
|
|
conn = Faraday.new(url: "#{Gitea.gitea_config[:domain]}#{url}") do |req| |
|
|
|
conn = Faraday.new(url: url) do |req| |
|
|
|
req.request :url_encoded |
|
|
|
req.adapter Faraday.default_adapter |
|
|
|
req.headers["cookie"] = "_session_=#{SecureRandom.hex(28)}; _oauth_state_=#{state}" |
|
|
|
@@ -188,8 +188,8 @@ module Ci::CloudAccountManageable |
|
|
|
response = conn.get |
|
|
|
logger.info "[drone] response headers: #{response.headers}" |
|
|
|
|
|
|
|
true |
|
|
|
# response.headers['location'].include?('error') ? false : true |
|
|
|
# true |
|
|
|
response.headers['location'].include?('error') ? false : true |
|
|
|
end |
|
|
|
|
|
|
|
private |
|
|
|
|