-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add id_token_hint param to end_session_endpoint * Don't use discovery when set to false * Correct variable update * Linting
- Loading branch information
1 parent
0b85867
commit 0870e66
Showing
4 changed files
with
89 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# frozen_string_literal: true | ||
|
||
module Extensions | ||
module Discovery | ||
Module.new do | ||
# Monkey patch allow HTTP instead of forcing HTTPS for discovery. | ||
|
||
attr_reader :scheme | ||
|
||
def initialize(uri) | ||
@scheme = uri.scheme | ||
super | ||
end | ||
|
||
def endpoint | ||
URI::Generic.build(scheme: scheme, host: host, port: port, path: path) | ||
rescue URI::Error => e | ||
raise SWD::Exception, e.message | ||
end | ||
|
||
prepend_features(::OpenIDConnect::Discovery::Provider::Config::Resource) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# frozen_string_literal: true | ||
|
||
require "omniauth_openid_connect" | ||
require_relative "../../extensions/discovery" | ||
|
||
module OmniAuth | ||
module Strategies | ||
class BaseStrategy < OmniAuth::Strategies::OpenIDConnect | ||
def public_key | ||
@public_key ||= if options.discovery | ||
config.jwks | ||
elsif key_or_secret | ||
key_or_secret | ||
elsif client_options.jwks_uri | ||
fetch_key | ||
end | ||
end | ||
|
||
private | ||
|
||
def fetch_key | ||
@fetch_key ||= parse_jwk_key(::OpenIDConnect.http_client.get_content(client_options.jwks_uri)) | ||
end | ||
|
||
def key_or_secret | ||
@key_or_secret ||= | ||
case options.client_signing_alg&.to_sym | ||
when :HS256, :HS384, :HS512 | ||
client_options.secret | ||
when :RS256, :RS384, :RS512 | ||
parse_key | ||
end | ||
end | ||
|
||
def encoded_post_logout_redirect_uri | ||
return unless options.post_logout_redirect_uri | ||
|
||
query = { | ||
post_logout_redirect_uri: options.post_logout_redirect_uri, | ||
} | ||
query = query.merge({ id_token_hint: params["id_token_hint"] }) if params["id_token_hint"] | ||
|
||
URI.encode_www_form(query) | ||
end | ||
|
||
def parse_key | ||
if options.client_jwk_signing_key | ||
parse_jwk_key(options.client_jwk_signing_key) | ||
elsif options.client_x509_signing_key | ||
parse_x509_key(options.client_x509_signing_key) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,14 @@ | ||
# frozen_string_literal: true | ||
|
||
require "omniauth_openid_connect" | ||
require_relative "base_strategy" | ||
|
||
module OmniAuth | ||
module Strategies | ||
class NitroId < OmniAuth::Strategies::OpenIDConnect | ||
DEFAULT_STRATEGY_NAME = "nitro_id" | ||
DEFAULT_ISSUER = "https://id.powerhrg.com/" | ||
DEFAULT_HOST = "id.powerhrg.com" | ||
|
||
option :name, DEFAULT_STRATEGY_NAME | ||
class NitroId < BaseStrategy | ||
option :name, "nitro_id" | ||
option :discovery, true | ||
option :issuer, DEFAULT_ISSUER | ||
option :client_options, host: DEFAULT_HOST | ||
option :issuer, "https://id.powerhrg.com/" | ||
option :client_options, host: "id.powerhrg.com" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,14 @@ | ||
# frozen_string_literal: true | ||
|
||
require "omniauth_openid_connect" | ||
require_relative "base_strategy" | ||
|
||
module OmniAuth | ||
module Strategies | ||
class TempoId < OmniAuth::Strategies::OpenIDConnect | ||
DEFAULT_STRATEGY_NAME = "tempo_id" | ||
DEFAULT_ISSUER = "https://id.streamfinancial.io/" | ||
DEFAULT_HOST = "id.streamfinancial.io" | ||
|
||
option :name, DEFAULT_STRATEGY_NAME | ||
class TempoId < BaseStrategy | ||
option :name, "tempo_id" | ||
option :discovery, true | ||
option :issuer, DEFAULT_ISSUER | ||
option :client_options, host: DEFAULT_HOST | ||
option :issuer, "https://id.streamfinancial.io/" | ||
option :client_options, host: "id.streamfinancial.io" | ||
end | ||
end | ||
end |