osso 0.0.11 → 0.1.0

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: f3def53429479fcc6f8174b8065830233e8437b3e6cd5e6a2647caa710622028
4
- data.tar.gz: dbdaa671b3a6b2ca07e5d48ed247eefbdbe6bd06423247975821088aea097f45
3
+ metadata.gz: c263ca76f08c31c90de62d7b81c1d1d8b93817dba65f9424b81223ae2c003418
4
+ data.tar.gz: 6e869dff216866735060d0cae9a478a3bdbc76a59b0a5b2b06ad419dca0c09c3
5
5
  SHA512:
6
- metadata.gz: '0391fb57427e5f417ee19f2566cda5e432834bff640d14516abdf54a716c401c6ed42559ed5f366855936e2f6d976f86e1c64c1bfd497f9b3443f8a54f240485'
7
- data.tar.gz: 1bdc64d6943502b18f7801003131d379879bad62265bc80f4f5cd5c9547604d7fb60b35a174ce9875a1d5b13ef673535bed4566d14d5888de1552b40a9c0d26b
6
+ metadata.gz: 4e8d2b6df9b9520d209cdda204d8a69d8d072277bbb5d2ec3a961bbdf2710712d07fc6a9b2cfd1683f6e53450b54e61706a4e49418286d9cce161ebc03690bbe
7
+ data.tar.gz: a9d71e8fc6fe531c48b51c8534a8dfedbb94d265f97ae6b1365ad47485a34ee8cf0ffc5ad4e426f0dc4e1d818f57b425a1fa6c697a8e638a76d80627ee5d728e
@@ -1,25 +1,10 @@
1
1
  AllCops:
2
+ NewCops: enable
2
3
  TargetRubyVersion: 2.6.0
3
4
  Exclude:
4
5
  - db/**/*
5
6
  - lib/osso/db/**/*
6
7
 
7
- # New rules must be explicitly opted into / out of
8
- Lint/RaiseException:
9
- Enabled: true
10
- Lint/StructNewOverride:
11
- Enabled: true
12
- Style/HashEachMethods:
13
- Enabled: true
14
- Style/HashTransformKeys:
15
- Enabled: true
16
- Style/HashTransformValues:
17
- Enabled: true
18
- Layout/SpaceAroundMethodCallOperator:
19
- Enabled: true
20
- Style/ExponentialNotation:
21
- Enabled: true
22
-
23
8
  Style/TrailingCommaInArguments:
24
9
  Description: "Checks for trailing comma in argument lists."
25
10
  StyleGuide: "https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas"
@@ -50,6 +35,9 @@ Style/TrailingCommaInHashLiteral:
50
35
  - no_comma
51
36
  Enabled: true
52
37
 
38
+ Layout/FirstHashElementIndentation:
39
+ EnforcedStyle: consistent
40
+
53
41
  Layout/MultilineMethodCallIndentation:
54
42
  EnforcedStyle: indented
55
43
 
data/Gemfile CHANGED
@@ -12,7 +12,7 @@ group :test do
12
12
  gem 'rack-test'
13
13
  gem 'rspec', '~> 3.10'
14
14
  gem 'rubocop'
15
- gem 'simplecov', '0.21.1', require: false
15
+ gem 'simplecov', '0.21.2', require: false
16
16
  gem 'webmock', '~> 3.11'
17
17
  end
18
18
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- osso (0.0.11)
4
+ osso (0.1.0)
5
5
  activesupport (>= 6.0.3.2)
6
6
  bcrypt (~> 3.1.13)
7
7
  graphql
@@ -13,23 +13,24 @@ PATH
13
13
  rack (>= 2.1.4)
14
14
  rack-contrib
15
15
  rack-oauth2
16
+ rack-protection (~> 2.1.0)
16
17
  rake
17
- rodauth (>= 2.6, < 2.8)
18
- sequel (>= 5.37, < 5.41)
18
+ rodauth (~> 2.9)
19
+ sequel (~> 5.40)
19
20
  sequel-activerecord_connection (>= 0.3, < 2.0)
20
21
  sinatra
21
- sinatra-activerecord
22
+ sinatra-activerecord (>= 2.0.22)
22
23
  sinatra-contrib
23
24
 
24
25
  GEM
25
26
  remote: https://rubygems.org/
26
27
  specs:
