Module: Conversant::V3::Mixins::Authentication
- Defined in:
- lib/conversant/v3/mixins/authentication.rb
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.
-
#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.
-
#portal_authorized_headers ⇒ Hash{String => String}
Returns authorized headers for Portal API calls.
-
#vms_authorized_headers ⇒ Hash{String => String}
Returns authorized headers for VMS API calls.
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 |
#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 |
#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 |
#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 |