omniauth-osso 0.1.3 → 0.1.8.pre

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 328ecac5ccc2447ce90e9920e6031edb78e014839a4d338a0ed2cced64250fe3
4
- data.tar.gz: dd1291453982cdefeb3283560084675586732777ebd155cf0ddc24c74e73d240
3
+ metadata.gz: efe9a8d36940d227d545a3cf506bd1d381b861eae392eed1b3eec0d02e36d0e5
4
+ data.tar.gz: fd73cbce13680ef1da6e4cc2a2f0556557521d4ffe2e6b970d85172dabe84226
5
5
  SHA512:
6
- metadata.gz: 4db39607891bf68cfb40ea72dfbd0f3178dd0feccf66ff3ef5dfbe8739b3488bb49b1f469204ba9da841b1486c34a5ca77bccbddd4cd005651820345b5907634
7
- data.tar.gz: ae0b069373f8e6ca7fc4a964055433774f2a0af448057f3bf8b3a5ba0b746438a1a4b9f576a2c4ce678848c99792503f265fb4468a905208b9a3c7edba3e6133
6
+ metadata.gz: 0b0de0abbf87c876d7604d72838b68ea659158449bb9a02ffb588809dabd59d5c2f17c78063404f2c9472a6922a435012414caff00bf77473f8e1a96019c3127
7
+ data.tar.gz: deaa1f5a322dd3ec21b5cb7c839de4aa161fb0bd2ebedde8f75ecd1138f22234a394896f496916a74149063098dd4c86ce683e70f81c75787560e94e60b23aca
@@ -0,0 +1,9 @@
1
+ #!/bin/bash
2
+
3
+ set -eu
4
+
5
+ echo '--- RBENV'
6
+
7
+ export PATH="$HOME/.rbenv/bin:$PATH"
8
+
9
+ eval "$(rbenv init -)"
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+
3
+ set -eu
4
+
5
+ export PATH="$HOME/.rbenv/bin:$PATH"
6
+
7
+ eval "$(rbenv init -)"
@@ -0,0 +1,17 @@
1
+ steps:
2
+ - name: ":rspec:"
3
+ commands:
4
+ - bundle install
5
+ - bundle exec rspec
6
+
7
+ - name: "rubocop :male-police-officer:"
8
+ commands:
9
+ - bundle install
10
+ - bundle exec rubocop
11
+
12
+ - block: ":rubygems: Publish :red_button:"
13
+ if: build.tag != null
14
+
15
+ - name: "Push :rubygems:"
16
+ commands: "./bin/publish"
17
+ if: build.tag != null
@@ -0,0 +1,8 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: "/"
5
+ schedule:
6
+ interval: daily
7
+ labels:
8
+ - "dependencies"
@@ -0,0 +1,19 @@
1
+ name: auto-merge
2
+
3
+ on:
4
+ pull_request:
5
+
6
+ jobs:
7
+ auto-approve:
8
+ runs-on: ubuntu-latest
9
+ steps:
10
+ - uses: actions/checkout@v2
11
+ - uses: ahmadnassri/action-dependabot-auto-merge@v2
12
+ with:
13
+ target: minor
14
+ github-token: ${{ secrets.TOKEN }}
15
+ - uses: hmarr/auto-approve-action@v2.0.0
16
+ if: github.actor == 'dependabot[bot]'
17
+ with:
18
+ github-token: "${{ secrets.TOKEN }}"
19
+
@@ -1,3 +1,6 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.4
3
+
1
4
  Layout/LineLength:
2
5
  Max: 120
3
6
 