27
- activemodel (6.1.0)
28
- activesupport (= 6.1.0)
29
- activerecord (6.1.0)
30
- activemodel (= 6.1.0)
31
- activesupport (= 6.1.0)
32
- activesupport (6.1.0)
28
+ activemodel (6.1.1)
29
+ activesupport (= 6.1.1)
30
+ activerecord (6.1.1)
31
+ activemodel (= 6.1.1)
32
+ activesupport (= 6.1.1)
33
+ activesupport (6.1.1)
33
34
  concurrent-ruby (~> 1.0, >= 1.0.2)
34
35
  i18n (>= 1.6, < 2)
35
36
  minitest (>= 5.1)
@@ -43,28 +44,29 @@ GEM
43
44
  annotate (3.1.1)
44
45
  activerecord (>= 3.2, < 7.0)
45
46
  rake (>= 10.4, < 14.0)
46
- ast (2.4.1)
47
+ ast (2.4.2)
47
48
  attr_required (1.0.1)
48
49
  bcrypt (3.1.16)
49
50
  bindata (2.4.8)
50
51
  coderay (1.1.3)
51
- concurrent-ruby (1.1.7)
52
- crack (0.4.4)
52
+ concurrent-ruby (1.1.8)
53
+ crack (0.4.5)
54
+ rexml
53
55
  database_cleaner (1.8.5)
54
56
  database_cleaner-active_record (1.8.0)
55
57
  activerecord
56
58
  database_cleaner (~> 1.8.0)
57
59
  diff-lcs (1.4.4)
58
- docile (1.3.4)
60
+ docile (1.3.5)
59
61
  factory_bot (6.1.0)
60
62
  activesupport (>= 5.0.0)
61
63
  faker (2.15.1)
62
64
  i18n (>= 1.6, < 2)
63
- graphql (1.11.6)
65
+ graphql (1.12.2)
64
66
  hashdiff (1.0.1)
65
67
  hashie (4.1.0)
66
68
  httpclient (2.8.3)
67
- i18n (1.8.5)
69
+ i18n (1.8.7)
68
70
  concurrent-ruby (~> 1.0)
69
71
  json-jwt (1.13.0)
70
72
  activesupport (>= 4.2)
@@ -76,20 +78,21 @@ GEM
76
78
  method_source (1.0.0)
77
79
  mini_mime (1.0.2)
78
80
  mini_portile2 (2.5.0)
79
- minitest (5.14.2)
81
+ minitest (5.14.3)
80
82
  multi_json (1.15.0)
81
83
  mustermann (1.1.1)
82
84
  ruby2_keywords (~> 0.0.1)
83
85
  nokogiri (1.11.1)
84
86
  mini_portile2 (~> 2.5.0)
85
87
  racc (~> 1.4)
86
- omniauth (1.9.1)
88
+ omniauth (2.0.1)
87
89
  hashie (>= 3.4.6)
88
90
  rack (>= 1.6.2, < 3)
91
+ rack-protection
89
92
  omniauth-multi-provider (0.2.1)
90
93
  omniauth
91
- omniauth-saml (1.10.3)
92
- omniauth (~> 1.3, >= 1.3.2)
94
+ omniauth-saml (2.0.0)
95
+ omniauth (~> 2.0)
93
96
  ruby-saml (~> 1.9)
94
97
  parallel (1.20.1)
95
98
  parser (3.0.0.0)
@@ -116,47 +119,47 @@ GEM
116
119
  rack (>= 1.0, < 3)
117
120
  rainbow (3.0.0)
118
121
  rake (13.0.3)
119
- regexp_parser (2.0.2)
122
+ regexp_parser (2.0.3)
120
123
  rexml (3.2.4)
121
- roda (3.39.0)
124
+ roda (3.40.0)
122
125
  rack
123
- rodauth (2.7.0)
126
+ rodauth (2.9.0)
124
127
  roda (>= 2.6.0)
125
128
  sequel (>= 4)
126
129
  rspec (3.10.0)
127
130
  rspec-core (~> 3.10.0)
128
131
  rspec-expectations (~> 3.10.0)
129
132
  rspec-mocks (~> 3.10.0)
130
- rspec-core (3.10.0)
133
+ rspec-core (3.10.1)
131
134
  rspec-support (~> 3.10.0)
132
- rspec-expectations (3.10.0)
135
+ rspec-expectations (3.10.1)
133
136
  diff-lcs (>= 1.2.0, < 2.0)
134
137
  rspec-support (~> 3.10.0)
135
- rspec-mocks (3.10.0)
138
+ rspec-mocks (3.10.1)
136
139
  diff-lcs (>= 1.2.0, < 2.0)
137
140
  rspec-support (~> 3.10.0)
