Class: Bidi2pdf::Bidi::AuthInterceptor
- Inherits:
-
Object
- Object
- Bidi2pdf::Bidi::AuthInterceptor
- Includes:
- Interceptor
- Defined in:
- lib/bidi2pdf/bidi/auth_interceptor.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#network_ids ⇒ Object
readonly
Returns the value of attribute network_ids.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#url_patterns ⇒ Object
readonly
Returns the value of attribute url_patterns.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(username:, password:, url_patterns:, context:) ⇒ AuthInterceptor
constructor
A new instance of AuthInterceptor.
- #process_interception(_event_response, navigation_id, network_id, url) ⇒ Object
Methods included from Interceptor
#client, #handle_event, included, #interceptor_id, #register_with_client, #unregister_with_client, #validate_phases!
Constructor Details
#initialize(username:, password:, url_patterns:, context:) ⇒ AuthInterceptor
Returns a new instance of AuthInterceptor.
18 19 20 21 22 23 24 |
# File 'lib/bidi2pdf/bidi/auth_interceptor.rb', line 18 def initialize(username:, password:, url_patterns:, context:) @url_patterns = url_patterns @context = context @username = username @password = password @network_ids = [] end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
16 17 18 |
# File 'lib/bidi2pdf/bidi/auth_interceptor.rb', line 16 def context @context end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
16 17 18 |
# File 'lib/bidi2pdf/bidi/auth_interceptor.rb', line 16 def headers @headers end |
#network_ids ⇒ Object (readonly)
Returns the value of attribute network_ids.
16 17 18 |
# File 'lib/bidi2pdf/bidi/auth_interceptor.rb', line 16 def network_ids @network_ids end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
16 17 18 |
# File 'lib/bidi2pdf/bidi/auth_interceptor.rb', line 16 def password @password end |
#url_patterns ⇒ Object (readonly)
Returns the value of attribute url_patterns.
16 17 18 |
# File 'lib/bidi2pdf/bidi/auth_interceptor.rb', line 16 def url_patterns @url_patterns end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
16 17 18 |
# File 'lib/bidi2pdf/bidi/auth_interceptor.rb', line 16 def username @username end |
Class Method Details
.events ⇒ Object
13 |
# File 'lib/bidi2pdf/bidi/auth_interceptor.rb', line 13 def events = ["network.authRequired"] |
.phases ⇒ Object
11 |
# File 'lib/bidi2pdf/bidi/auth_interceptor.rb', line 11 def phases = [Bidi2pdf::Bidi::Commands::AddIntercept::AUTH_REQUIRED] |
Instance Method Details
#process_interception(_event_response, navigation_id, network_id, url) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/bidi2pdf/bidi/auth_interceptor.rb', line 26 def process_interception(_event_response, , network_id, url) return if handled_bad_credentials(, network_id, url) network_ids << network_id cmd = Bidi2pdf::Bidi::Commands::ProvideCredentials.new request: network_id, username: username, password: password client.send_cmd(cmd) rescue StandardError => e Bidi2pdf.logger.error "Error handling auth event: #{e.message}" Bidi2pdf.logger.error e.backtrace.join("\n") raise e end |