Sha256: b448f18c46565c13fb7126470e4cbe1456398e784262f2f14dfb6322317bf200

Contents?: true

Size: 1.33 KB

Versions: 19

Compression:

Stored size: 1.33 KB

Contents

module RailsBase::Authentication
  class SingleSignOnVerify < RailsBase::ServiceBase
    delegate :data, to: :context
    delegate :reason, to: :context
    delegate :bypass, to: :context

    def call
      datum = find_data_point
      context.data = datum
      if bypass
        context.should_fail = !datum[:valid]
        context.url_redirect = datum[:extra] || RailsBase.url_routes.authenticated_root_path
        log(level: :info, msg: "sending full data point. bypass set to true")
        return
      end

      context.sign_in = false
      if datum[:valid]
        context.sign_in = true
        context.url_redirect = datum[:extra] || RailsBase.url_routes.authenticated_root_path
        context.user = datum[:user]
      else
        context.url_redirect = datum[:extra] || RailsBase.url_routes.unauthenticated_root_path
        context.fail!(message: "Authorization token error: #{datum[:invalid_reason].join(',')}")
      end
    end

    def find_data_point
      params = {
        data: data,
        reason: reason,
        access_count: !(bypass || false)
      }
      ShortLivedData.find_datum(**params)
    end

    def validate!
      raise "Expected data to be a String. Received #{data.class}" unless data.is_a? String
      raise "Expected reason to be a String. Received #{reason.class}" unless reason.is_a? String
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
rails_base-0.82.0 app/services/rails_base/authentication/single_sign_on_verify.rb
rails_base-0.81.1 app/services/rails_base/authentication/single_sign_on_verify.rb
rails_base-0.81.0 app/services/rails_base/authentication/single_sign_on_verify.rb
rails_base-0.80.0 app/services/rails_base/authentication/single_sign_on_verify.rb
rails_base-0.75.6 app/services/rails_base/authentication/single_sign_on_verify.rb
rails_base-0.75.5 app/services/rails_base/authentication/single_sign_on_verify.rb
rails_base-0.75.4 app/services/rails_base/authentication/single_sign_on_verify.rb
rails_base-0.75.3 app/services/rails_base/authentication/single_sign_on_verify.rb
rails_base-0.75.2 app/services/rails_base/authentication/single_sign_on_verify.rb
rails_base-0.75.1 app/services/rails_base/authentication/single_sign_on_verify.rb
rails_base-0.75.0 app/services/rails_base/authentication/single_sign_on_verify.rb
rails_base-0.74.0 app/services/rails_base/authentication/single_sign_on_verify.rb
rails_base-0.73.1 app/services/rails_base/authentication/single_sign_on_verify.rb
rails_base-0.73.0 app/services/rails_base/authentication/single_sign_on_verify.rb
rails_base-0.72.1 app/services/rails_base/authentication/single_sign_on_verify.rb
rails_base-0.72.0 app/services/rails_base/authentication/single_sign_on_verify.rb
rails_base-0.71.0 app/services/rails_base/authentication/single_sign_on_verify.rb
rails_base-0.70.1.pre app/services/rails_base/authentication/single_sign_on_verify.rb
rails_base-0.70.0 app/services/rails_base/authentication/single_sign_on_verify.rb