@@ -0,0 +1,130 @@
1
+
2
+ # Contributor Covenant Code of Conduct
3
+
4
+ ## Our Pledge
5
+
6
+ We as members, contributors, and leaders pledge to make participation in our
7
+ community a harassment-free experience for everyone, regardless of age, body
8
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
9
+ identity and expression, level of experience, education, socio-economic status,
10
+ nationality, personal appearance, race, religion, or sexual identity
11
+ and orientation.
12
+
13
+ We pledge to act and interact in ways that contribute to an open, welcoming,
14
+ diverse, inclusive, and healthy community.
15
+
16
+ ## Our Standards
17
+
18
+ Examples of behavior that contributes to a positive environment for our
19
+ community include:
20
+
21
+ * Demonstrating empathy and kindness toward other people
22
+ * Being respectful of differing opinions, viewpoints, and experiences
23
+ * Giving and gracefully accepting constructive feedback
24
+ * Accepting responsibility and apologizing to those affected by our mistakes,
25
+ and learning from the experience
26
+ * Focusing on what is best not just for us as individuals, but for the
27
+ overall community
28
+
29
+ Examples of unacceptable behavior include:
30
+
31
+ * The use of sexualized language or imagery, and sexual attention or
32
+ advances of any kind
33
+ * Trolling, insulting or derogatory comments, and personal or political attacks
34
+ * Public or private harassment
35
+ * Publishing others' private information, such as a physical or email
36
+ address, without their explicit permission
37
+ * Other conduct which could reasonably be considered inappropriate in a
38
+ professional setting
39
+
40
+ ## Enforcement Responsibilities
41
+
42
+ Community leaders are responsible for clarifying and enforcing our standards of
43
+ acceptable behavior and will take appropriate and fair corrective action in
44
+ response to any behavior that they deem inappropriate, threatening, offensive,
45
+ or harmful.
46
+
47
+ Community leaders have the right and responsibility to remove, edit, or reject
48
+ comments, commits, code, wiki edits, issues, and other contributions that are
49
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
50
+ decisions when appropriate.
51
+
52
+ ## Scope
53
+
54
+ This Code of Conduct applies within all community spaces, and also applies when
55
+ an individual is officially representing the community in public spaces.
56
+ Examples of representing our community include using an official e-mail address,
57
+ posting via an official social media account, or acting as an appointed
58
+ representative at an online or offline event.
59
+
60
+ ## Enforcement
61
+
62
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
63
+ reported to the community leaders responsible for enforcement at
64
+ sbauch@gmail.com.
65
+ All complaints will be reviewed and investigated promptly and fairly.
66
+
67
+ All community leaders are obligated to respect the privacy and security of the
68
+ reporter of any incident.
69
+
70
+ ## Enforcement Guidelines
71
+
72
+ Community leaders will follow these Community Impact Guidelines in determining
73
+ the consequences for any action they deem in violation of this Code of Conduct:
74
+
75
+ ### 1. Correction
76
+
77
+ **Community Impact**: Use of inappropriate language or other behavior deemed
78
+ unprofessional or unwelcome in the community.
79
+
80
+ **Consequence**: A private, written warning from community leaders, providing
81
+ clarity around the nature of the violation and an explanation of why the
82
+ behavior was inappropriate. A public apology may be requested.
83
+
84
+ ### 2. Warning
85
+
86
+ **Community Impact**: A violation through a single incident or series
87
+ of actions.
88
+
89
+ **Consequence**: A warning with consequences for continued behavior. No
90
+ interaction with the people involved, including unsolicited interaction with
91
+ those enforcing the Code of Conduct, for a specified period of time. This
92
+ includes avoiding interactions in community spaces as well as external channels
93
+ like social media. Violating these terms may lead to a temporary or
94
+ permanent ban.
95
+
96
+ ### 3. Temporary Ban
97
+
98
+ **Community Impact**: A serious violation of community standards, including
99
+ sustained inappropriate behavior.
100
+
101
+ **Consequence**: A temporary ban from any sort of interaction or public
102
+ communication with the community for a specified period of time. No public or
103
+ private interaction with the people involved, including unsolicited interaction
104
+ with those enforcing the Code of Conduct, is allowed during this period.
105
+ Violating these terms may lead to a permanent ban.
106
+
107
+ ### 4. Permanent Ban
108
+
109
+ **Community Impact**: Demonstrating a pattern of violation of community
110
+ standards, including sustained inappropriate behavior, harassment of an
111
+ individual, or aggression toward or disparagement of classes of individuals.
112
+
113
+ **Consequence**: A permanent ban from any sort of public interaction within
114
+ the community.
115
+
116
+ ## Attribution
117
+
118
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
119
+ version 2.0, available at
120
+ https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
121
+
122
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct
123
+ enforcement ladder](https://github.com/mozilla/diversity).
124
+
125
+ [homepage]: https://www.contributor-covenant.org
126
+
127
+ For answers to common questions about this code of conduct, see the FAQ at
128
+ https://www.contributor-covenant.org/faq. Translations are available at
129
+ https://www.contributor-covenant.org/translations.
130
+
data/Gemfile CHANGED
@@ -7,9 +7,9 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
7
7
  group :test do
8
8
  gem 'pry'
9
9
  gem 'rack-test'
10
- gem 'rspec', '~> 3.2'
10
+ gem 'rspec', '~> 3.10'
11
11
  gem 'rubocop'
12
- gem 'webmock', '~> 3.0'
12
+ gem 'webmock', '~> 3.10'
13
13
  end
14
14
 
15
15
  gemspec
@@ -1,27 +1,26 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- omniauth-osso (0.1.2)
5
- omniauth-oauth2 (~> 1.6.0)
4
+ omniauth-osso (0.1.7)
5
+ omniauth-oauth2 (>= 1.6, < 1.8)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
10
  addressable (2.7.0)
11
11
  public_suffix (>= 2.0.2, < 5.0)
12
- ast (2.4.0)
13
- coderay (1.1.2)
14
- crack (0.4.3)
15
- safe_yaml (~> 1.0.0)
16
- diff-lcs (1.3)
17
- faraday (1.0.1)
12
+ ast (2.4.1)
13
+ coderay (1.1.3)
14
+ crack (0.4.4)
15
+ diff-lcs (1.4.4)
16
+ faraday (1.1.0)
18
17
  multipart-post (>= 1.2, < 3)
18
+ ruby2_keywords
19
19
  hashdiff (1.0.1)
20
20
  hashie (4.1.0)
21
- jaro_winkler (1.5.4)
22
- jwt (2.2.1)
21
+ jwt (2.2.2)
23
22
  method_source (1.0.0)
24
- multi_json (1.14.1)
23
+ multi_json (1.15.0)
25
24
  multi_xml (0.6.0)
26
25
  multipart-post (2.1.1)
27
26
  oauth2 (1.4.4)
@@ -33,46 +32,50 @@ GEM
33
32
  omniauth (1.9.1)
34
33
  hashie (>= 3.4.6)
35
34
  rack (>= 1.6.2, < 3)
36
- omniauth-oauth2 (1.6.0)
37
- oauth2 (~> 1.1)
35
+ omniauth-oauth2 (1.7.0)
36
+ oauth2 (~> 1.4)
38
37
  omniauth (~> 1.9)
39
- parallel (1.19.1)
40
- parser (2.7.1.0)
41
- ast (~> 2.4.0)
42
- pry (0.13.0)
38
+ parallel (1.20.1)
39
+ parser (2.7.2.0)
40
+ ast (~> 2.4.1)
41
+ pry (0.13.1)
43
42
  coderay (~> 1.1)
44
43
  method_source (~> 1.0)
45
- public_suffix (4.0.4)
46
- rack (2.2.2)
44
+ public_suffix (4.0.6)
45
+ rack (2.2.3)
47
46
  rack-test (1.1.0)
48
47
  rack (>= 1.0, < 3)
49
48
  rainbow (3.0.0)
49
+ regexp_parser (2.0.0)
50
50
  rexml (3.2.4)
51
- rspec (3.8.0)
52
- rspec-core (~> 3.8.0)
53
- rspec-expectations (~> 3.8.0)
54
- rspec-mocks (~> 3.8.0)
55
- rspec-core (3.8.2)
56
- rspec-support (~> 3.8.0)
57
- rspec-expectations (3.8.4)
51
+ rspec (3.10.0)
52
+ rspec-core (~> 3.10.0)
53
+ rspec-expectations (~> 3.10.0)
54
+ rspec-mocks (~> 3.10.0)
55
+ rspec-core (3.10.0)
56
+ rspec-support (~> 3.10.0)
57
+ rspec-expectations (3.10.0)
58
58
  diff-lcs (>= 1.2.0, < 2.0)
59
- rspec-support (~> 3.8.0)
60
- rspec-mocks (3.8.1)
59
+ rspec-support (~> 3.10.0)
60
+ rspec-mocks (3.10.0)
61
61
  diff-lcs (>= 1.2.0, < 2.0)
62
- rspec-support (~> 3.8.0)
63
- rspec-support (3.8.2)
64
- rubocop (0.81.0)
65
- jaro_winkler (~> 1.5.1)
62
+ rspec-support (~> 3.10.0)
63
+ rspec-support (3.10.0)
64
+ rubocop (1.6.1)
66
65
  parallel (~> 1.10)
67
- parser (>= 2.7.0.1)
66
+ parser (>= 2.7.1.5)
68
67
  rainbow (>= 2.2.2, < 4.0)
68
+ regexp_parser (>= 1.8, < 3.0)
69
69
  rexml
70
+ rubocop-ast (>= 1.2.0, < 2.0)
70
71
  ruby-progressbar (~> 1.7)
71
72
  unicode-display_width (>= 1.4.0, < 2.0)
73
+ rubocop-ast (1.3.0)
74
+ parser (>= 2.7.1.5)
72
75
  ruby-progressbar (1.10.1)
73
- safe_yaml (1.0.5)
76
+ ruby2_keywords (0.0.2)
74
77
  unicode-display_width (1.7.0)
75
- webmock (3.8.3)
78
+ webmock (3.10.0)
76
79
  addressable (>= 2.3.6)
77
80
  crack (>= 0.3.2)
78
81
  hashdiff (>= 0.4.0, < 2.0.0)
@@ -85,9 +88,9 @@ DEPENDENCIES
85
88
  omniauth-osso!
86
89
  pry
87
90
  rack-test
88
- rspec (~> 3.2)
91
+ rspec (~> 3.10)
89
92
  rubocop
90
- webmock (~> 3.0)
93
+ webmock (~> 3.10)
91
94
 
92
95
  BUNDLED WITH
93
96
  2.1.4
data/LICENSE ADDED
@@ -0,0 +1,109 @@
1
+ Business Source License 1.1
2
+
3
+ Parameters
4
+
5
+ Licensor: EnterpriseOSS, Inc.
6
+ Licensed Work: omniauth-osso
7
+ The Licensed Work is (c) 2020 EnterpriseOSS, Inc.
8
+
9
+ Additional Use Grant: You and your Authorized Users may make use of the
10
+ Licensed Work for your internal business purposes,
11
+ provided that you do not (i) rent, lease, copy, transfer,
12
+ resell, sublicense, lease, time-share, or otherwise provide
13
+ access to the Licensed Work to a third party (except
14
+ Authorized Users) or (ii) incorporate the Licensed Work
15
+ (or any portion of such) with, or use it with or to provide,
16
+ any site, product, or service, other than on sites/applications
17
+ owned and operated by you.
18
+
19
+ An “Authorized User” is defined as an individual person
20
+ (e.g. your employee, contractor, agent) who is registered and
21
+ permitted by you to use the Licensed Work subject to these
22
+ restrictions.
23
+
24
+ Change Date: 2025-10-01
25
+
26
+ Change License: Apache License, Version 2.0
27
+
28
+ For information about alternative licensing arrangements for the Software,
29
+ contact: hello@enterpriseoss.dev
30
+
31
+ Notice
32
+
33
+ The Business Source License (this document, or the "License") is not an Open
34
+ Source license. However, the Licensed Work will eventually be made available
35
+ under an Open Source License, as stated in this License.
36
+
37
+ License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved.
38
+ "Business Source License" is a trademark of MariaDB Corporation Ab.
39
+
40
+ -----------------------------------------------------------------------------
41
+
42
+ Business Source License 1.1
43
+
44
+ Terms
45
+
46
+ The Licensor hereby grants you the right to copy, modify, create derivative
47
+ works, redistribute, and make non-production use of the Licensed Work. The
48
+ Licensor may make an Additional Use Grant, above, permitting limited
49
+ production use.
50
+
51
+ Effective on the Change Date, or the fourth anniversary of the first publicly
52
+ available distribution of a specific version of the Licensed Work under this
53
+ License, whichever comes first, the Licensor hereby grants you rights under
54
+ the terms of the Change License, and the rights granted in the paragraph
55
+ above terminate.
56
+
57
+ If your use of the Licensed Work does not comply with the requirements
58
+ currently in effect as described in this License, you must purchase a
59
+ commercial license from the Licensor, its affiliated entities, or authorized
60
+ resellers, or you must refrain from using the Licensed Work.
61
+
62
+ All copies of the original and modified Licensed Work, and derivative works
63
+ of the Licensed Work, are subject to this License. This License applies
64
+ separately for each version of the Licensed Work and the Change Date may vary
65
+ for each version of the Licensed Work released by Licensor.
66
+
67
+ You must conspicuously display this License on each original or modified copy
68
+ of the Licensed Work. If you receive the Licensed Work in original or
69
+ modified form from a third party, the terms and conditions set forth in this
70
+ License apply to your use of that work.
71
+
72
+ Any use of the Licensed Work in violation of this License will automatically
73
+ terminate your rights under this License for the current and all other
74
+ versions of the Licensed Work.
75
+
76
+ This License does not grant you any right in any trademark or logo of
77
+ Licensor or its affiliates (provided that you may use a trademark or logo of
78
+ Licensor as expressly required by this License).
79
+
80
+ TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
81
+ AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
82
+ EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
83
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
84
+ TITLE.
85
+
86
+ MariaDB hereby grants you permission to use this License’s text to license
87
+ your works, and to refer to it using the trademark "Business Source License",
88
+ as long as you comply with the Covenants of Licensor below.
89
+
90
+ Covenants of Licensor
91
+
92
+ In consideration of the right to use this License’s text and the "Business
93
+ Source License" name and trademark, Licensor covenants to MariaDB, and to all
94
+ other recipients of the licensed work to be provided by Licensor:
95
+
96
+ 1. To specify as the Change License the GPL Version 2.0 or any later version,
97
+ or a license that is compatible with GPL Version 2.0 or a later version,
98
+ where "compatible" means that software provided under the Change License can
99
+ be included in a program with software provided under GPL Version 2.0 or a
100
+ later version. Licensor may specify additional Change Licenses without
101
+ limitation.
102
+
103
+ 2. To either: (a) specify an additional grant of rights to use that does not
104
+ impose any additional restriction on the right granted in this License, as
105
+ the Additional Use Grant; or (b) insert the text "None".
106
+
107
+ 3. To specify a Change Date.
108
+
109
+ 4. Not to modify this License in any other way.
@@ -0,0 +1,18 @@
1
+ #!/bin/sh
2
+ # Scriptacular - gemify.sh
3
+ # Create a Ruby gem and push it to rubygems.org
4
+ # Copyright 2013 Christopher Simpkins
5
+ # MIT License
6
+
7
+ GEM_NAME="omniauth-osso"
8
+ GEMSPEC_SUFFIX=".gemspec"
9
+
10
+ # run the gem build and parse for the gem release filename
11
+ GEM_BUILD_NAME=$(gem build "$GEM_NAME$GEMSPEC_SUFFIX" | awk '/File/ {print $2}' -)
12
+
13
+ if [ -z "$GEM_BUILD_NAME" ]; then
14
+ echo "The gem build failed." >&2
15
+ exit 1
16
+ fi
17
+
18
+ gem push $GEM_BUILD_NAME
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OmniAuth
4
4
  module Osso
5
- VERSION = '0.1.3'
5
+ VERSION = '0.1.8.pre'
6
6
  end
7
7
  end
@@ -6,17 +6,12 @@ module OmniAuth
6
6
  module Strategies
7
7
  # The main source for the Osso Omniauth Strategy
8
8
  class Osso < OmniAuth::Strategies::OAuth2
9
- include OmniAuth::Strategy
9
+ attr_accessor :env
10
10
 
11
11
  option :name, 'osso'
12
12
  option :client_id, nil
13
13
  option :client_secret, nil
14
- option :client_options, { site: ENV['OSSO_BASE_URL'] }
15
- option :authorize_params, { state: SecureRandom.hex(24) }
16
14
  option :authorize_options, %i[state]
17
- option :token_params, {}
18
- option :token_options, []
19
- option :auth_token_params, {}
20
15
  option :provider_ignores_state, false
21
16
 
22
17
  def request_phase
@@ -24,25 +19,16 @@ module OmniAuth
24
19
  client
25
20
  .auth_code
26
21
  .authorize_url(
27
- {
28
- redirect_uri: callback_url,
29
- domain: request_domain
30
- }.merge(authorize_params)
22
+ request_params
23
+ .merge(authorize_params)
31
24
  )
32
25
  )
