omniauth-your-membership-token 1.1.2 → 2.0.0

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
- SHA1:
3
- metadata.gz: a3e72458def061151d23a7bc5c8f70a944fce061
4
- data.tar.gz: ba57375bb44a13a4be124a369118f33689e32e9b
2
+ SHA256:
3
+ metadata.gz: fc2f241654369dea6cfbd8592e0b367865c3f49bc8bc9d485a4af8c1c8ee37d0
4
+ data.tar.gz: 62dbbd185f8c0ff11055910285c1d13aa90142be8eb4d1a32485dd7abfc0c83c
5
5
  SHA512:
6
- metadata.gz: 360b7f3f30aa07ed16286d6a080a21fac074d4c1a7b456a04079fcee63298ead7802abb6297eb1df524e1fc6e3b24b370d6fbc9464ed9210aebd9b6cdc4c59a2
7
- data.tar.gz: d66609aa1877c9c54c1f57a93b54c32e4ae9da204b8e7529c1ad592440ee4b5c8aff1541ad5accfc39825b685e751f5072beb5bf3fc84ed2301de853e55510b5
6
+ metadata.gz: 5944ec29fa4fba8c0e20a3f7968acec86e569d5202caa79067aa5941f2d7037f7407e37524fdc345cd14dcf53343f929a6a7b3851822a5ad58cf554ecb271826
7
+ data.tar.gz: 7c577b390c2d21bc79dd9fd9e33c6a02bf02c7232474c32e0b18f5f6cd7f45c6f533b16aab6302483e8b77378a716f5cbe8597adfbd222bebf003eb6103925d5
data/.gitignore CHANGED
@@ -2,6 +2,7 @@
2
2
  *.rbc
3
3
  .bundle
4
4
  .config
5
+ .ruby-version
5
6
  .yardoc
6
7
  Gemfile.lock
7
8
  InstalledFiles
data/CHANGELOG.md CHANGED
@@ -1,15 +1,20 @@
1
- # Change Log
1
+ # Changelog
2
+
2
3
  All notable changes to this project will be documented in this file.
