-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into snyk-fix-0ff7fd289fe698ac816a17effca57f6f
- Loading branch information
Showing
7 changed files
with
133 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM alpine:3.17 AS alpine | ||
FROM alpine:3 AS alpine | ||
|
||
ARG RAILS_ROOT=/usr/src/app | ||
ENV RAILS_ROOT=${RAILS_ROOT} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# frozen_string_literal: true | ||
|
||
# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/. | ||
|
||
# Copyright (c) 2018 BigBlueButton Inc. and by respective authors (see below). | ||
|
||
# This program is free software; you can redistribute it and/or modify it under the | ||
# terms of the GNU Lesser General Public License as published by the Free Software | ||
# Foundation; either version 3.0 of the License, or (at your option) any later | ||
# version. | ||
|
||
# BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY | ||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | ||
# PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. | ||
|
||
# You should have received a copy of the GNU Lesser General Public License along | ||
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>. | ||
|
||
class Api::V1::TenantsController < Api::V1::BaseController | ||
before_action :doorkeeper_authorize! | ||
|
||
before_action :set_tenant, only: [:show] | ||
|
||
# GET /api/v1/tenant/:uid | ||
def show | ||
render(json: @tenant, status: :ok) | ||
end | ||
|
||
private | ||
|
||
def set_tenant | ||
uid = params[:uid] | ||
uid ||= '' | ||
@tenant = RailsLti2Provider::Tenant.find_by(uid: uid) | ||
rescue ApplicationRecord::RecordNotFound => e | ||
render(json: { error: e.message }, status: :not_found) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'bbb_lti_broker/helpers' | ||
|
||
namespace :db do | ||
namespace :tenants do | ||
namespace :settings do | ||
desc 'Show all settings for a tenant. If no id is specified, settings for all tenants will be shown' | ||
task :showall, [:uid] => :environment do |_t, args| | ||
tenant_id = args[:uid] || '' | ||
|
||
if tenant_id.present? | ||
tenant = RailsLti2Provider::Tenant.find_by(uid: tenant_id) | ||
if tenant.nil? | ||
puts("Tenant '#{tenant_id}' does not exist.") | ||
exit(1) | ||
end | ||
|
||
puts("Settings for tenant #{tenant_id}: \n #{tenant.settings}") | ||
else | ||
tenants = RailsLti2Provider::Tenant.all | ||
tenants_list = tenants.map do |t| | ||
{ | ||
tenant: t.uid, | ||
settings: t.settings, | ||
} | ||
end | ||
puts(tenants_list) | ||
end | ||
end | ||
|
||
desc 'Add a new tenant setting' | ||
task :upsert, [:uid, :key, :value] => :environment do |_t, args| | ||
tenant_id = args[:uid] || '' | ||
key = args[:key] | ||
value = args[:value] | ||
|
||
unless key.present? && value.present? | ||
puts('Error: key and value are required to create a tenant setting') | ||
exit(1) | ||
end | ||
|
||
tenant = RailsLti2Provider::Tenant.find_by(uid: tenant_id) | ||
if tenant.nil? | ||
puts("Tenant '#{tenant_id}' does not exist.") | ||
exit(1) | ||
end | ||
|
||
# Add the setting | ||
tenant.settings[key] = value | ||
tenant.save! | ||
|
||
puts("Added setting #{key}=#{value} to tenant #{tenant_id}") | ||
rescue StandardError => e | ||
puts(e.backtrace) | ||
exit(1) | ||
end | ||
|
||
desc 'Delete a setting' | ||
task :delete, [:uid, :key] => :environment do |_t, args| | ||
tenant_id = args[:uid] || '' | ||
key = args[:key] | ||
|
||
if key.blank? | ||
puts('Error: The setting key is required to delete a tenant setting') | ||
exit(1) | ||
end | ||
|
||
tenant = RailsLti2Provider::Tenant.find_by(uid: tenant_id) | ||
if tenant.nil? | ||
puts("Tenant '#{tenant_id}' does not exist.") | ||
exit(1) | ||
end | ||
|
||
puts("Key '#{key}' not found for tenant #{tenant}") unless tenant.settings[key] | ||
|
||
tenant.settings.delete(key) | ||
tenant.save! | ||
|
||
puts("Setting #{key} for tenant '#{tenant_id}' has been deleted") | ||
rescue StandardError => e | ||
puts(e.backtrace) | ||
exit(1) | ||
end | ||
end | ||
end | ||
end |