33
26
  end
34
27
 
35
- def authorize_params
36
- params = options.authorize_params.merge(options_for('authorize')) || {}
37
-
38
- if OmniAuth.config.test_mode
39
- @env ||= {}
40
- @env['rack.session'] ||= {}
41
- end
42
-
43
- session['omniauth.state'] = params[:state]
44
-
45
- params
28
+ def request_params
29
+ {
30
+ redirect_uri: callback_url
31
+ }.merge(user_param)
46
32
  end
47
33
 
48
34
  uid { raw_info['id'] }
@@ -55,7 +41,8 @@ module OmniAuth
55
41
 
56
42
  extra do
57
43
  {
58
- idp: raw_info['idp']
44
+ idp: raw_info['idp'],
45
+ requested: raw_info['requested']
59
46
  }
60
47
  end
61
48
 
@@ -63,20 +50,48 @@ module OmniAuth
63
50
  @raw_info ||= access_token.get("/oauth/me?access_token=#{access_token.token}").parsed
64
51
  end
65
52
 
66
- protected
53
+ def callback_phase # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
54
+ error = request.params['error_reason'] || request.params['error']
67
55
 
68
- def callback_url
69
- ENV['OSSO_REDIRECT_URI'] || super
56
+ if error
57
+ fail!(
58
+ error,
59
+ CallbackError.new(
60
+ request.params['error'], request.params['error_description'] ||
61
+ request.params['error_reason'], request.params['error_uri']
62
+ )
63
+ )
64
+ elsif request.params['state'] != 'IDP_INITIATED' &&
65
+ request.params['state'] != session.delete('omniauth.state')
66
+
67
+ fail!(:csrf_detected, CallbackError.new(:csrf_detected, 'CSRF detected'))
68
+ else
69
+ self.access_token = build_access_token
70
+ self.access_token = access_token.refresh! if access_token.expired?
71
+ env['omniauth.auth'] = auth_hash
72
+ call_app!
73
+ end
74
+ rescue ::OAuth2::Error, CallbackError => e
75
+ fail!(:invalid_credentials, e)
76
+ rescue ::Timeout::Error, ::Errno::ETIMEDOUT => e
77
+ fail!(:timeout, e)
78
+ rescue ::SocketError => e
79
+ fail!(:failed_to_connect, e)
70
80
  end