138
- rspec-support (3.10.0)
139
- rubocop (1.7.0)
141
+ rspec-support (3.10.1)
142
+ rubocop (1.8.1)
140
143
  parallel (~> 1.10)
141
- parser (>= 2.7.1.5)
144
+ parser (>= 3.0.0.0)
142
145
  rainbow (>= 2.2.2, < 4.0)
143
146
  regexp_parser (>= 1.8, < 3.0)
144
147
  rexml
145
148
  rubocop-ast (>= 1.2.0, < 2.0)
146
149
  ruby-progressbar (~> 1.7)
147
- unicode-display_width (>= 1.4.0, < 2.0)
148
- rubocop-ast (1.3.0)
150
+ unicode-display_width (>= 1.4.0, < 3.0)
151
+ rubocop-ast (1.4.1)
149
152
  parser (>= 2.7.1.5)
150
- ruby-progressbar (1.10.1)
153
+ ruby-progressbar (1.11.0)
151
154
  ruby-saml (1.11.0)
152
155
  nokogiri (>= 1.5.10)
153
- ruby2_keywords (0.0.2)
154
- sequel (5.39.0)
155
- sequel-activerecord_connection (1.2.0)
156
+ ruby2_keywords (0.0.4)
157
+ sequel (5.40.0)
158
+ sequel-activerecord_connection (1.2.2)
156
159
  activerecord (>= 4.2, < 7)
157
160
  after_commit_everywhere (~> 0.1.5)
158
161
  sequel (~> 5.16)
159
- simplecov (0.21.1)
162
+ simplecov (0.21.2)
160
163
  docile (~> 1.1)
161
164
  simplecov-html (~> 0.11)
162
165
  simplecov_json_formatter (~> 0.1)
@@ -167,7 +170,7 @@ GEM
167
170
  rack (~> 2.2)
168
171
  rack-protection (= 2.1.0)
169
172
  tilt (~> 2.0)
170
- sinatra-activerecord (2.0.21)
173
+ sinatra-activerecord (2.0.22)
171
174
  activerecord (>= 4.1)
172
175
  sinatra (>= 1.0)
173
176
  sinatra-contrib (2.1.0)
@@ -177,10 +180,10 @@ GEM
177
180
  sinatra (= 2.1.0)
178
181
  tilt (~> 2.0)
179
182
  tilt (2.0.10)
180
- tzinfo (2.0.3)
183
+ tzinfo (2.0.4)
181
184
  concurrent-ruby (~> 1.0)
182
- unicode-display_width (1.7.0)
183
- webmock (3.11.0)
185
+ unicode-display_width (2.0.0)
186
+ webmock (3.11.1)
184
187
  addressable (>= 2.3.6)
185
188
  crack (>= 0.3.2)
186
189
  hashdiff (>= 0.4.0, < 2.0.0)
@@ -201,7 +204,7 @@ DEPENDENCIES
201
204
  rack-test
202
205
  rspec (~> 3.10)
203
206
  rubocop
204
- simplecov (= 0.21.1)
207
+ simplecov (= 0.21.2)
205
208
  webmock (~> 3.11)
206
209
 
207
210
  BUNDLED WITH
@@ -17,7 +17,7 @@ module Osso
17
17
 
18
18
  if provider.update(args)
19
19
  Osso::Analytics.capture(email: context[:email], event: self.class.name.demodulize, properties: args)
20
- return response_data(identity_provider: provider)
20
+ return response_data(identity_provider: provider)
21
21
  end
22
22
 
23
23
  response_error(provider.errors)
@@ -17,7 +17,7 @@ module Osso
17
17
 
18
18
  if enterprise_account.save
19
19
  Osso::Analytics.capture(email: context[:email], event: self.class.name.demodulize, properties: args)
20
- return response_data(enterprise_account: enterprise_account)
20
+ return response_data(enterprise_account: enterprise_account)
21
21
  end
22
22
 
23
23
  response_error(enterprise_account.errors)
@@ -13,7 +13,7 @@ module Osso
13
13
  field :identity_provider, Types::IdentityProvider, null: false
14
14
  field :errors, [String], null: false
15
15
 
16
- def resolve(service: nil, enterprise_account_id:, oauth_client_id:)
16
+ def resolve(enterprise_account_id:, oauth_client_id:, service: nil)
17
17
  customer = enterprise_account(enterprise_account_id: enterprise_account_id)
18
18
 
19
19
  identity_provider = customer.identity_providers.build(
@@ -27,12 +27,12 @@ module Osso
27
27
  service: service, enterprise_account_id: enterprise_account_id, oauth_client_id: oauth_client_id
28
28
  })
