Module: OmniauthOpenidFederation::TasksHelper
- Defined in:
- lib/omniauth_openid_federation/tasks_helper.rb
Class Method Summary collapse
- .detect_key_status(jwks) ⇒ Object
- .fetch_entity_statement(url:, output_file:, fingerprint: nil) ⇒ Object
- .fetch_jwks(jwks_uri:, output_file:) ⇒ Object
- .parse_entity_statement(file_path:) ⇒ Object
- .prepare_client_keys(key_type:, output_dir:) ⇒ Object
- .process_callback_and_validate(callback_url:, base_url:, client_id:, redirect_uri:, private_key:, entity_statement_url: nil, entity_statement_path: nil, provider_acr: nil, client_entity_statement_url: nil, client_entity_statement_path: nil) ⇒ Object
- .resolve_path(file_path) ⇒ Object
- .test_authentication_flow(login_page_url:, base_url:, provider_acr: nil) ⇒ Object
- .test_local_endpoint(base_url:) ⇒ Object
- .validate_entity_statement(file_path:, expected_fingerprint: nil) ⇒ Object
Class Method Details
.detect_key_status(jwks) ⇒ Object
112 113 114 |
# File 'lib/omniauth_openid_federation/tasks_helper.rb', line 112 def self.detect_key_status(jwks) Tasks::LocalEndpointTester.detect_key_status(jwks) end |
.fetch_entity_statement(url:, output_file:, fingerprint: nil) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/omniauth_openid_federation/tasks_helper.rb', line 23 def self.fetch_entity_statement(url:, output_file:, fingerprint: nil) output_path = resolve_path(output_file) entity_statement = Federation::EntityStatement.fetch!( url, fingerprint: fingerprint ) entity_statement.save_to_file(output_path) = entity_statement.parse { success: true, entity_statement: entity_statement, output_path: output_path, fingerprint: entity_statement.fingerprint, metadata: } end |
.fetch_jwks(jwks_uri:, output_file:) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/omniauth_openid_federation/tasks_helper.rb', line 72 def self.fetch_jwks(jwks_uri:, output_file:) output_path = resolve_path(output_file) jwks = Jwks::Fetch.run(jwks_uri) File.write(output_path, JSON.pretty_generate(jwks)) { success: true, jwks: jwks, output_path: output_path } end |
.parse_entity_statement(file_path:) ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/omniauth_openid_federation/tasks_helper.rb', line 86 def self.parse_entity_statement(file_path:) resolved_path = resolve_path(file_path) unless File.exist?(resolved_path) raise ConfigurationError, "Entity statement file not found: #{resolved_path}" end = EntityStatementReader.( entity_statement_path: resolved_path ) unless raise Federation::EntityStatement::ValidationError, "Failed to parse entity statement" end end |
.prepare_client_keys(key_type:, output_dir:) ⇒ Object
104 105 106 |
# File 'lib/omniauth_openid_federation/tasks_helper.rb', line 104 def self.prepare_client_keys(key_type:, output_dir:) Tasks::ClientKeysPreparer.prepare(key_type: key_type, output_dir: output_dir) end |
.process_callback_and_validate(callback_url:, base_url:, client_id:, redirect_uri:, private_key:, entity_statement_url: nil, entity_statement_path: nil, provider_acr: nil, client_entity_statement_url: nil, client_entity_statement_path: nil) ⇒ Object
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/omniauth_openid_federation/tasks_helper.rb', line 124 def self.process_callback_and_validate( callback_url:, base_url:, client_id:, redirect_uri:, private_key:, entity_statement_url: nil, entity_statement_path: nil, provider_acr: nil, client_entity_statement_url: nil, client_entity_statement_path: nil ) Tasks::CallbackProcessor.process( callback_url: callback_url, base_url: base_url, client_id: client_id, redirect_uri: redirect_uri, private_key: private_key, entity_statement_url: entity_statement_url, entity_statement_path: entity_statement_path, provider_acr: provider_acr, client_entity_statement_url: client_entity_statement_url, client_entity_statement_path: client_entity_statement_path ) end |
.resolve_path(file_path) ⇒ Object
19 20 21 |
# File 'lib/omniauth_openid_federation/tasks_helper.rb', line 19 def self.resolve_path(file_path) Tasks::PathResolver.resolve(file_path) end |
.test_authentication_flow(login_page_url:, base_url:, provider_acr: nil) ⇒ Object
116 117 118 119 120 121 122 |
# File 'lib/omniauth_openid_federation/tasks_helper.rb', line 116 def self.test_authentication_flow(login_page_url:, base_url:, provider_acr: nil) Tasks::AuthenticationFlowTester.run( login_page_url: login_page_url, base_url: base_url, provider_acr: provider_acr ) end |
.test_local_endpoint(base_url:) ⇒ Object
108 109 110 |
# File 'lib/omniauth_openid_federation/tasks_helper.rb', line 108 def self.test_local_endpoint(base_url:) Tasks::LocalEndpointTester.run(base_url: base_url) end |
.validate_entity_statement(file_path:, expected_fingerprint: nil) ⇒ Object
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 |
# File 'lib/omniauth_openid_federation/tasks_helper.rb', line 44 def self.validate_entity_statement(file_path:, expected_fingerprint: nil) resolved_path = resolve_path(file_path) unless File.exist?(resolved_path) raise ConfigurationError, "Entity statement file not found: #{resolved_path}" end entity_statement_content = File.read(resolved_path) entity_statement = Federation::EntityStatement.new( entity_statement_content, fingerprint: expected_fingerprint ) if expected_fingerprint unless entity_statement.validate_fingerprint(expected_fingerprint) raise Federation::EntityStatement::ValidationError, "Fingerprint mismatch: expected #{expected_fingerprint}, got #{entity_statement.fingerprint}" end end = entity_statement.parse { success: true, fingerprint: entity_statement.fingerprint, metadata: } end |