71
81
 
72
- def request_domain
73
- return @request_domain if defined?(@request_domain)
82
+ protected
74
83
 
75
- @request_domain = request.params['domain'] || request.params['email'].split('@')[1]
84
+ def callback_url
85
+ full_host + callback_path
86
+ end
76
87
 
77
- raise StandardError if @request_domain.nil?
88
+ def user_param
89
+ return @user_param if defined?(@user_param)
78
90
 
79
- @request_domain
91
+ @user_param = {
92
+ domain: request.params['domain'],
93
+ email: request.params['email']
94
+ }.compact
80
95
  end
81
96
  end
82
97
  end
@@ -8,9 +8,9 @@ Gem::Specification.new do |gem|
8
8
  gem.description = 'An OAuth 2.0 OmniAuth provider for Osso SSO.'
9
9
  gem.summary = gem.description
10
10
  gem.homepage = 'https://github.com/enterprise-oss/omniauth-osso'
11
- gem.license = 'MIT'
11
+ gem.license = 'BSL'
12
12
 
13
- gem.add_dependency 'omniauth-oauth2', '~> 1.6.0'
13
+ gem.add_dependency 'omniauth-oauth2', '>= 1.6', '< 1.8'
14
14
  gem.add_development_dependency 'bundler', '~> 2.1'