29
29
  return response_data(identity_provider: identity_provider)
30
- end
30
+ end
31
31
 
32
32
  response_error(identity_provider.errors)
33
33
  end
34
34
 
35
- def domain(enterprise_account_id:, **args)
35
+ def domain(enterprise_account_id:, **_args)
36
36
  enterprise_account(enterprise_account_id: enterprise_account_id)&.domain
37
37
  end
38
38
 
@@ -16,7 +16,7 @@ module Osso
16
16
 
17
17
  if oauth_client.save
18
18
  Osso::Analytics.capture(email: context[:email], event: self.class.name.demodulize, properties: args)
19
- return response_data(oauth_client: oauth_client)
19
+ return response_data(oauth_client: oauth_client)
20
20
  end
21
21
 
22
22
  response_error(oauth_client.errors)
@@ -20,9 +20,8 @@ module Osso
20
20
 
21
21
  if customer.destroy
22
22
  Osso::Analytics.capture(email: context[:email], event: self.class.name.demodulize, properties: args)
23
- return response_data(enterprise_account: nil)
23
+ return response_data(enterprise_account: nil)
24
24
  end
25
-
26
25
 
27
26
  response_error(customer.errors)
28
27
  end
@@ -16,7 +16,7 @@ module Osso
16
16
 
17
17
  if identity_provider.destroy
18
18
  Osso::Analytics.capture(email: context[:email], event: self.class.name.demodulize, properties: { id: id })
19
- return response_data(identity_provider: nil)
19
+ return response_data(identity_provider: nil)
20
20
  end
21
21
 
22
22
  response_error(identity_provider.errors)
@@ -16,7 +16,13 @@ module Osso
16
16
  oauth_client.regenerate_secrets!
17
17
 
18
18
  if oauth_client.save
19
- Osso::Analytics.capture(email: context[:email], event: self.class.name.demodulize, properties: { oauth_client_id: id })
19
+ Osso::Analytics.capture(
20
+ email: context[:email],
21
+ event: self.class.name.demodulize,
22
+ properties: {
23
+ oauth_client_id: id
24
+ }
25
+ )
20
26
  return response_data(oauth_client: oauth_client)
21
27
  end
22
28
 
@@ -16,44 +16,39 @@ module Osso
16
16
 
17
17
  field :oauth_clients, null: true, resolver: Resolvers::OAuthClients
18
18
 
19
- field(
20
- :identity_provider,
21
- Types::IdentityProvider,
22
- null: true,
23
- resolve: ->(_obj, args, _context) { Osso::Models::IdentityProvider.find(args[:id]) },
24
- ) do
19
+ field :admin_users, [Types::AdminUser], null: false
20
+
21
+ field :app_config, Types::AppConfig, null: false
22
+
23
+ field :current_user, Types::AdminUser, null: false
24
+
25
+ field :identity_provider, Types::IdentityProvider, null: true do
25
26
  argument :id, ID, required: true
26
27
  end
27
28
 
28
- field(
29
- :app_config,
30
- Types::AppConfig,
31
- null: false,
32
- resolve: ->(_obj, _args, _context) { Osso::Models::AppConfig.find },
33
- )
34
-
35
- field(
36
- :oauth_client,
37
- Types::OauthClient,
38
- null: true,
39
- resolve: ->(_obj, args, _context) { Osso::Models::OauthClient.find(args[:id]) },
40
- ) do
29
+ field :oauth_client, Types::OauthClient, null: true do
41
30
  argument :id, ID, required: true
42
31
  end
43
32
 
44
- field(
45
- :admin_users,
46
- [Types::AdminUser],
47
- null: false,
48
- resolve: ->(_obj, _args, _context) { Osso::Models::Account.all },
49
- )
33
+ def admin_users
34
+ Osso::Models::Account.all
35
+ end
36
+
37
+ def app_config
38
+ Osso::Models::AppConfig.find
39
+ end
40
+
41
+ def current_user
42
+ context.to_h
43
+ end
50
44
 
51
- field(
52
- :current_user,
53
- Types::AdminUser,
54
- null: false,
55
- resolve: ->(_obj, _args, context) { context.to_h },
56
- )
45
+ def identity_provider(id:)
46
+ Osso::Models::IdentityProvider.find(id)
47
+ end
48
+
49
+ def oauth_client(id:)
50
+ Osso::Models::OauthClient.find(id)
51
+ end
57
52
  end
58
53
  end
