osso 0.0.3.21 → 0.0.3.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c333af7fbc082441290340a2d49c93256b0d6ba6eda97ae6ab3689ccf3335da7
4
- data.tar.gz: b4f51151c6e1608b624a857b2ed657be48c44593af4dd621b558a74fe0cca297
3
+ metadata.gz: cb9f3d69563582f827ee2bca6484354ef751f2f4a47078227756a866b5bf59b0
4
+ data.tar.gz: da7fa02b67baf9c336d380bb3798874375b8580d6e414cc29193143ab7b33bb0
5
5
  SHA512:
6
- metadata.gz: 2d3ab0db1e4f6137bfbfe30c6f90ed098e061fcd6f90cc62f6b7818bba64c9d59a9c56af3ef87ee987b12f472f69fd890d583406c1630cb80ac6b2725118e8c7
7
- data.tar.gz: b6c1d1fda9fd6f4d24dfb5e03a8f3271ff5853ed9660921e0318065c8e0d6c57bce4f400a3b1c49f4b2171b203301c1c1782ba9f76b976cf42f65e9be801523c
6
+ metadata.gz: 2e4eff9a9f7c39460bd0691e6c5f67464e2350e36477d90f10ac1cc47277347f17c1a2a20ec61aff2194a630dc651a1d5f7ebaa3855af09829aaa4f5021a4fb6
7
+ data.tar.gz: 2f990d6ced375400d60a06200e3f14758c6574657cfd16509e6239511f0f4622bad5106ed1a819089dbf356b9e3612952682b1a52bdd7b450a0f6b8d26f00d56
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- osso (0.0.3.21)
4
+ osso (0.0.3.26)
5
5
  activesupport (>= 6.0.3.2)
6
6
  graphql
7
7
  jwt
@@ -13,7 +13,7 @@ module Osso
13
13
 
14
14
  def resolve(id:)
15
15
  oauth_client = Osso::Models::OauthClient.find(id)
16
- oauth_client.generate_secrets
16
+ oauth_client.regenerate_secrets!
17
17
 
18
18
  return response_data(oauth_client: oauth_client) if oauth_client.save
19
19
 
@@ -4,7 +4,6 @@ module Osso
4
4
  module Models
5
5
  # Base class for SAML Providers
6
6
  class IdentityProvider < ActiveRecord::Base
7
- NAME_FORMAT = 'urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress'
8
7
  belongs_to :enterprise_account
9
8
  belongs_to :oauth_client
10
9
  has_many :users
@@ -41,8 +40,18 @@ module Osso
41
40
  self.status = 'CONFIGURED' if sso_url && sso_cert
42
41
  end
43
42
 
43
+ def active!
44
+ update(status: 'ACTIVE')
45
+ end
46
+
47
+ def error!
48
+ update(status: 'ERROR')
49
+ end
50
+
44
51
  def root_url
45
- ENV['HEROKU_APP_NAME'] || ENV.fetch('BASE_URL')
52
+ return "https://#{ENV['HEROKU_APP_NAME']}.herokuapp.com" if ENV['HEROKU_APP_NAME']
53
+
54
+ ENV.fetch('BASE_URL')
46
55
  end
47
56
  end
48
57
  end
@@ -26,6 +26,11 @@ module Osso
26
26
  self.identifier ||= SecureRandom.hex(16)
27
27
  self.secret ||= SecureRandom.hex(32)
28
28
  end
29
+
30
+ def regenerate_secrets!
31
+ self.identifier = SecureRandom.hex(16)
32
+ self.secret = SecureRandom.hex(32)
33
+ end
29
34
  end
30
35
  end
31
36
  end
@@ -58,8 +58,7 @@ module Osso
58
58
  oauth_client: @oauth_client,
59
59
  redirect_uri: redirect_uri,
60
60
  )
61
-
62
- # Mark IDP as active
61
+ provider.active!
63
62
 
64
63
  redirect(redirect_uri + "?code=#{CGI.escape(authorization_code.token)}&state=#{provider_state}")
65
64
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Osso
4
- VERSION = '0.0.3.21'
4
+ VERSION = '0.0.3.26'
5
5
  end
@@ -5,6 +5,7 @@ FactoryBot.define do
5
5
  id { SecureRandom.uuid }
6
6
  domain { Faker::Internet.domain_name }
7
7
  oauth_client
8
+ status { 'PENDING' }
8
9
 
9
10
  factory :okta_identity_provider, parent: :identity_provider do
10
11
  service { 'OKTA' }
@@ -21,6 +22,7 @@ FactoryBot.define do
21
22
  end
22
23
 
23
24
  factory :configured_identity_provider, parent: :identity_provider do
25
+ status { 'CONFIGURED' }
24
26
  sso_cert do
25
27
  <<~CERT
26
28
  -----BEGIN CERTIFICATE-----
@@ -6,11 +6,20 @@ describe Osso::Models::IdentityProvider do
6
6
  subject { create(:okta_identity_provider) }
7
7
 
8
8
  describe '#assertion_consumer_service_url' do
9
- it 'returns the expected URI' do
9
+ it 'returns the expected URI for BASE_URL' do
10
+ ENV['HEROKU_APP_NAME'] = nil
10
11
  ENV['BASE_URL'] = 'https://example.com'
11
12
 
12
13
  expect(subject.assertion_consumer_service_url).to eq(
13
- "https://example.com/auth/saml/#{subject.id}/callback",
14
+ "#{ENV['BASE_URL']}/auth/saml/#{subject.id}/callback",
15
+ )
16
+ end
17
+
18
+ it 'returns the expected URI for HEROKU_APP_NAME' do
19
+ ENV['HEROKU_APP_NAME'] = 'test'
20
+
21
+ expect(subject.assertion_consumer_service_url).to eq(
22
+ "https://test.herokuapp.com/auth/saml/#{subject.id}/callback",
14
23
  )
15
24
  end
16
25
  end
@@ -104,6 +104,17 @@ describe Osso::Auth do
104
104
  )
105
105
  end.to_not(change { Osso::Models::User.count })
106
106
  end
107
+ it 'marks the provider as ACTIVE' do
108
+ post(
109
+ "/auth/saml/#{okta_provider.id}/callback",
110
+ nil,
111
+ {
112
+ 'omniauth.auth' => OmniAuth.config.mock_auth[:saml],
113
+ 'identity_provider' => okta_provider,
114
+ },
115
+ )
116
+ expect(okta_provider.reload.status).to eq('ACTIVE')
117
+ end
107
118
  end
108
119
  end
109
120
 
@@ -126,6 +137,21 @@ describe Osso::Auth do
126
137
  )
127
138
  end.to change { Osso::Models::User.count }.by(1)
128
139
  end
140
+
141
+ it 'marks the provider ACTIVE' do
142
+ mock_saml_omniauth
143
+
144
+ post(
145
+ "/auth/saml/#{azure_provider.id}/callback",
146
+ nil,
147
+ {
148
+ 'omniauth.auth' => OmniAuth.config.mock_auth[:saml],
149
+ 'identity_provider' => azure_provider,
150
+ },
151
+ )
152
+
153
+ expect(azure_provider.reload.status).to eq('ACTIVE')
154
+ end
129
155
  end
130
156
 
131
157
  describe 'on subsequent authentications' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: osso
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3.21
4
+ version: 0.0.3.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Bauch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-27 00:00:00.000000000 Z
11
+ date: 2020-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport