Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions app/controllers/api/canvas_proxy_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ class Api::CanvasProxyController < Api::ApiApplicationController
before_action :protect_canvas_api

def proxy
api = if params[:bundle_instance_token].present?
canvas_api(application_instance: targeted_app_instance)
else
canvas_api
end
api = canvas_api
result = api.proxy(params[:lms_proxy_call_type], params.to_unsafe_h, request.body.read, params[:get_all])
allowed_headers = %w{
content-type link p3p x-canvas-meta x-canvas-user-id
Expand Down
21 changes: 1 addition & 20 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ class ApplicationController < ActionController::Base

helper_method :current_application_instance,
:current_application,
:current_bundle_instance,
:current_canvas_course,
:canvas_url,
:targeted_app_instance,
:current_user_roles

protected
Expand Down Expand Up @@ -145,8 +143,7 @@ def setup_will_paginate
def canvas_url
@canvas_url ||= session[:canvas_url] ||
custom_canvas_api_domain ||
current_application_instance&.site&.url ||
current_bundle_instance&.site&.url
current_application_instance&.site&.url
end

def custom_canvas_api_domain
Expand Down Expand Up @@ -178,13 +175,6 @@ def current_application
Application.find_by(key: request.subdomains.first)
end

def current_bundle_instance
@current_bundle ||= BundleInstance.
where(id_token: params[:bundle_instance_token]).
or(BundleInstance.where(id: params[:bundle_instance_id])).
first
end

def current_ability
@current_ability ||= Ability.new(current_user, params[:context_id])
end
Expand Down Expand Up @@ -220,13 +210,4 @@ def set_i18n_locale
end
end

def targeted_app_instance
key = request.subdomains.first
application = Application.find_by(key: key)
return nil if current_bundle_instance.nil?
current_bundle_instance.
application_instances.
find_by(application_id: application.id)
end

end
5 changes: 1 addition & 4 deletions app/models/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ class Application < ApplicationRecord
validates :name, presence: true, uniqueness: true
validates :key, presence: true, uniqueness: true

has_many :application_bundles
has_many :bundles, through: :application_bundles
has_many :jwks
has_many :lti_installs

Expand All @@ -33,10 +31,9 @@ class Application < ApplicationRecord
AUTH = "auth".freeze
HELLOWORLD = "helloworld".freeze

def create_instance(site: nil, bundle_instance: nil, tenant: nil, lti_key: nil)
def create_instance(site: nil, tenant: nil, lti_key: nil)
application_instance = application_instances.find_or_create_by(
site: site,
bundle_instance: bundle_instance,
lti_key: lti_key,
)
if tenant.present?
Expand Down
4 changes: 0 additions & 4 deletions app/models/application_bundle.rb

This file was deleted.

1 change: 0 additions & 1 deletion app/models/application_instance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ class ApplicationInstance < ApplicationRecord

belongs_to :application, counter_cache: true
belongs_to :site
belongs_to :bundle_instance, required: false

has_many :authentications, dependent: :destroy, inverse_of: :application_instance
has_many :lti_deployments, dependent: :destroy
Expand Down
6 changes: 0 additions & 6 deletions app/models/bundle.rb

This file was deleted.

30 changes: 0 additions & 30 deletions app/models/bundle_instance.rb

This file was deleted.

1 change: 1 addition & 0 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,5 @@
# This removes whitelisting of domains allowed to front the application
# config.hosts.clear
config.hosts << ".atomicjolt.win"
config.hosts << ".atomicjolt.xyz"
end
3 changes: 0 additions & 3 deletions config/initializers/apartment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
ApplicationInstance
OauthState
Site
Bundle
BundleInstance
ApplicationBundle
ImsExport
RequestStatistic
RequestUserStatistic
Expand Down
9 changes: 9 additions & 0 deletions db/migrate/20221025213143_remove_bundles.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class RemoveBundles < ActiveRecord::Migration[7.0]
def change
drop_table :bundles
drop_table :bundle_instances
drop_table :application_bundles

remove_column :application_instances, :bundle_instance_id, :integer
end
end
34 changes: 0 additions & 34 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,6 @@
HELPER_ALL_ACCOUNTS: [],
}

bundles = [
{
name: "Hello World",
key: Application::HELLOWORLD,
applications: [Application::HELLOWORLD],
shared_tenant: true,
},
]

file_path = Rails.root.join("db/lti_advantage_configs/hello_world_lti_advantage_config.json")
hello_lti_advantage_config = JSON.parse(File.read(file_path))

Expand Down Expand Up @@ -312,31 +303,6 @@ def setup_application_instances(application, application_instances)
setup_application_instances(application, application_instances)
end

bundles.each do |attrs|
current_bundle = Bundle.find_or_create_by(key: attrs[:key])
current_bundle.update!(name: attrs[:name], shared_tenant: attrs[:shared_tenant] == true)

attrs[:applications].reduce(current_bundle) do |bundle, key|
app = Application.find_by!(key: key)
bundle.application_bundles.find_or_create_by(bundle_id: bundle.id, application_id: app.id)
bundle
end
end

ApplicationInstance.where(bundle_instance_id: nil).find_each do |instance|
bundle = Bundle.includes(:applications).by_application_id(instance.application.id).last
BundleInstance.create(site: instance.site, bundle: bundle)
end

BundleInstance.find_each do |bundle_instance|
site = bundle_instance.site
bundle_instance.applications.each do |app|
if instance = app.application_instances.find_by(site: site)
instance.update(bundle_instance: bundle_instance) if instance.bundle_instance_id.nil?
end
end
end

begin
Apartment::Tenant.create Application::AUTH
rescue Apartment::TenantExists
Expand Down
10 changes: 0 additions & 10 deletions spec/controllers/application_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,6 @@
end
end

describe "#current_bundle_instance" do
it "returns the canvas url" do
bundle_instance = FactoryBot.create(:bundle_instance)
subject.params = {
bundle_instance_token: bundle_instance.id_token,
}
expect(subject.send(:current_bundle_instance)).to eq(bundle_instance)
end
end

describe "#current_user_roles" do
it "returns the roles for the current user when context is nil" do
role = "admin"
Expand Down
6 changes: 0 additions & 6 deletions spec/factories/application_bundles.rb

This file was deleted.

1 change: 0 additions & 1 deletion spec/factories/application_instances.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@
lti_secret { FactoryBot.generate(:password) }
site
canvas_token { FactoryBot.generate(:password) }
bundle_instance
end
end
6 changes: 0 additions & 6 deletions spec/factories/bundle_instance.rb

This file was deleted.

6 changes: 0 additions & 6 deletions spec/factories/bundles.rb

This file was deleted.

13 changes: 0 additions & 13 deletions spec/models/application_bundle_spec.rb

This file was deleted.

17 changes: 0 additions & 17 deletions spec/models/bundle_instance_spec.rb

This file was deleted.

18 changes: 0 additions & 18 deletions spec/models/bundle_spec.rb

This file was deleted.

8 changes: 0 additions & 8 deletions spec/support/application_instance_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,12 @@ def self.make_application_instance

default_config = {}

bundle = Bundle.find_or_create_by(key: GLOBAL_LTI_KEY)

bundle_instance = FactoryBot.create(
:bundle_instance,
bundle: bundle,
)

FactoryBot.create(
:application_instance,
application: application,
lti_key: GLOBAL_LTI_KEY,
tenant: GLOBAL_LTI_KEY,
config: default_config,
bundle_instance: bundle_instance,
)
end

Expand Down