15
15
 
16
16
  gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
@@ -19,4 +19,5 @@ Gem::Specification.new do |gem|
19
19
  gem.name = 'omniauth-osso'
20
20
  gem.require_paths = ['lib']
21
21
  gem.version = OmniAuth::Osso::VERSION
22
+ gem.required_ruby_version = '~> 2.4'
22
23
  end
@@ -46,28 +46,88 @@ describe OmniAuth::Strategies::Osso do
46
46
  end
47
47
 
48
48
  it 'includes custom state in the authorize params' do
49
- instance = subject.new('abc', 'def', authorize_params: { state: 'qux' })
49
+ instance = subject.new('abc', 'def', state: 'qux')
50
50
  expect(instance.authorize_params.keys).to include('state')
51
51
  expect(instance.session['omniauth.state']).to eq('qux')
52
52
  end
53
53
  end
54
54
 
55
- describe '#token_params' do
55
+ describe '#request_params' do
56
+ let(:url) { 'https://example.com/auth/osso' }
56
57
  subject { fresh_strategy }
57
58
 
58
- it 'includes any authorize params passed in the :authorize_params option' do
59
- instance = subject.new('abc', 'def', token_params: { foo: 'bar', baz: 'zip' })
60
- expect(instance.token_params).to eq('foo' => 'bar', 'baz' => 'zip')
59
+ before do
60
+ OmniAuth.config.full_host = 'https://osso-base.com'
61
61
  end
