调整Bot授权接口

This commit is contained in:
xxq250 2023-02-16 09:57:25 +08:00
parent 1d9df770b5
commit 3c51d69555
2 changed files with 27 additions and 6 deletions

View File

@ -6,6 +6,25 @@ class InstallationsController < ApplicationController
@install_bots = BotInstall.where(:installer_id => current_user.id) @install_bots = BotInstall.where(:installer_id => current_user.id)
end end
def update_secret
ActiveRecord::Base.transaction do
bot = Bot.find params[:id]
application = Doorkeeper::Application.find_by(uid: bot.client_id, secret: bot.client_secret)
bot.client_secret = Doorkeeper::OAuth::Helpers::UniqueToken.generate
bot.save!
application.secret = bot.client_secret
application.save!
render_ok
end
end
def update_private_key
bot = Bot.find params[:id]
bot.private_key = OpenSSL::PKey::RSA::generate(2048).to_s
bot.save!
render_ok
end
def auth_active def auth_active
begin begin
@bot = Bot.find params[:id] @bot = Bot.find params[:id]

View File

@ -1048,7 +1048,9 @@ Rails.application.routes.draw do
resources :commit_logs, :only => [:create] resources :commit_logs, :only => [:create]
scope '/app' do scope '/app' do
post 'auth_active', to: 'installations#auth_active' post ':id/auth_active', to: 'installations#auth_active'
post ':id/update_private_key', to: 'installations#update_private_key'
post ':id/update_secret', to: 'installations#update_secret'
resources :installations do resources :installations do
get :repositories, on: :collection get :repositories, on: :collection
member do member do