59
54
  end
@@ -14,7 +14,6 @@ GraphQL::Relay::BaseConnection.register_connection_implementation(
14
14
  module Osso
15
15
  module GraphQL
16
16
  class Schema < ::GraphQL::Schema
17
- use ::GraphQL::Pagination::Connections
18
17
  query Types::QueryType
19
18
  mutation Types::MutationType
20
19
 
@@ -5,9 +5,9 @@ require 'posthog-ruby'
5
5
  module Osso
6
6
  # Osso::Analytics provides an interface to track product analytics for any provider.
7
7
  # Osso recommends PostHog as an open source solution for your product analytics needs.
8
- # If you want to use another product analytics provider, you can patch the Osso::Analytics
8
+ # If you want to use another product analytics provider, you can patch the Osso::Analytics
9
9
  # class yourself in your parent application. Be sure to implement the public
10
- # .identify and .capture class methods with the required method signatures and require
10
+ # .identify and .capture class methods with the required method signatures and require
11
11
  # your class after requiring Osso.
12
12
  class Analytics
13
13
  class << self
@@ -40,7 +40,7 @@ module Osso
40
40
  @client ||= PostHog::Client.new({
41
41
  api_key: ENV['POSTHOG_API_KEY'],
42
42
  api_host: ENV['POSTHOG_HOST'],
43
- on_error: Proc.new { |status, msg| print msg }
43
+ on_error: proc { |_status, msg| print msg },
44
44
  })
45
45
  end
46
46
 
@@ -52,4 +52,4 @@ module Osso
52
52
  end
53
53
  end
54
54
  end
55
- end
55
+ end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'rack/protection'
4
+
3
5
  module Osso
4
6
  module RouteMap
5
7
  def self.included(klass)
@@ -3,7 +3,7 @@
3
3
  module Osso
4
4
  module Models
5
5
  class Account < ::ActiveRecord::Base
6
- enum status_id: { 1 => :Unverified, 2 => :Verified, 3 => :Closed }
6
+ enum status_id: { Unverified: 1, Verified: 2, Closed: 3 }
7
7
 
8
8
  def context
9
9
  {
@@ -18,7 +18,7 @@ module Osso
18
18
 
19
19
  ENTITY_ID_URI_REQUIRED = [
20
20
  'PING',
21
- ]
21
+ ].freeze
22
22
 
23
23
  def name
24
24
  service.titlecase
@@ -30,7 +30,7 @@ module Osso
30
30
  idp_sso_target_url: sso_url,
31
31
  idp_cert: sso_cert,
32
32
  issuer: sso_issuer,
33
- name_identifier_format: "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"
33
+ name_identifier_format: 'urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress',
34
34
  }
35
35
  end
36
36
 
@@ -56,7 +56,7 @@ module Osso
56
56
 
57
57
  def set_sso_issuer
58
58
  parts = [domain, oauth_client_id]
59
-
59
+
60
60
  parts.unshift('https:/') if ENTITY_ID_URI_REQUIRED.any?(service)
61
61
 
62
62
  self.sso_issuer = parts.join('/')
@@ -9,7 +9,7 @@ module Osso
9
9
  class Admin < Roda
10
10
  DB = Sequel.postgres(extensions: :activerecord_connection)
11
11
  use Rack::Session::Cookie, secret: ENV.fetch('SESSION_SECRET')
12
-
12
+
13
13
  plugin :json
14
14
  plugin :middleware
15
15
  plugin :render, engine: 'erb', views: ENV['RODAUTH_VIEWS'] || DEFAULT_VIEWS_DIR
@@ -64,7 +64,7 @@ module Osso
64
64
  rodauth.
65
65
  session.
66
66
  to_hash.
67
- stringify_keys['account_id']
67
+ stringify_keys['account_id'],
68
68
  ).context.
69
69
  merge({ rodauth: rodauth })
70
70
  end
@@ -14,6 +14,8 @@ module Osso
14
14
  /[0-9a-f]{8}-[0-9a-f]{3,4}-[0-9a-f]{4}-[0-9a-f]{3,4}-[0-9a-f]{12}/.
15
15
  freeze
16
16
 
17
+ use Rack::Protection, allow_if: ->(env) { Rack::Request.new(env)&.path&.end_with?('callback') }
18
+
17
19
  use OmniAuth::Builder do
