Browse Source

fixed ci4s oauth2接入

pull/347/head
xxq250 1 year ago
parent
commit
d038f30994
3 changed files with 8 additions and 0 deletions
  1. +4
    -0
      app/controllers/oauth/ci4s_controller.rb
  2. +3
    -0
      app/libs/ci4s/service.rb
  3. +1
    -0
      config/routes.rb

+ 4
- 0
app/controllers/oauth/ci4s_controller.rb View File

@@ -2,6 +2,10 @@ class Oauth::Ci4sController < Oauth::BaseController
include RegisterHelper


def oauth_url
Ci4s::Service.oauth_url(code)
end

# 需要educoder那边设置回调地址
def create
begin


+ 3
- 0
app/libs/ci4s/service.rb View File

@@ -23,6 +23,9 @@ module Ci4s::Service
config.dig("oauth", "ci4s", "redirect_uri")
end

def oauth_url
"#{base_url}/oauth/authorize?client_id=#{client_id}&redirect_uri=#{URI.encode_www_form_component(redirect_uri)}&response_type=code&grant_type=authorization_code"
end

def request(method, url, params)
begin


+ 1
- 0
config/routes.rb View File

@@ -26,6 +26,7 @@ Rails.application.routes.draw do
get 'auth/failure', to: 'oauth/base#auth_failure'
get 'auth/cas/callback', to: 'oauth/cas#create'
get 'auth/acge/callback', to: "oauth/acge#create"
get 'oauth_ci4s', to: "oauth/ci4s#oauth_url"
get 'auth/ci4s/callback', to: "oauth/ci4s#create"
get 'auth/acge/refer', to: "oauth/acge#refer"
get 'auth/:provider/callback', to: 'oauth/callbacks#create'


Loading…
Cancel
Save