feat: remove enabled field

This commit is contained in:
Shivam Mishra
2025-08-28 16:09:07 +05:30
parent 6274f0f803
commit 85fb20013e
5 changed files with 4 additions and 15 deletions
@@ -2,7 +2,6 @@ class CreateAccountSamlSettings < ActiveRecord::Migration[7.1]
def change
create_table :account_saml_settings do |t|
t.references :account, null: false
t.boolean :enabled, default: false, null: false
t.string :sso_url
t.string :certificate_fingerprint
t.text :certificate
-1
View File
@@ -30,7 +30,6 @@ ActiveRecord::Schema[7.1].define(version: 2025_08_25_070005) do
create_table "account_saml_settings", force: :cascade do |t|
t.bigint "account_id", null: false
t.boolean "enabled", default: false, null: false
t.string "sso_url"
t.string "certificate_fingerprint"
t.text "certificate"
@@ -28,7 +28,6 @@ class Api::V1::Accounts::SamlSettingsController < Api::V1::Accounts::BaseControl
def saml_settings_params
params.require(:saml_settings).permit(
:enabled,
:sso_url,
:certificate_fingerprint,
:certificate,
@@ -6,7 +6,6 @@
# attribute_mappings :json
# certificate :text
# certificate_fingerprint :string
# enabled :boolean default(FALSE), not null
# enforced_sso :boolean default(FALSE), not null
# role_mappings :json
# sso_url :string
@@ -23,16 +22,14 @@ class AccountSamlSettings < ApplicationRecord
belongs_to :account
validates :account_id, presence: true
validates :sso_url, presence: true, if: :enabled?
validates :certificate, presence: true, if: :enabled?
validates :sp_entity_id, presence: true, if: :enabled?
validates :sso_url, presence: true
validates :certificate, presence: true
validates :sp_entity_id, presence: true
before_save :generate_certificate_fingerprint, if: :certificate_changed?
scope :enabled, -> { where(enabled: true) }
def saml_enabled?
enabled && sso_url.present? && certificate_fingerprint.present?
sso_url.present? && certificate_fingerprint.present?
end
def sp_entity_id_or_default
-5
View File
@@ -1,7 +1,6 @@
FactoryBot.define do
factory :account_saml_settings do
account
enabled { false }
sso_url { 'https://idp.example.com/saml/sso' }
certificate_fingerprint { nil }
certificate do
@@ -22,10 +21,6 @@ FactoryBot.define do
attribute_mappings { {} }
role_mappings { {} }
trait :enabled do
enabled { true }
end
trait :with_role_mappings do
role_mappings do
{