Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Move auth provider to base table

Oliver Günther344ce2730cec
diff --git a/modules/auth_saml/app/contracts/saml/providers/create_contract.rb b/modules/auth_saml/app/contracts/saml/providers/create_contract.rb
index 555aeac3604..2115bc482b3 100644
--- a/modules/auth_saml/app/contracts/saml/providers/create_contract.rb
+++ b/modules/auth_saml/app/contracts/saml/providers/create_contract.rb
@@ -28,6 +28,7 @@
module Saml
module Providers
class CreateContract < BaseContract
+ attribute :type
end
end
end
diff --git a/modules/auth_saml/app/models/saml/provider.rb b/modules/auth_saml/app/models/saml/provider.rb
index 1a59208a1a5..ec2604d1b38 100644
--- a/modules/auth_saml/app/models/saml/provider.rb
+++ b/modules/auth_saml/app/models/saml/provider.rb
@@ -1,11 +1,7 @@
module Saml
- class Provider < ApplicationRecord
+ class Provider < AuthProvider
include HashBuilder
- self.table_name = "saml_providers"
-
- belongs_to :creator, class_name: "User"
-
store_attribute :options, :sp_entity_id, :string
store_attribute :options, :name_identifier_format, :string
store_attribute :options, :metadata_url, :string
@@ -47,17 +43,10 @@ module Saml
attr_accessor :readonly
- validates_presence_of :display_name
- validates_uniqueness_of :display_name
-
def slug
options.fetch(:name) { "saml-#{id}" }
end
- def limit_self_registration?
- limit_self_registration
- end
-
def has_metadata?
metadata_xml.present? || metadata_url.present?
end
@@ -109,8 +98,7 @@ module Saml
end
def assertion_consumer_service_url
- root_url = OpenProject::StaticRouting::StaticUrlHelpers.new.root_url
- URI.join(root_url, "/auth/#{slug}/callback").to_s
+ callback_url
end
end
end
diff --git a/modules/auth_saml/db/migrate/20240801105918_add_saml_provider.rb b/modules/auth_saml/db/migrate/20240801105918_add_saml_provider.rb
deleted file mode 100644
index 2eac33eae9f..00000000000
--- a/modules/auth_saml/db/migrate/20240801105918_add_saml_provider.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-class AddSamlProvider < ActiveRecord::Migration[7.1]
- def change
- create_table :saml_providers do |t|
- t.string :display_name, null: false, index: { unique: true }
- t.boolean :available, null: false, default: true
- t.boolean :limit_self_registration, null: false, default: false
- t.jsonb :options, default: {}, null: false
- t.references :creator, null: false, index: true, foreign_key: { to_table: :users }
-
- t.timestamps
- end
- end
-end