18
20
  OmniAuth::MultiProvider.register(
19
21
  self,
@@ -22,7 +22,7 @@ module Osso
22
22
 
23
23
  @providers = find_providers
24
24
 
25
- redirect "/auth/saml/#{@providers.first.id}" if @providers.one?
25
+ return erb :saml_login_form if @providers.one?
26
26
 
27
27
  return erb :multiple_providers if @providers.count > 1
28
28
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Osso
4
- VERSION = '0.0.11'
4
+ VERSION = '0.1.0'
5
5
  end
@@ -8,9 +8,11 @@ namespace :osso do
8
8
  desc 'Bootstrap Osso data for a deployment'
9
9
  task :bootstrap do
10
10
  %w[Production Staging Development].each do |environment|
11
+ next if Osso::Models::OauthClient.find_by_name(environment)
12
+
11
13
  Osso::Models::OauthClient.create!(
12
14
  name: environment,
13
- ) unless Osso::Models::OauthClient.find_by_name(environment)
15
+ )
14
16
  end
15
17
 
16
18
  Osso::Models::AppConfig.create
@@ -18,7 +20,7 @@ namespace :osso do
18
20
  admin_email = ENV['ADMIN_EMAIL']
19
21
 
20
22
  if admin_email
21
- admin = Osso::Models::Account.create(
23
+ Osso::Models::Account.create(
22
24
  email: admin_email,
23
25
  status_id: 1,
24
26
  role: 'admin',
@@ -29,10 +31,10 @@ namespace :osso do
29
31
  rodauth = Osso::Admin.rodauth.new(Osso::Admin.new({
30
32
  'HTTP_HOST' => base_uri.host,
31
33
  'SERVER_NAME' => base_uri.to_s,
32
- 'rack.url_scheme' => base_uri.scheme
34
+ 'rack.url_scheme' => base_uri.scheme,
33
35
  }))
34
36
 
35
- account = rodauth.account_from_login(admin_email)
37
+ rodauth.account_from_login(admin_email)
36
38
  rodauth.setup_account_verification
37
39
  end
38
40
  end
@@ -26,12 +26,13 @@ Gem::Specification.new do |spec|
26
26
  spec.add_runtime_dependency 'rack', '>= 2.1.4'
27
27
  spec.add_runtime_dependency 'rack-contrib'
28
28
  spec.add_runtime_dependency 'rack-oauth2'
29
+ spec.add_runtime_dependency 'rack-protection', '~> 2.1.0'
29
30
  spec.add_runtime_dependency 'rake'
30
- spec.add_runtime_dependency 'rodauth', '>= 2.6', '< 2.8'
31
- spec.add_runtime_dependency 'sequel', '>= 5.37', '< 5.41'
31
+ spec.add_runtime_dependency 'rodauth', '~> 2.9'
32
+ spec.add_runtime_dependency 'sequel', '~> 5.40'
32
33
  spec.add_runtime_dependency 'sequel-activerecord_connection', '>= 0.3', '< 2.0'
33
34
  spec.add_runtime_dependency 'sinatra'
34
- spec.add_runtime_dependency 'sinatra-activerecord'
35
+ spec.add_runtime_dependency 'sinatra-activerecord', '>= 2.0.22'
35
36
  spec.add_runtime_dependency 'sinatra-contrib'
36
37
 
37
38
  spec.add_development_dependency 'annotate', '~> 3.1'
@@ -91,7 +91,7 @@ describe Osso::GraphQL::Schema do
91
91
  },
92
92
  }
93
93
  end
94
-
94
+
95
95
  it 'creates an identity provider' do
96
96
  expect { subject }.to change { enterprise_account.identity_providers.count }.by(1)
97
97
  expect(subject.dig('data', 'createIdentityProvider', 'identityProvider', 'domain')).
@@ -66,7 +66,7 @@ describe Osso::Models::IdentityProvider do
66
66
  idp_cert: subject.sso_cert,
67
67
  idp_sso_target_url: subject.sso_url,
68
68
  issuer: subject.sso_issuer,
69
- name_identifier_format: "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"
69
+ name_identifier_format: 'urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress',
70
70
  )
71
71
  end
72
72
  end
@@ -17,26 +17,26 @@ describe Osso::Admin do
17
17
  it 'runs a GraphQL query with a valid jwt' do
18
18
  allow_any_instance_of(described_class.rodauth).to receive(:logged_in?).and_return(true)
19
19
  allow(Osso::Models::Account).to receive(:find).and_return(account)
20
- allow(Osso::GraphQL::Schema).to receive(:execute).and_return({graphql: true})
20
+ allow(Osso::GraphQL::Schema).to receive(:execute).and_return({ graphql: true })
21
21
 
