Module: Conversant::V3::Mixins::Authentication
- Defined in:
- lib/conversant/v3/mixins/authentication.rb,
sig/conversant/v3.rbs
Overview
Authentication mixin for integrating V3 authentication into existing classes
This mixin provides a bridge for existing classes to use Conversant V3 authentication without fully adopting the gem's service architecture. It's designed for gradual migration and backward compatibility.
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#customer_id ⇒ Integer
readonly
Customer ID for API calls.
-
#type ⇒ Integer
readonly
Customer type.
Class Method Summary collapse
-
.included(base) ⇒ void
Hook called when module is included.
Instance Method Summary collapse
-
#cdn_authorized_headers ⇒ Hash{String => String}
Returns authorized headers for CDN API calls.
-
#cdn_service ⇒ Conversant::V3::Services::CDN
Gets or creates CDN service instance.
-
#configuration ⇒ Conversant::Configuration
Returns the global Conversant configuration.
-
#conversant_authenticate ⇒ Hash{Symbol => String}?
Authenticates and returns SSO sessions.
-
#initialize_conversant_auth(customer_id, type = 2) ⇒ void
Initializes authentication with customer ID and type.
-
#lms_authorized_headers ⇒ Hash{String => String}
Returns authorized headers for LMS API calls.
-
#lms_service ⇒ Conversant::V3::Services::LMS
Gets or creates LMS service instance.
-
#portal_authorized_headers ⇒ Hash{String => String}
Returns authorized headers for Portal API calls.
-
#portal_service ⇒ Conversant::V3::Services::Portal
Gets or creates Portal service instance.
-
#redis ⇒ Redis
Returns the Redis client from configuration.
-
#vms_authorized_headers ⇒ Hash{String => String}
Returns authorized headers for VMS API calls.
-
#vms_service ⇒ Conversant::V3::Services::VMS
Gets or creates VMS service instance.
Instance Attribute Details
#customer_id ⇒ Integer (readonly)
Returns Customer ID for API calls.
72 73 74 |
# File 'lib/conversant/v3/mixins/authentication.rb', line 72 def customer_id @customer_id end |
#type ⇒ Integer (readonly)
Returns Customer type.
75 76 77 |
# File 'lib/conversant/v3/mixins/authentication.rb', line 75 def type @type end |
Class Method Details
.included(base) ⇒ void
This method returns an undefined value.
Hook called when module is included
47 48 49 |
# File 'lib/conversant/v3/mixins/authentication.rb', line 47 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#cdn_authorized_headers ⇒ Hash{String => String}
Returns authorized headers for CDN API calls
Delegates to CDN service class which uses the Authorization module.
141 142 143 |
# File 'lib/conversant/v3/mixins/authentication.rb', line 141 def cdn_service.send(:authorized_headers) end |
#cdn_service ⇒ Conversant::V3::Services::CDN
Gets or creates CDN service instance
187 188 189 |
# File 'lib/conversant/v3/mixins/authentication.rb', line 187 def cdn_service @cdn_service ||= Conversant::V3.cdn(@customer_id, @type) end |
#configuration ⇒ Conversant::Configuration
Returns the global Conversant configuration
208 209 210 |
# File 'lib/conversant/v3/mixins/authentication.rb', line 208 def configuration Conversant.configuration end |
#conversant_authenticate ⇒ Hash{Symbol => String}?
Authenticates and returns SSO sessions
Wrapper method for backward compatibility with existing code.
109 110 111 |
# File 'lib/conversant/v3/mixins/authentication.rb', line 109 def conversant_authenticate authenticate end |
#initialize_conversant_auth(customer_id, type = 2) ⇒ void
This method returns an undefined value.
Initializes authentication with customer ID and type
Call this from your class's initialize method to set up authentication.
91 92 93 94 |
# File 'lib/conversant/v3/mixins/authentication.rb', line 91 def initialize_conversant_auth(customer_id, type = 2) @customer_id = customer_id # @type [Integer] @type = type # @type [Integer] end |
#lms_authorized_headers ⇒ Hash{String => String}
Returns authorized headers for LMS API calls
Delegates to LMS service class which uses the Authorization module.
156 157 158 |
# File 'lib/conversant/v3/mixins/authentication.rb', line 156 def lms_service.send(:authorized_headers) end |
#lms_service ⇒ Conversant::V3::Services::LMS
Gets or creates LMS service instance
194 195 196 |
# File 'lib/conversant/v3/mixins/authentication.rb', line 194 def lms_service @lms_service ||= Conversant::V3.lms(@customer_id, @type) end |
#portal_authorized_headers ⇒ Hash{String => String}
Returns authorized headers for Portal API calls
Delegates to Portal service class which uses the Authorization module.
126 127 128 |
# File 'lib/conversant/v3/mixins/authentication.rb', line 126 def portal_service.send(:authorized_headers) end |
#portal_service ⇒ Conversant::V3::Services::Portal
Gets or creates Portal service instance
180 181 182 |
# File 'lib/conversant/v3/mixins/authentication.rb', line 180 def portal_service @portal_service ||= Conversant::V3.portal(@customer_id, @type) end |
#redis ⇒ Redis
Returns the Redis client from configuration
215 216 217 |
# File 'lib/conversant/v3/mixins/authentication.rb', line 215 def redis configuration.redis end |
#vms_authorized_headers ⇒ Hash{String => String}
Returns authorized headers for VMS API calls
Delegates to VMS service class which uses the Authorization module.
171 172 173 |
# File 'lib/conversant/v3/mixins/authentication.rb', line 171 def vms_service.send(:authorized_headers) end |
#vms_service ⇒ Conversant::V3::Services::VMS
Gets or creates VMS service instance
201 202 203 |
# File 'lib/conversant/v3/mixins/authentication.rb', line 201 def vms_service @vms_service ||= Conversant::V3.vms(@customer_id, @type) end |