Skip to content

Commit

Permalink
[SHD-160] Add tempo id provider (#6)
Browse files Browse the repository at this point in the history
Add tempo id provider
  • Loading branch information
web-kat authored Dec 1, 2022
1 parent eb1d5e9 commit 4fd651e
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/omniauth/nitro_id.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@

require "omniauth/nitro_id/version"
require "omniauth/strategies/nitro_id"
require "omniauth/strategies/tempo_id"
18 changes: 18 additions & 0 deletions lib/omniauth/strategies/tempo_id.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

require "omniauth_openid_connect"

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
option :discovery, true
option :issuer, DEFAULT_ISSUER
option :client_options, host: DEFAULT_HOST
end
end
end
55 changes: 55 additions & 0 deletions spec/omniauth/strategies/tempo_id_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# frozen_string_literal: true

require "spec_helper"

describe OmniAuth::Strategies::TempoId do
let(:access_token) { instance_double("AccessToken", :options => {}, :[] => "user") }
let(:custom_client) do
OmniAuth::Strategies::TempoId.new(:test_app,
issuer: "https://example-host.com/",
discovery: false,
client_options: {
host: "example-host.com",
})
end

subject do
OmniAuth::Strategies::TempoId.new({})
end

before(:each) do
allow(subject).to receive(:access_token).and_return(access_token)
end

context "options" do
it "should have correct name" do
expect(subject.options.name).to eq "tempo_id"
end

it "should have correct host" do
expect(subject.options.client_options.host).to eq "id.streamfinancial.io"
end

it "should have correct issuer" do
expect(subject.options.issuer).to eq "https://id.streamfinancial.io/"
end

it "should have the correct discovery setting" do
expect(subject.options.discovery).to eq true
end

describe "should be overrideable" do
it "for host" do
expect(custom_client.options.client_options.host).to eq "example-host.com"
end

it "for issuer" do
expect(custom_client.options.issuer).to eq "https://example-host.com/"
end

it "for discovery" do
expect(custom_client.options.discovery).to eq false
end
end
end
end

0 comments on commit 4fd651e

Please sign in to comment.