22
22
  header 'Content-Type', 'application/json'
23
- post("/graphql")
23
+ post('/graphql')
24
24
 
25
25
  expect(last_response).to be_ok
26
- expect(last_json_response).to eq({graphql: true})
26
+ expect(last_json_response).to eq({ graphql: true })
27
27
  end
28
28
 
29
29
  it 'returns a 400 for an invalid jwt' do
30
30
  header 'Content-Type', 'application/json'
31
31
  header 'Authorization', 'Bearer bad-token'
32
- post("/graphql")
32
+ post('/graphql')
33
33
 
34
34
  expect(last_response.status).to eq 400
35
35
  end
36
-
36
+
37
37
  it 'returns a 401 without a jwt' do
38
38
  header 'Content-Type', 'application/json'
39
- post("/graphql")
39
+ post('/graphql')
40
40
 
41
41
  expect(last_response.status).to eq 401
42
42
  end
@@ -6,12 +6,13 @@ describe Osso::Auth do
6
6
  before do
7
7
  described_class.set(:views, spec_views)
8
8
  end
9
- describe 'get /auth/saml/:uuid' do
9
+
10
+ describe 'post /auth/saml/:uuid' do
10
11
  describe 'for an Okta SAML provider' do
11
12
  let(:enterprise) { create(:enterprise_with_okta) }
12
13
  let(:okta_provider) { enterprise.identity_providers.first }
13
14
  it 'uses omniauth saml' do
14
- get("/auth/saml/#{okta_provider.id}")
15
+ post("/auth/saml/#{okta_provider.id}")
15
16
 
16
17
  expect(last_response).to be_redirect
17
18
  follow_redirect!
@@ -23,7 +24,7 @@ describe Osso::Auth do
23
24
  let(:enterprise) { create(:enterprise_with_okta) }
24
25
  let(:azure_provider) { enterprise.identity_providers.first }
25
26
  it 'uses omniauth saml' do
26
- get("/auth/saml/#{azure_provider.id}")
27
+ post("/auth/saml/#{azure_provider.id}")
27
28
 
28
29
  expect(last_response).to be_redirect
29
30
  follow_redirect!
@@ -31,6 +32,7 @@ describe Osso::Auth do
31
32
  end
32
33
  end
33
34
  end
35
+
34
36
  describe 'post /auth/saml/:uuid/callback' do
35
37
  describe 'for an Okta SAML provider' do
36
38
  let(:enterprise) { create(:enterprise_with_okta) }
@@ -28,7 +28,7 @@ describe Osso::Oauth do
28
28
  end
29
29
 
30
30
  describe 'for a request without email or domain' do