62
62
 
63
- it 'includes top-level options that are marked as :authorize_options' do
64
- instance = subject.new('abc', 'def', token_options: %i[scope foo], scope: 'bar', foo: 'baz')
65
- expect(instance.token_params).to eq('scope' => 'bar', 'foo' => 'baz')
63
+ it 'includes domain passed as a request param' do
64
+ instance = subject.new('abc', 'def')
65
+ allow(instance).to receive(:request) do
66
+ double('Request', params: { 'domain' => 'example.com' }, scheme: 'https', url: url)
67
+ end
68
+
69
+ expect(instance.request_params[:domain]).to eq('example.com')
70
+ end
71
+
72
+ it 'includes email when an email address is passed as an authorize option' do
73
+ instance = subject.new('abc', 'def')
74
+
75
+ allow(instance).to receive(:request) do
76
+ double('Request', params: { 'email' => 'user@example.com' }, scheme: 'https', url: url)
77
+ end
78
+
79
+ expect(instance.request_params[:email]).to eq('user@example.com')
66
80
  end
67
81
  end
68
82
 
83
+ # We need to get a little hacky with testing the callback phase
84
+ # in order to cover IDP initiated flows. When a user opens
85
+ # an SP app by clicking a tile on their IDP, then the OAuth flow
86
+ # skips the first leg, and we have to ignore CSRF protection.
87
+ # Osso will send `state=IDP_INITIATED_FLOW` when this is the case,
88
+ # and here we ensure that our strategy completes the callback phase
89
+ # with this state param.
90
+
69
91
  describe '#callback_phase' do
