omniauth-token 1.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 50350c6c033e379177ec9ef7ebb2e8e9645738bdce389cc0f309ed55210339af
4
+ data.tar.gz: ff615c5b241c69768e52ebaedd8b1f36b7d3564840fb255386b001bb45bb6525
5
+ SHA512:
6
+ metadata.gz: f70ab253ffc8d1f31416c9b64b44a4d8ea6f892d546a8013d076be74dc08441d426cbb628fefa41c9dcba66902e5cacffedccca4795db8906b27700786cd4155
7
+ data.tar.gz: 58b07b66a97befb3f5cc7be64425a7dd8245d71910066d7d0cf163c0362975c4ac41eb24571d9855579c88e9907cea7998b8205ec6f6e510f84cff9edfdab968
@@ -0,0 +1,13 @@
1
+ version: 2.1
2
+ jobs:
3
+ build:
4
+ docker:
5
+ - image: ruby:3.1
6
+ steps:
7
+ - checkout
8
+ - run:
9
+ name: Run the default task
10
+ command: |
11
+ gem install bundler -v 2.3.10
12
+ bundle install
13
+ bundle exec rake
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ *.gem
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,230 @@
1
+ AllCops:
2
+ TargetRubyVersion: 3.1
3
+ Exclude:
4
+ - bin/**/*
5
+ <% `git status --ignored --porcelain`.scan(/^!!\s+(.*)$/).each do |match| %>
6
+ - <%= match[0] %>**/*
7
+ <% end %>
8
+
9
+ # Extensions
10
+ require:
11
+ - rubocop-rake
12
+ - rubocop-rspec
13
+
14
+ # New rules
15
+ Lint/DuplicateBranch: # (new in 1.3)
16
+ Enabled: true
17
+ Lint/DuplicateRegexpCharacterClassElement: # (new in 1.1)
18
+ Enabled: true
19
+ Lint/EmptyBlock: # (new in 1.1)
20
+ Enabled: true
21
+ Lint/EmptyClass: # (new in 1.3)
22
+ Enabled: true
23
+ Lint/NoReturnInBeginEndBlocks: # (new in 1.2)
24
+ Enabled: true
25
+ Lint/ToEnumArguments: # (new in 1.1)
26
+ Enabled: true
27
+ Lint/UnexpectedBlockArity: # (new in 1.5)
28
+ Enabled: true
29
+ Lint/UnmodifiedReduceAccumulator: # (new in 1.1)
30
+ Enabled: true
31
+ Style/ArgumentsForwarding: # (new in 1.1)
32
+ Enabled: true
33
+ Style/CollectionCompact: # (new in 1.2)
34
+ Enabled: true
35
+ Style/DocumentDynamicEvalDefinition: # (new in 1.1)
36
+ Enabled: true
37
+ Style/NegatedIfElseCondition: # (new in 1.2)
38
+ Enabled: true
39
+ Style/NilLambda: # (new in 1.3)
40
+ Enabled: true
41
+ Style/RedundantArgument: # (new in 1.4)
42
+ Enabled: true
43
+ Style/SwapValues: # (new in 1.1)
44
+ Enabled: true
45
+ Gemspec/DateAssignment: # (new in 1.10)
46
+ Enabled: true
47
+ Layout/SpaceBeforeBrackets: # (new in 1.7)
48
+ Enabled: true
49
+ Lint/AmbiguousAssignment: # (new in 1.7)
50
+ Enabled: true
51
+ Lint/DeprecatedConstants: # (new in 1.8)
52
+ Enabled: true
53
+ Lint/LambdaWithoutLiteralBlock: # (new in 1.8)
54
+ Enabled: true
55
+ Lint/NumberedParameterAssignment: # (new in 1.9)
56
+ Enabled: true
57
+ Lint/OrAssignmentToConstant: # (new in 1.9)
58
+ Enabled: true
59
+ Lint/RedundantDirGlobSort: # (new in 1.8)
60
+ Enabled: true
61
+ Lint/SymbolConversion: # (new in 1.9)
62
+ Enabled: true
63
+ Lint/TripleQuotes: # (new in 1.9)
64
+ Enabled: true
65
+ Style/EndlessMethod: # (new in 1.8)
66
+ Enabled: true
67
+ Style/HashConversion: # (new in 1.10)
68
+ Enabled: true
69
+ Style/HashExcept: # (new in 1.7)
70
+ Enabled: true
71
+ Style/IfWithBooleanLiteralBranches: # (new in 1.9)
72
+ Enabled: true
73
+ Gemspec/RequireMFA: # new in 1.23
74
+ Enabled: true
75
+ Layout/LineEndStringConcatenationIndentation: # new in 1.18
76
+ Enabled: true
77
+ Lint/AmbiguousOperatorPrecedence: # new in 1.21
78
+ Enabled: true
79
+ Lint/AmbiguousRange: # new in 1.19
80
+ Enabled: true
81
+ Lint/EmptyInPattern: # new in 1.16
82
+ Enabled: true
83
+ Lint/IncompatibleIoSelectWithFiberScheduler: # new in 1.21
84
+ Enabled: true
85
+ Lint/RequireRelativeSelfPath: # new in 1.22
86
+ Enabled: true
87
+ Lint/UselessRuby2Keywords: # new in 1.23
88
+ Enabled: true
89
+ Naming/BlockForwarding: # new in 1.24
90
+ Enabled: true
91
+ Security/IoMethods: # new in 1.22
92
+ Enabled: true
93
+ Style/FileRead: # new in 1.24
94
+ Enabled: true
95
+ Style/FileWrite: # new in 1.24
96
+ Enabled: true
97
+ Style/InPatternThen: # new in 1.16
98
+ Enabled: true
99
+ Style/MapToHash: # new in 1.24
100
+ Enabled: true
101
+ Style/MultilineInPatternThen: # new in 1.16
102
+ Enabled: true
103
+ Style/NumberedParameters: # new in 1.22
104
+ Enabled: true
105
+ Style/NumberedParametersLimit: # new in 1.22
106
+ Enabled: true
107
+ Style/OpenStructUse: # new in 1.23
108
+ Enabled: true
109
+ Style/QuotedSymbols: # new in 1.16
110
+ Enabled: true
111
+ Style/RedundantSelfAssignmentBranch: # new in 1.19
112
+ Enabled: true
113
+ Style/SelectByRegexp: # new in 1.22
114
+ Enabled: true
115
+ Style/StringChars: # new in 1.12
116
+ Enabled: true
117
+ RSpec/ExcessiveDocstringSpacing: # new in 2.5
118
+ Enabled: true
119
+ RSpec/IdenticalEqualityAssertion: # new in 2.4
120
+ Enabled: true
121
+ RSpec/SubjectDeclaration: # new in 2.5
122
+ Enabled: true
123
+ RSpec/FactoryBot/SyntaxMethods: # new in 2.7
124
+ Enabled: true
125
+ RSpec/Rails/AvoidSetupHook: # new in 2.4
126
+ Enabled: true
127
+ Style/NestedFileDirname: # new in 1.26
128
+ Enabled: true
129
+ RSpec/BeEq: # new in 2.9.0
130
+ Enabled: true
131
+ RSpec/BeNil: # new in 2.9.0
132
+ Enabled: true
133
+ Lint/RefinementImportMethods: # new in 1.27
134
+ Enabled: true
135
+ Style/RedundantInitialize: # new in 1.27
136
+ Enabled: true
137
+
138
+ # Alterations
139
+ Naming/RescuedExceptionsVariableName:
140
+ Enabled: false
141
+ Style/BlockComments:
142
+ Exclude:
143
+ - spec/**/*
144
+ Style/Documentation:
145
+ Enabled: false
146
+ Style/FrozenStringLiteralComment:
147
+ Enabled: false
148
+ Layout/MultilineMethodCallIndentation:
149
+ Enabled: false
150
+ Style/StringLiterals:
151
+ EnforcedStyle: double_quotes
152
+ Layout/AccessModifierIndentation:
153
+ EnforcedStyle: outdent
154
+ RSpec/NestedGroups:
155
+ Enabled: false
156
+ RSpec/MultipleMemoizedHelpers:
157
+ Enabled: false
158
+ RSpec/MultipleExpectations:
159
+ Enabled: false
160
+ RSpec/ExampleLength:
161
+ Enabled: false
162
+ RSpec/ContextWording:
163
+ Prefixes:
164
+ - but
165
+ - if
166
+ - when
167
+ - with
168
+ - without
169
+ RSpec/AnyInstance:
170
+ Enabled: false
171
+ Metrics/BlockLength:
172
+ Exclude:
173
+ - spec/**/*
174
+ Layout/ArgumentAlignment:
175
+ Enabled: false
176
+ Style/TrailingCommaInArrayLiteral:
177
+ EnforcedStyleForMultiline: consistent_comma
178
+ Style/TrailingCommaInArguments:
179
+ EnforcedStyleForMultiline: consistent_comma
180
+ Style/TrailingCommaInHashLiteral:
181
+ EnforcedStyleForMultiline: consistent_comma
182
+ Layout/MultilineMethodCallBraceLayout:
183
+ EnforcedStyle: new_line
184
+ Style/AsciiComments:
185
+ Enabled: false
186
+ Layout/CaseIndentation:
187
+ EnforcedStyle: end
188
+ Style/Lambda:
189
+ Enabled: false
190
+ Layout/SpaceInLambdaLiteral:
191
+ Enabled: false
192
+ Style/RedundantSelf:
193
+ Enabled: false
194
+ Style/PreferredHashMethods:
195
+ EnforcedStyle: verbose
196
+ Style/IfUnlessModifier:
197
+ Enabled: false
198
+ Layout/EndAlignment:
199
+ EnforcedStyleAlignWith: variable
200
+ Style/BlockDelimiters:
201
+ EnforcedStyle: semantic
202
+ AllowBracesOnProceduralOneLiners: true
203
+ Style/GuardClause:
204
+ Enabled: false
205
+ Metrics/MethodLength:
206
+ Enabled: false
207
+ Naming/MethodParameterName:
208
+ AllowedNames:
209
+ - as
210
+ - id
211
+ Metrics/AbcSize:
212
+ Enabled: false
213
+ Style/IfUnlessModifierOfIfUnless:
214
+ Enabled: false
215
+ Style/NestedModifier:
216
+ Enabled: false
217
+ Style/SoleNestedConditional:
218
+ Enabled: false
219
+ Naming/VariableNumber:
220
+ EnforcedStyle: snake_case
221
+ RSpec/SubjectStub:
222
+ Enabled: false
223
+ Layout/ArrayAlignment:
224
+ Enabled: false
225
+ Layout/FirstArrayElementIndentation:
226
+ Enabled: false
227
+ RSpec/FilePath:
228
+ Enabled: false
229
+ Naming/FileName:
230
+ Enabled: false
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.1.1
data/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ ## [Unreleased]
2
+
3
+ - Add a release script
4
+ - Adjust README
5
+
6
+ ## [1.0.0] - 2022-04-16
7
+
8
+ - Create an OmniAuth extension for authenticating using token URLs
@@ -0,0 +1,128 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, religion, or sexual identity
10
+ and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the
26
+ overall community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or
31
+ advances of any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
33
+ * Public or private harassment
34
+ * Publishing others' private information, such as a physical or email
35
+ address, without their explicit permission
36
+ * Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official e-mail address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ elliot@smart-casual.com.
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series
86
+ of actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or
93
+ permanent ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within
113
+ the community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.0, available at
119
+ https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120
+
121
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct
122
+ enforcement ladder](https://github.com/mozilla/diversity).
123
+
124
+ [homepage]: https://www.contributor-covenant.org
125
+
126
+ For answers to common questions about this code of conduct, see the FAQ at
127
+ https://www.contributor-covenant.org/faq. Translations are available at
128
+ https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in omniauth-token.gemspec
6
+ gemspec
7
+
8
+ gem "pry", "~> 0.13"
9
+ gem "rack-test", "~> 1.1"
10
+ gem "rake", "~> 13.0"
11
+ gem "rspec", "~> 3.11"
12
+ gem "rubocop", "~> 1.7"
13
+ gem "rubocop-rake", "~> 0.6"
14
+ gem "rubocop-rspec", "~> 2.9"
data/Gemfile.lock ADDED
@@ -0,0 +1,81 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ omniauth-token (1.0.0)
5
+ hmac (~> 2.1)
6
+ omniauth (~> 2.1)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ ast (2.4.2)
12
+ coderay (1.1.3)
13
+ diff-lcs (1.5.0)
14
+ hashie (5.0.0)
15
+ hmac (2.1.0)
16
+ method_source (1.0.0)
17
+ omniauth (2.1.0)
18
+ hashie (>= 3.4.6)
19
+ rack (>= 2.2.3)
20
+ rack-protection
21
+ parallel (1.22.1)
22
+ parser (3.1.2.0)
23
+ ast (~> 2.4.1)
24
+ pry (0.14.1)
25
+ coderay (~> 1.1)
26
+ method_source (~> 1.0)
27
+ rack (2.2.3)
28
+ rack-protection (2.2.0)
29
+ rack
30
+ rack-test (1.1.0)
31
+ rack (>= 1.0, < 3)
32
+ rainbow (3.1.1)
33
+ rake (13.0.6)
34
+ regexp_parser (2.3.0)
35
+ rexml (3.2.5)
36
+ rspec (3.11.0)
37
+ rspec-core (~> 3.11.0)
38
+ rspec-expectations (~> 3.11.0)
39
+ rspec-mocks (~> 3.11.0)
40
+ rspec-core (3.11.0)
41
+ rspec-support (~> 3.11.0)
42
+ rspec-expectations (3.11.0)
43
+ diff-lcs (>= 1.2.0, < 2.0)
44
+ rspec-support (~> 3.11.0)
45
+ rspec-mocks (3.11.1)
46
+ diff-lcs (>= 1.2.0, < 2.0)
47
+ rspec-support (~> 3.11.0)
48
+ rspec-support (3.11.0)
49
+ rubocop (1.27.0)
50
+ parallel (~> 1.10)
51
+ parser (>= 3.1.0.0)
52
+ rainbow (>= 2.2.2, < 4.0)
53
+ regexp_parser (>= 1.8, < 3.0)
54
+ rexml
55
+ rubocop-ast (>= 1.16.0, < 2.0)
56
+ ruby-progressbar (~> 1.7)
57
+ unicode-display_width (>= 1.4.0, < 3.0)
58
+ rubocop-ast (1.17.0)
59
+ parser (>= 3.1.1.0)
60
+ rubocop-rake (0.6.0)
61
+ rubocop (~> 1.0)
62
+ rubocop-rspec (2.9.0)
63
+ rubocop (~> 1.19)
64
+ ruby-progressbar (1.11.0)
65
+ unicode-display_width (2.1.0)
66
+
67
+ PLATFORMS
68
+ x86_64-darwin-21
69
+
70
+ DEPENDENCIES
71
+ omniauth-token!
72
+ pry (~> 0.13)
73
+ rack-test (~> 1.1)
74
+ rake (~> 13.0)
75
+ rspec (~> 3.11)
76
+ rubocop (~> 1.7)
77
+ rubocop-rake (~> 0.6)
78
+ rubocop-rspec (~> 2.9)
79
+
80
+ BUNDLED WITH
81
+ 2.3.10
data/LICENCE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Smart/Casual Ltd
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # Omniauth::Token
2
+
3
+ ## Installation
4
+
5
+ Add this line to your application's Gemfile:
6
+
7
+ ```ruby
8
+ gem 'omniauth-token'
9
+ ```
10
+
11
+ And then execute:
12
+
13
+ $ bundle install
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install omniauth-token
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Development
24
+
25
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
26
+
27
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
28
+
29
+ ## Contributing
30
+
31
+ Bug reports and pull requests are welcome on GitHub at https://github.com/SmartCasual/omniauth-token.
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rubocop/rake_task"
5
+ require "rspec/core/rake_task"
6
+
7
+ RuboCop::RakeTask.new
8
+ RSpec::Core::RakeTask.new(:spec)
9
+
10
+ task default: %i[rubocop spec]
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "omniauth-token"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/rake ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rake' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rake", "rake")
data/bin/release ADDED
@@ -0,0 +1,4 @@
1
+ gem build
2
+ gem push omniauth-token-$1.gem
3
+ git tag $1
4
+ git push --tags
data/bin/rspec ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rspec' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rspec-core", "rspec")
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,69 @@
1
+ require "omniauth"
2
+ require "hmac"
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ class Token
7
+ include OmniAuth::Strategy
8
+
9
+ option :uid_field, :id
10
+ option :email_address_field, :email_address
11
+ option :token_field, :token
12
+ option :context, :sessions
13
+ option :secret, nil
14
+ option :request_a_login_email_path, "/"
15
+
16
+ def request_phase
17
+ redirect options.request_a_login_email_path
18
+ end
19
+
20
+ def callback_phase
21
+ return fail!(:invalid_credentials) unless valid_token?
22
+
23
+ super
24
+ end
25
+
26
+ uid do
27
+ id
28
+ end
29
+
30
+ info do
31
+ {
32
+ email: email_address,
33
+ }
34
+ end
35
+
36
+ private
37
+
38
+ def valid_token?
39
+ token_validator.validate(token, against_id: id, extra_fields:)
40
+ end
41
+
42
+ def id
43
+ request.params[options.uid_field.to_s]
44
+ end
45
+
46
+ def email_address
47
+ request.params[options.email_address_field.to_s]
48
+ end
49
+
50
+ def token
51
+ request.params[options.token_field.to_s]
52
+ end
53
+
54
+ def token_validator
55
+ @token_validator ||= ::HMAC::Validator.new(context: options[:context], secret: options[:secret])
56
+ end
57
+
58
+ def extra_fields
59
+ {}.tap do |extra_fields|
60
+ extra_fields[:email_address] = email_address if email_address_given?
61
+ end
62
+ end
63
+
64
+ def email_address_given?
65
+ request.params.has_key?(options.email_address_field.to_s)
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Omniauth
4
+ module Token
5
+ VERSION = "1.0.0"
6
+ end
7
+ end
@@ -0,0 +1 @@
1
+ require_relative "omniauth/strategies/token"
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/omniauth-token/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "omniauth-token"
7
+ spec.version = Omniauth::Token::VERSION
8
+ spec.authors = ["Elliot Crosby-McCullough"]
9
+ spec.email = ["elliot.cm@gmail.com"]
10
+
11
+ spec.summary = "Token authentication for OmniAuth"
12
+ spec.homepage = "https://github.com/SmartCasual/omniauth-token"
13
+ spec.required_ruby_version = Gem::Requirement.new(">= 3.1.0")
14
+
15
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = spec.homepage
19
+ spec.metadata["changelog_uri"] = "https://github.com/SmartCasual/omniauth-token/blob/#{spec.version}/CHANGELOG.md"
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(File.expand_path(__dir__)) {
24
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
25
+ }
26
+ spec.require_paths = ["lib"]
27
+
28
+ spec.add_runtime_dependency "hmac", "~> 2.1"
29
+ spec.add_runtime_dependency "omniauth", "~> 2.1"
30
+ spec.metadata["rubygems_mfa_required"] = "true"
31
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-token
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Elliot Crosby-McCullough
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-04-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: hmac
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: omniauth
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.1'
41
+ description:
42
+ email:
43
+ - elliot.cm@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".circleci/config.yml"
49
+ - ".gitignore"
50
+ - ".rspec"
51
+ - ".rubocop.yml"
52
+ - ".ruby-version"
53
+ - CHANGELOG.md
54
+ - CODE_OF_CONDUCT.md
55
+ - Gemfile
56
+ - Gemfile.lock
57
+ - LICENCE
58
+ - README.md
59
+ - Rakefile
60
+ - bin/console
61
+ - bin/rake
62
+ - bin/release
63
+ - bin/rspec
64
+ - bin/setup
65
+ - lib/omniauth-token.rb
66
+ - lib/omniauth-token/version.rb
67
+ - lib/omniauth/strategies/token.rb
68
+ - omniauth-token.gemspec
69
+ homepage: https://github.com/SmartCasual/omniauth-token
70
+ licenses: []
71
+ metadata:
72
+ allowed_push_host: https://rubygems.org
73
+ homepage_uri: https://github.com/SmartCasual/omniauth-token
74
+ source_code_uri: https://github.com/SmartCasual/omniauth-token
75
+ changelog_uri: https://github.com/SmartCasual/omniauth-token/blob/1.0.0/CHANGELOG.md
76
+ rubygems_mfa_required: 'true'
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: 3.1.0
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubygems_version: 3.3.7
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: Token authentication for OmniAuth
96
+ test_files: []