3
- This project adheres to [Semantic Versioning](http://semver.org/).
4
4
 
5
- ## [Unreleased]
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## (Unreleased)
9
+
10
+ - Nothing yet
11
+
12
+ ## 2.0.0
13
+
14
+ - Breaking Changes
15
+ - Requires [OmniAuth 2](https://github.com/omniauth/omniauth/releases/tag/v2.0.0)
6
16
 
7
- ## [1.1.2]
8
- ### Changed
9
- - In request phase, convert `SocketError` into an OmniAuth failure.
10
- This allows for easier handling in application code.
17
+ ## Older releases
11
18
 
12
- ## [1.1.1] - 2017-02-16
13
- ### Breaking
14
- - Require omniauth 1.3.2+ or 1.4+ (for compatibility with
15
- https://github.com/omniauth/omniauth/commit/71866c5264122e196847a3980c43051446a03e9b)
19
+ PRs welcome, in the [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
20
+ format.
@@ -6,6 +6,13 @@ module OmniAuth
6
6
  class YourMembershipToken
7
7
  include OmniAuth::Strategy
8
8
 
9
+ E_YM_SESSION_ID_BLANK = <<~EOS
10
+ Assertion failed: YourMembership ID blank during callback_phase. This ID
11
+ was stored in the Rack session during the request_phase but has not
12
+ survived to (is no longer present in) the callback_phase.
13
+ EOS
14
+ RACK_SESSION_KEY = 'omniauth_ym_session_id'.freeze
15
+
9
16
  # The UID is going to be the member's API id (member_id)
10
17
  # We'll also store the session ID
11
18
  option :fields, [:member_id, :ym_session]
@@ -13,30 +20,38 @@ module OmniAuth
13
20
 
14
21
  def request_phase
15
22
 
16
- # We're doing this because the callback_url is built from the options.name attribute which is built by downcasing
17
- # the name of the class. This returns an uncapitalized url which Rails will not recognize as the same path as the
18
- # devise controller. This is a forced way to do this and probably has a more elegant solution.
23
+ # We're doing this because the callback_url is built from the
24
+ # options.name attribute which is built by down-casing the name of the
25
+ # class. This returns an un-capitalized url which Rails will not
26
+ # recognize as the same path as the devise controller. This is a forced
27
+ # way to do this and probably has a more elegant solution.
19
28
  options.name = 'yourMembershipToken'
29
+ # Build an Access Token
30
+ session = YourMembership::Session.create
31
+ token_hash = session.createToken(:RetUrl => callback_url)
20
32
 
21
- begin
22
- # Build an Access Token
23
- session = YourMembership::Session.create
24
- token_hash = session.createToken(:RetUrl => callback_url)
25
- # Pass the YourMembership session id to the Callback
26
- request.GET['ym_session'] = session.to_s
27
- # Redirect to token url
28
- redirect token_hash['GoToUrl']
29
- rescue SocketError => e
30
- fail! e.message
31
- end
33
+ # Store the YourMembership session id somewhere it can be retrieved
34
+ # during the callback_phase.
35
+ #
36
+ # In OmniAuth 1, we were able to do:
37
+ #
38
+ # request.params['ym_session'] = session.to_s
39
+ #
40
+ # but this seems no longer possible in OmniAuth 2 (as described in
41
+ # https://github.com/omniauth/omniauth/issues/975). So, the only thing I
42
+ # can think of is to use `env['rack.session']`. If a better solution
43
+ # is discovered, we can revisit this decision.
44
+ env['rack.session'][RACK_SESSION_KEY] = session.to_s
45
+
46
+ # Redirect to token url
47
+ redirect token_hash['GoToUrl']
32
48
  end
33
49
 
50
+ # See discussion in `request_phase` re: the use of `env['rack.session']`.
34
51
  def callback_phase
35
- # create session object
36
-
37
- ym_session_id = request.env['omniauth.params']['ym_session']
38
-
39
- ym_session = YourMembership::Session.new(ym_session_id, 100)
52
+ ym_session_id = env['rack.session'][RACK_SESSION_KEY]
53
+ fail!(E_YM_SESSION_ID_BLANK) if ym_session_id.blank?
54
+ ym_session = YourMembership::Session.new(ym_session_id, 100)
40
55
 
41
56
  begin
42
57
  fail! 'Failed To Log In' unless ym_session.authenticated?
@@ -1,5 +1,11 @@
1
1
  module OmniAuth
2
2
  module YourMembershipToken
3
- VERSION = "1.1.2"
3
+ def self.gem_version
4
+ Gem::Version.new('2.0.0')
5
+ end
6
+
7
+ # @deprecated But will never be removed. Use `gem_version` instead, which
8
+ # provides a `Gem::Version` object that is easier to work with.
9
+ VERSION = gem_version.to_s
4
10
  end
5
11
  end
@@ -5,7 +5,7 @@ require 'omniauth/your_membership_token/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "omniauth-your-membership-token"
8
- spec.version = OmniAuth::YourMembershipToken::VERSION
8
+ spec.version = OmniAuth::YourMembershipToken.gem_version.to_s
9
9
  spec.authors = ["Nate Flood"]
10
10
  spec.email = ["nflood@echonet.org"]
11
11
  spec.summary = %q{Omniauth Strategy For Authenticating To YourMembership}
@@ -18,9 +18,9 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "omniauth", [">= 1.3.2", "< 2"]
21
+ spec.add_dependency "omniauth", "~> 2"
22
22
  spec.add_dependency "your_membership", "~> 1.1"
23
23
 
24
- spec.add_development_dependency "bundler", "~> 1.6"
24
+ spec.add_development_dependency "bundler", "~> 2"
25
25
  spec.add_development_dependency "rake"
26
26
  end
metadata CHANGED
@@ -1,33 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-your-membership-token
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nate Flood
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-01 00:00:00.000000000 Z
11
+ date: 2021-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: 1.3.2
20
- - - "<"
17
+ - - "~>"
21
18
  - !ruby/object:Gem::Version
22
19
  version: '2'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: 1.3.2
30
- - - "<"
24
+ - - "~>"
31
25
  - !ruby/object:Gem::Version
32
26
  version: '2'
33
27
  - !ruby/object:Gem::Dependency
@@ -50,14 +44,14 @@ dependencies:
50
44
  requirements:
51
45
  - - "~>"
52
46
  - !ruby/object:Gem::Version
53
- version: '1.6'
47
+ version: '2'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
51
  requirements:
58
52
  - - "~>"
59
53
  - !ruby/object:Gem::Version
60
- version: '1.6'
54
+ version: '2'
61
55
  - !ruby/object:Gem::Dependency
62
56
  name: rake
63
57
  requirement: !ruby/object:Gem::Requirement
@@ -109,8 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
103
  - !ruby/object:Gem::Version
110
104
  version: '0'
111
105
  requirements: []
112
- rubyforge_project:
113
- rubygems_version: 2.6.10
106
+ rubygems_version: 3.0.3
114
107
  signing_key:
115
108
  specification_version: 4
116
109
  summary: Omniauth Strategy For Authenticating To YourMembership