70
92
  subject { fresh_strategy }
93
+ let(:url) { 'https://example.com/auth/osso/callback' }
94
+ let(:instance) { subject.new(app, 'abc', 'def') }
95
+
96
+ before do
97
+ OmniAuth.config.test_mode = true
98
+ ENV['OSSO_BASE_URL'] = 'https://osso-base.com'
99
+ allow(instance).to receive(:auth_hash) { auth_hash }
100
+ instance.env = {}
101
+ end
102
+
103
+ let :auth_hash do
104
+ {
105
+ provider: 'osso',
106
+ uid: 'uuid',
107
+ info: {
108
+ email: 'user@enterprise.com',
109
+ name: 'user@enterprise.com'
110
+ },
111
+ credentials: {
112
+ },
113
+ extra: {
114
+ }
115
+ }
116
+ end
117
+
118
+ it 'allows callbacks with IDP_INITIATED state param' do
119
+ allow(instance).to receive(:request) do
120
+ double('Request', params: { 'state' => 'IDP_INITIATED' }, scheme: 'https', url: url)
121
+ end
122
+
123
+ allow(instance).to receive(:build_access_token) do
124
+ double('AccessToken', expired?: false, token: 'token')
125
+ end
126
+
127
+ expect(instance).to_not receive(:fail!)
128
+ instance.callback_phase
129
+ end
130
+
71
131
  it 'calls fail with the client error received' do
