Implement RS auth revocation
This commit is contained in:
parent
8ec2a6d7e4
commit
713e91a720
@ -9,7 +9,7 @@ class DropdownLinkComponent < ViewComponent::Base
|
|||||||
private
|
private
|
||||||
|
|
||||||
def class_str(separator, add_class)
|
def class_str(separator, add_class)
|
||||||
str = "no-underline block px-4 py-2 text-sm text-gray-900 bg-white
|
str = "no-underline block px-5 py-3 text-sm text-gray-900 bg-white
|
||||||
hover:bg-gray-100 focus:bg-gray-100 whitespace-no-wrap"
|
hover:bg-gray-100 focus:bg-gray-100 whitespace-no-wrap"
|
||||||
str = "#{str} border-t" if separator
|
str = "#{str} border-t" if separator
|
||||||
str = "#{str} #{add_class}" if add_class
|
str = "#{str} #{add_class}" if add_class
|
||||||
|
@ -20,7 +20,8 @@
|
|||||||
Launch app
|
Launch app
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= render DropdownLinkComponent.new(
|
<%= render DropdownLinkComponent.new(
|
||||||
href: "#", separator: true, add_class: "text-red-700"
|
href: revoke_services_storage_rs_auth_url(@auth),
|
||||||
|
separator: true, add_class: "text-red-700"
|
||||||
) do %>
|
) do %>
|
||||||
Revoke access
|
Revoke access
|
||||||
<% end %>
|
<% end %>
|
||||||
|
@ -3,7 +3,8 @@ class Services::RemotestorageController < Services::BaseController
|
|||||||
before_action :require_feature_enabled
|
before_action :require_feature_enabled
|
||||||
before_action :require_service_available
|
before_action :require_service_available
|
||||||
|
|
||||||
def dashboard
|
# Dashboard
|
||||||
|
def show
|
||||||
# unless current_user.services_enabled.include?(:remotestorage)
|
# unless current_user.services_enabled.include?(:remotestorage)
|
||||||
# redirect_to service_remotestorage_info_path
|
# redirect_to service_remotestorage_info_path
|
||||||
# end
|
# end
|
||||||
|
34
app/controllers/services/rs_auths_controller.rb
Normal file
34
app/controllers/services/rs_auths_controller.rb
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
class Services::RsAuthsController < Services::BaseController
|
||||||
|
before_action :authenticate_user!
|
||||||
|
before_action :require_feature_enabled
|
||||||
|
before_action :require_service_available
|
||||||
|
# before_action :require_service_enabled
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
if @rs_auth = current_user.remote_storage_authorizations.find(params[:id])
|
||||||
|
@rs_auth.destroy!
|
||||||
|
else
|
||||||
|
http_status :not_found
|
||||||
|
end
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html do redirect_to services_storage_url, flash: {
|
||||||
|
success: 'App authorization revoked'
|
||||||
|
}
|
||||||
|
end
|
||||||
|
format.json { head :no_content }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def require_feature_enabled
|
||||||
|
unless Flipper.enabled?(:remotestorage, current_user)
|
||||||
|
http_status :forbidden
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def require_service_available
|
||||||
|
http_status :not_found unless Setting.remotestorage_enabled?
|
||||||
|
end
|
||||||
|
end
|
@ -4,7 +4,7 @@
|
|||||||
<section>
|
<section>
|
||||||
<h3 class="mb-10">Connected Apps</h3>
|
<h3 class="mb-10">Connected Apps</h3>
|
||||||
<% if @rs_auths.any? %>
|
<% if @rs_auths.any? %>
|
||||||
<div class="w-full grid grid-cols-1 md:grid-cols-3 gap-10">
|
<div class="w-full grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-y-10 gap-x-12">
|
||||||
<% @rs_auths.each do |auth| %>
|
<% @rs_auths.each do |auth| %>
|
||||||
<%= render RsAuthComponent.new(auth: auth) %>
|
<%= render RsAuthComponent.new(auth: auth) %>
|
||||||
<% end %>
|
<% end %>
|
@ -19,10 +19,10 @@ Rails.application.routes.draw do
|
|||||||
resources :invitations, only: ['index', 'show', 'create', 'destroy']
|
resources :invitations, only: ['index', 'show', 'create', 'destroy']
|
||||||
|
|
||||||
namespace :services do
|
namespace :services do
|
||||||
get 'storage', to: 'remotestorage#dashboard'
|
|
||||||
|
|
||||||
resource :chat, only: [:show], controller: 'chat'
|
resource :chat, only: [:show], controller: 'chat'
|
||||||
|
|
||||||
|
resource :mastodon, only: [:show], controller: 'mastodon'
|
||||||
|
|
||||||
resources :lightning, only: [:index] do
|
resources :lightning, only: [:index] do
|
||||||
collection do
|
collection do
|
||||||
get 'transactions'
|
get 'transactions'
|
||||||
@ -30,7 +30,13 @@ Rails.application.routes.draw do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
resource :mastodon, only: [:show], controller: 'mastodon'
|
resource :storage, controller: 'remotestorage', only: [:show] do
|
||||||
|
resources :rs_auths, only: [:destroy] do
|
||||||
|
member do
|
||||||
|
get 'revoke', to: 'rs_auths#destroy'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :settings, param: 'section', only: ['index', 'show', 'update'] do
|
resources :settings, param: 'section', only: ['index', 'show', 'update'] do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user