Skip to content

Commit

Permalink
[SHD-1009] Use dynamic options (#46)
Browse files Browse the repository at this point in the history
Use dynamic issuer for JWK discovery and token introspection.

This is needed for testing integration with NitroID environments outside
of production. This is useful when testing feature additions or updates
to NitroID's OAuth flows.

---------

Co-authored-by: Denis Zablotsky <[email protected]>
  • Loading branch information
web-kat and denisZablotsky authored Dec 18, 2024
1 parent c71e3a2 commit 9c327a8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
20 changes: 19 additions & 1 deletion docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

* Use dynamic issuer for JWK discovery and token introspection

## [1.3.3] - 2024-07-01

### Fixed

* Correct URLs for JWK discovery and token introspection. PR [#43](https://github.com/powerhome/omniauth-nitro-id/pull/43)

## [1.3.2] - 2024-06-30

### Fixed

* Correct default issuer value for nitro-id and tempo-id strategies. PR [#41](https://github.com/powerhome/omniauth-nitro-id/pull/41)

## [1.3.1] - 2023-09-21

* Display better error message for missing credentials. PR [#27](https://github.com/powerhome/omniauth-nitro-id/pull/27)
Expand Down Expand Up @@ -47,7 +63,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

* Initial release

[Unreleased]: https://github.com/powerhome/omniauth-nitro-id/compare/v1.3.1...HEAD
[Unreleased]: https://github.com/powerhome/omniauth-nitro-id/compare/v1.3.3...HEAD
[1.3.3]: https://github.com/powerhome/omniauth-nitro-id/releases/tag/v1.3.3
[1.3.2]: https://github.com/powerhome/omniauth-nitro-id/releases/tag/v1.3.2
[1.3.1]: https://github.com/powerhome/omniauth-nitro-id/releases/tag/v1.3.1
[1.3.0]: https://github.com/powerhome/omniauth-nitro-id/releases/tag/v1.3.0
[1.2.1]: https://github.com/powerhome/omniauth-nitro-id/releases/tag/v1.2.1
Expand Down
6 changes: 3 additions & 3 deletions lib/omniauth/strategies/base_strategy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def self.decode_logout_token(token)
end

def self.fetch_jwks
key = ::OpenIDConnect.http_client.get("#{default_options[:issuer]}/.well-known/jwks.json").body
key = ::OpenIDConnect.http_client.get("#{options[:issuer]}/.well-known/jwks.json").body
json = key.is_a?(String) ? JSON.parse(key) : key
return JSON::JWK::Set.new(json["keys"]) if json.key?("keys")

Expand All @@ -45,9 +45,9 @@ def self.introspect_token(token, api_key)
body: { token: token },
}

response = ::OpenIDConnect.http_client.post("#{default_options[:issuer]}/api/tokens/introspect", **options)
response = ::OpenIDConnect.http_client.post("#{options[:issuer]}/api/tokens/introspect", **options)

raise APIError, "#{default_options[:name]} error: #{response.status}" if response.status.to_i >= 400
raise APIError, "#{options[:name]} error: #{response.status}" if response.status.to_i >= 400

JSON.parse(response.body)
end
Expand Down

0 comments on commit 9c327a8

Please sign in to comment.