72
132
  instance = subject.new('abc', 'def')
73
133
  allow(instance).to receive(:request) do
@@ -38,8 +38,5 @@ end
38
38
 
39
39
  RSpec.configure do |config|
40
40
  config.include RSpecMixin
41
-
42
- # OmniAuth.config.test_mode = true
43
- # OmniAuth.config.logger = Logger.new('/dev/null')
44
41
  WebMock.disable_net_connect!(allow_localhost: true)
45
42
  end
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-osso
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.8.pre
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-05-01 00:00:00.000000000 Z
11
+ date: 2020-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth-oauth2
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ - - "<"
18
21
  - !ruby/object:Gem::Version
19
- version: 1.6.0
22
+ version: '1.8'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
26
- version: 1.6.0
29
+ version: '1.6'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '1.8'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: bundler
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -43,18 +49,27 @@ email:
43
49
  - sbauch@gmail.com
44
50
  executables:
45
51
  - console
52
+ - publish
46
53
  - setup
47
54
  extensions: []
48
55
  extra_rdoc_files: []
49
56
  files:
57
+ - ".buildkite/hooks/environment"
58
+ - ".buildkite/hooks/pre-command"
59
+ - ".buildkite/pipeline.yml"
60
+ - ".github/dependabot.yml"
61
+ - ".github/workflows/automerge.yml"
50
62
  - ".gitignore"
51
63
  - ".rspec"
52
64
  - ".rubocop.yml"
65
+ - CODE_OF_CONDUCT.md
53
66
  - Gemfile
54
67
  - Gemfile.lock
68
+ - LICENSE
55
69
  - README.md
56
70
  - Rakefile
57
71
  - bin/console
72
+ - bin/publish
58
73
  - bin/setup
59
74
  - lib/omniauth-osso.rb
60
75
  - lib/omniauth-osso/version.rb
@@ -64,7 +79,7 @@ files:
64
79
  - spec/spec_helper.rb
65
80
  homepage: https://github.com/enterprise-oss/omniauth-osso
66
81
  licenses:
67
- - MIT
82
+ - BSL
68
83
  metadata: {}
69
84
  post_install_message:
70
85
  rdoc_options: []
@@ -72,20 +87,17 @@ require_paths:
72
87
  - lib
73
88
  required_ruby_version: !ruby/object:Gem::Requirement
74
89
  requirements:
75
- - - ">="
90
+ - - "~>"
76
91
  - !ruby/object:Gem::Version
77
- version: '0'
92
+ version: '2.4'
78
93
  required_rubygems_version: !ruby/object:Gem::Requirement
79
94
  requirements:
80
- - - ">="
95
+ - - ">"
81
96
  - !ruby/object:Gem::Version
82
- version: '0'
97
+ version: 1.3.1
83
98
  requirements: []
84
- rubyforge_project:
85
- rubygems_version: 2.7.6.2
99
+ rubygems_version: 3.0.3
86
100
  signing_key:
87
101
  specification_version: 4
88
102
  summary: An OAuth 2.0 OmniAuth provider for Osso SSO.
89
- test_files:
90
- - spec/omniauth/strategies/osso_spec.rb
91
- - spec/spec_helper.rb
103
+ test_files: []