31
- it 'redirects to /auth/saml/:provider_id' do
31
+ it 'renders the hosted login page' do
32
32
  get(
33
33
  '/oauth/authorize',
34
34
  client_id: client.identifier,
@@ -42,7 +42,7 @@ describe Osso::Oauth do
42
42
  end
43
43
 
44
44
  describe 'for an enterprise domain with one SAML provider' do
45
- it 'redirects to /auth/saml/:provider_id' do
45
+ it 'renders the saml login form' do
46
46
  enterprise = create(:enterprise_with_okta, oauth_client: client)
47
47
 
48
48
  get(
@@ -55,9 +55,7 @@ describe Osso::Oauth do
55
55
 
56
56
  provider_id = enterprise.identity_providers.first.id
57
57
 
58
- expect(last_response).to be_redirect
59
- follow_redirect!
60
- expect(last_request.url).to match("auth/saml/#{provider_id}")
58
+ expect(last_response.body).to match(provider_id)
61
59
  end
62
60
  end
63
61
 
@@ -79,7 +77,7 @@ describe Osso::Oauth do
79
77
  end
80
78
 
81
79
  describe "for an existing user's email address" do
82
- it 'redirects to /auth/saml/:provider_id' do
80
+ it 'renders the saml login form' do
83
81
  enterprise = create(:enterprise_with_okta, oauth_client: client)
84
82
  provider_id = enterprise.identity_providers.first.id
85
83
  user = create(:user, email: "user@#{enterprise.domain}", identity_provider_id: provider_id)
@@ -92,14 +90,12 @@ describe Osso::Oauth do
92
90
  redirect_uri: client.redirect_uri_values.sample,
93
91
  )
94
92
 
95
- expect(last_response).to be_redirect
96
- follow_redirect!
97
- expect(last_request.url).to match("auth/saml/#{provider_id}")
93
+ expect(last_response.body).to match(provider_id)
98
94
  end
99
95
  end
100
96
 
101
97
  describe "for a new user's email address belonging to an enterprise with one SAML provider" do
102
- it 'redirects to /auth/saml/:provider_id' do
98
+ it 'renders the saml login form' do
103
99
  enterprise = create(:enterprise_with_okta, oauth_client: client)
104
100
 
105
101
  get(
@@ -112,9 +108,7 @@ describe Osso::Oauth do
112
108
 
113
109
  provider_id = enterprise.identity_providers.first.id
114
110
 
115
- expect(last_response).to be_redirect
116
- follow_redirect!
117
- expect(last_request.url).to match("auth/saml/#{provider_id}")
111
+ expect(last_response.body).to match(provider_id)
118
112
  end
119
113
  end
120
114
 
@@ -80,5 +80,7 @@ RSpec.configure do |config|
80
80
 
81
81
  OmniAuth.config.test_mode = true
82
82
  OmniAuth.config.logger = Logger.new('/dev/null')
83
+ OmniAuth.config.request_validation_phase = proc {}
84
+
83
85
  WebMock.disable_net_connect!(allow_localhost: true)
84
86
  end
@@ -0,0 +1 @@
1
+ <%= @providers.first.id %>
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.11
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Bauch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-07 00:00:00.000000000 Z
11
+ date: 2021-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -164,6 +164,20 @@ dependencies:
164
164
  - - ">="
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: rack-protection
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: 2.1.0
174
+ type: :runtime
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: 2.1.0
167
181
  - !ruby/object:Gem::Dependency
168
182
  name: rake
169
183
  requirement: !ruby/object:Gem::Requirement
@@ -182,42 +196,30 @@ dependencies:
182
196
  name: rodauth
183
197
  requirement: !ruby/object:Gem::Requirement
184
198
  requirements:
185
- - - ">="
186
- - !ruby/object:Gem::Version
187
- version: '2.6'
188
- - - "<"
199
+ - - "~>"
189
200
  - !ruby/object:Gem::Version
190
- version: '2.8'
201
+ version: '2.9'
191
202
  type: :runtime
192
203
  prerelease: false
193
204
  version_requirements: !ruby/object:Gem::Requirement
194
205
  requirements:
195
- - - ">="
196
- - !ruby/object:Gem::Version
197
- version: '2.6'
198
- - - "<"
206
+ - - "~>"
199
207
  - !ruby/object:Gem::Version
200
- version: '2.8'
208
+ version: '2.9'
201
209
  - !ruby/object:Gem::Dependency
202
210
  name: sequel
203
211
  requirement: !ruby/object:Gem::Requirement
204
212
  requirements:
205
- - - ">="
206
- - !ruby/object:Gem::Version
207
- version: '5.37'
208
- - - "<"
213
+ - - "~>"
209
214
  - !ruby/object:Gem::Version
210
- version: '5.41'
215
+ version: '5.40'
211
216
  type: :runtime
212
217
  prerelease: false
213
218
  version_requirements: !ruby/object:Gem::Requirement
214
219
  requirements:
215
- - - ">="
216
- - !ruby/object:Gem::Version
217
- version: '5.37'
218
- - - "<"
220
+ - - "~>"
219
221
  - !ruby/object:Gem::Version
220
- version: '5.41'
222
+ version: '5.40'
221
223
  - !ruby/object:Gem::Dependency
222
224
  name: sequel-activerecord_connection
223
225
  requirement: !ruby/object:Gem::Requirement
@@ -258,14 +260,14 @@ dependencies:
258
260
  requirements:
259
261
  - - ">="
260
262
  - !ruby/object:Gem::Version
261
- version: '0'
263
+ version: 2.0.22
262
264
  type: :runtime
263
265
  prerelease: false
264
266
  version_requirements: !ruby/object:Gem::Requirement
265
267
  requirements:
266
268
  - - ">="
267
269
  - !ruby/object:Gem::Version
268
- version: '0'
270
+ version: 2.0.22
269
271
  - !ruby/object:Gem::Dependency
270
272
  name: sinatra-contrib
271
273
  requirement: !ruby/object:Gem::Requirement
@@ -486,6 +488,7 @@ files:
486
488
  - spec/support/views/hosted_login.erb
487
489
  - spec/support/views/layout.erb
488
490
  - spec/support/views/multiple_providers.erb
491
+ - spec/support/views/saml_login_form.erb
489
492
  homepage: https://github.com/enterprise-oss/osso-rb
490
493
  licenses:
491
494
  - MIT