Module: RazorRisk::Cassini::Authorisation::SecurityModelHelpers
- Includes:
- Pantheios, RazorRisk::Core::Diagnostics::Logger, Xqsr3::Quality::ParameterChecking
- Defined in:
- lib/razor_risk/cassini/authorisation/security_model_helpers.rb
Instance Method Summary collapse
-
#razor_requester_credentials_options(authentication_scheme, credentials, **options) ⇒ Object
Options a RazorRequester-compatible options hash containing credentials appropriate to the given
authentication_scheme.
Instance Method Details
#razor_requester_credentials_options(authentication_scheme, credentials, **options) ⇒ Object
Options a RazorRequester-compatible options hash containing
credentials appropriate to the given authentication_scheme
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/razor_risk/cassini/authorisation/security_model_helpers.rb', line 41 def authentication_scheme, credentials, ** check_parameter authentication_scheme, 'authentication_scheme', type: ::Symbol, values: [ :none, :basic, :authorisation_only, :jwt ] check_parameter(credentials, 'credentials', type: ::Array) { |value| value.empty? ? 'no credentials specified' : true } r = {} credentials = credentials.dup case authentication_scheme when :none ; when :basic if [:auth_test_mode] log :warning, "YOU ARE IN AUTHORIZATION TEST MODE! NO AUTHENTICATION WILL BE PERFORMED! THIS MUST NOT BE USED IN PRODUCTION!" r[:impersonatee] = credentials.shift unless credentials.empty? else r[:username] = credentials.shift unless credentials.empty? r[:password] = credentials.shift unless credentials.empty? r[:domain] = credentials.shift unless credentials.empty? end when :jwt if [:auth_test_mode] log :warning, "YOU ARE IN AUTHORIZATION TEST MODE! NO AUTHENTICATION WILL BE PERFORMED! THIS MUST NOT BE USED IN PRODUCTION!" end r[:session_id] = credentials.shift unless credentials.empty? r[:user_id] = credentials.shift unless credentials.empty? r[:user_name] = credentials.shift unless credentials.empty? when :authorisation_only r[:impersonatee] = credentials.shift unless credentials.empty? else log :violation, "unexpected authentication_scheme '#{authentication_scheme}' (#{authentication_scheme.class})" end r end |