omniauth-jwt2 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/FUNDING.yml +11 -0
- data/.github/dependabot.yml +2 -0
- data/.github/workflows/ancient.yml +53 -0
- data/.github/workflows/ci.yml +59 -0
- data/.github/workflows/coverage.yml +91 -0
- data/.github/workflows/legacy.yml +54 -0
- data/.github/workflows/style.yml +43 -0
- data/.gitignore +18 -0
- data/.rspec +2 -0
- data/.rubocop.yml +2 -0
- data/.rubocop_gradual.lock +39 -0
- data/.simplecov +2 -0
- data/.tool-versions +1 -0
- data/Gemfile +17 -0
- data/Guardfile +8 -0
- data/LICENSE.txt +23 -0
- data/README.md +125 -0
- data/Rakefile +23 -0
- data/gemfiles/ancient.gemfile +20 -0
- data/gemfiles/contexts/coverage.gemfile +2 -0
- data/gemfiles/contexts/debug.gemfile +6 -0
- data/gemfiles/contexts/style.gemfile +5 -0
- data/gemfiles/contexts/testing.gemfile +8 -0
- data/gemfiles/coverage.gemfile +20 -0
- data/gemfiles/legacy.gemfile +26 -0
- data/gemfiles/style.gemfile +20 -0
- data/gemfiles/vanilla.gemfile +20 -0
- data/lib/omniauth/jwt/version.rb +7 -0
- data/lib/omniauth/jwt.rb +10 -0
- data/lib/omniauth/strategies/jwt.rb +97 -0
- data/omniauth-jwt2.gemspec +41 -0
- data/spec/lib/omniauth/strategies/jwt_spec.rb +213 -0
- data/spec/spec_helper.rb +64 -0
- data/spec/support/hash.rb +9 -0
- data/spec/support/next_instance_of.rb +43 -0
- metadata +232 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 85ecb41b3dcf8d20cb6bb3229bfc0d4605356ff07a9d71885522683ecc4a5d05
|
4
|
+
data.tar.gz: 0460fdcc06eea2cba436b1fc04ae701bb91a13bdecc3818777c76f6df2eb00ab
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8d4355d90b9488207efe106bd6911cbd0f6c1cca54dc92aecde7ebee8aeed0fbf1f7a4154a3eca5d657a3865f166b90bd6b97f54662e1639115b89938f25bc8e
|
7
|
+
data.tar.gz: 708081766470208844bdb88647e797de49acc82d225ae15c8cd78148b47db8189afa3624a4a77c51a6e182c36b0d0f910557a15bcf1754be0e5a37c23c023f4c
|
data/.github/FUNDING.yml
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# These are supported funding model platforms
|
2
|
+
|
3
|
+
github: [pboling] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
4
|
+
patreon: galtzo # Replace with a single Patreon username
|
5
|
+
open_collective: # Replace with a single Open Collective username
|
6
|
+
ko_fi: pboling # Replace with a single Ko-fi username
|
7
|
+
tidelift: rubygems/omniauth-jwt2 # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
8
|
+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
9
|
+
liberapay: pboling # Replace with a single Liberapay username
|
10
|
+
issuehunt: pboling # Replace with a single IssueHunt username
|
11
|
+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
@@ -0,0 +1,53 @@
|
|
1
|
+
name: Ancient Ruby Support
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- 'main'
|
7
|
+
tags:
|
8
|
+
- '!*' # Do not execute on tags
|
9
|
+
pull_request:
|
10
|
+
branches:
|
11
|
+
- '*'
|
12
|
+
# Allow manually triggering the workflow.
|
13
|
+
workflow_dispatch:
|
14
|
+
|
15
|
+
# Cancels all previous workflow runs for the same branch that have not yet completed.
|
16
|
+
concurrency:
|
17
|
+
# The concurrency group contains the workflow name and the branch name.
|
18
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
19
|
+
cancel-in-progress: true
|
20
|
+
|
21
|
+
jobs:
|
22
|
+
test:
|
23
|
+
name: Ruby ${{ matrix.ruby }}
|
24
|
+
if: "!contains(github.event.commits[0].message, '[ci skip]') && !contains(github.event.commits[0].message, '[skip ci]')"
|
25
|
+
env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
|
26
|
+
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
|
27
|
+
strategy:
|
28
|
+
fail-fast: false
|
29
|
+
matrix:
|
30
|
+
experimental: [false]
|
31
|
+
rubygems:
|
32
|
+
- "2.7.11"
|
33
|
+
bundler:
|
34
|
+
- none
|
35
|
+
gemfile:
|
36
|
+
- ancient
|
37
|
+
ruby:
|
38
|
+
- "2.3.8"
|
39
|
+
- "2.2.10"
|
40
|
+
runs-on: ubuntu-20.04
|
41
|
+
continue-on-error: ${{ matrix.experimental || endsWith(matrix.ruby, 'head') }}
|
42
|
+
steps:
|
43
|
+
- name: Checkout
|
44
|
+
uses: actions/checkout@v4
|
45
|
+
- name: Setup Ruby & Bundle
|
46
|
+
uses: ruby/setup-ruby@v1
|
47
|
+
with:
|
48
|
+
ruby-version: ${{ matrix.ruby }}
|
49
|
+
rubygems: ${{ matrix.rubygems }}
|
50
|
+
bundler: ${{ matrix.bundler }}
|
51
|
+
bundler-cache: true
|
52
|
+
- name: Run tests
|
53
|
+
run: bundle exec rspec
|
@@ -0,0 +1,59 @@
|
|
1
|
+
name: Omniauth JWT Tests
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- 'main'
|
7
|
+
tags:
|
8
|
+
- '!*' # Do not execute on tags
|
9
|
+
pull_request:
|
10
|
+
branches:
|
11
|
+
- '*'
|
12
|
+
# Allow manually triggering the workflow.
|
13
|
+
workflow_dispatch:
|
14
|
+
|
15
|
+
# Cancels all previous workflow runs for the same branch that have not yet completed.
|
16
|
+
concurrency:
|
17
|
+
# The concurrency group contains the workflow name and the branch name.
|
18
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
19
|
+
cancel-in-progress: true
|
20
|
+
|
21
|
+
jobs:
|
22
|
+
build:
|
23
|
+
runs-on: ubuntu-latest
|
24
|
+
name: Ruby ${{ matrix.ruby }}
|
25
|
+
env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
|
26
|
+
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
|
27
|
+
if: "!contains(github.event.commits[0].message, '[ci skip]') && !contains(github.event.commits[0].message, '[skip ci]')"
|
28
|
+
continue-on-error: ${{ matrix.experimental || endsWith(matrix.ruby, 'head') }}
|
29
|
+
strategy:
|
30
|
+
fail-fast: false
|
31
|
+
matrix:
|
32
|
+
experimental: [false]
|
33
|
+
rubygems:
|
34
|
+
- latest
|
35
|
+
bundler:
|
36
|
+
- latest
|
37
|
+
gemfile:
|
38
|
+
- vanilla
|
39
|
+
ruby:
|
40
|
+
- "2.7"
|
41
|
+
- "3.0"
|
42
|
+
- "3.1"
|
43
|
+
- "3.2"
|
44
|
+
exclude:
|
45
|
+
# Vanilla + 3.2 is effectively run by coverage workflow
|
46
|
+
- gemfile: vanilla
|
47
|
+
ruby: "3.2"
|
48
|
+
steps:
|
49
|
+
- name: Checkout
|
50
|
+
uses: actions/checkout@v4
|
51
|
+
- name: Setup Ruby & Bundle
|
52
|
+
uses: ruby/setup-ruby@v1
|
53
|
+
with:
|
54
|
+
ruby-version: ${{ matrix.ruby }}
|
55
|
+
rubygems: ${{ matrix.rubygems }}
|
56
|
+
bundler: ${{ matrix.bundler }}
|
57
|
+
bundler-cache: true
|
58
|
+
- name: Tests
|
59
|
+
run: bundle exec rspec
|
@@ -0,0 +1,91 @@
|
|
1
|
+
name: Code Coverage
|
2
|
+
|
3
|
+
env:
|
4
|
+
K_SOUP_COV_MIN_BRANCH: 85
|
5
|
+
K_SOUP_COV_MIN_LINE: 87
|
6
|
+
|
7
|
+
on:
|
8
|
+
push:
|
9
|
+
branches:
|
10
|
+
- 'main'
|
11
|
+
tags:
|
12
|
+
- '!*' # Do not execute on tags
|
13
|
+
pull_request:
|
14
|
+
branches:
|
15
|
+
- '*'
|
16
|
+
# Allow manually triggering the workflow.
|
17
|
+
workflow_dispatch:
|
18
|
+
|
19
|
+
# Cancels all previous workflow runs for the same branch that have not yet completed.
|
20
|
+
concurrency:
|
21
|
+
# The concurrency group contains the workflow name and the branch name.
|
22
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
23
|
+
cancel-in-progress: true
|
24
|
+
|
25
|
+
jobs:
|
26
|
+
test:
|
27
|
+
name: Specs with Coverage - Ruby ${{ matrix.ruby }}
|
28
|
+
if: "!contains(github.event.commits[0].message, '[ci skip]') && !contains(github.event.commits[0].message, '[skip ci]')"
|
29
|
+
env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
|
30
|
+
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
|
31
|
+
CI_CODECOV: true
|
32
|
+
COVER_ALL: true
|
33
|
+
strategy:
|
34
|
+
fail-fast: false
|
35
|
+
matrix:
|
36
|
+
experimental: [false]
|
37
|
+
rubygems:
|
38
|
+
- latest
|
39
|
+
bundler:
|
40
|
+
- latest
|
41
|
+
gemfile:
|
42
|
+
- coverage
|
43
|
+
ruby:
|
44
|
+
- "3.2"
|
45
|
+
|
46
|
+
runs-on: ubuntu-latest
|
47
|
+
steps:
|
48
|
+
- name: Checkout
|
49
|
+
uses: actions/checkout@v4
|
50
|
+
|
51
|
+
- name: Setup Ruby & Bundle
|
52
|
+
uses: ruby/setup-ruby@v1
|
53
|
+
with:
|
54
|
+
ruby-version: ${{ matrix.ruby }}
|
55
|
+
rubygems: ${{ matrix.rubygems }}
|
56
|
+
bundler: ${{ matrix.bundler }}
|
57
|
+
bundler-cache: true
|
58
|
+
|
59
|
+
- name: Run RSpec tests
|
60
|
+
run: |
|
61
|
+
bundle exec rspec
|
62
|
+
|
63
|
+
- name: Code Coverage Summary Report
|
64
|
+
uses: irongut/CodeCoverageSummary@v1.3.0
|
65
|
+
if: ${{ github.event_name == 'pull_request' }}
|
66
|
+
with:
|
67
|
+
filename: ./coverage/coverage.xml
|
68
|
+
badge: true
|
69
|
+
fail_below_min: true
|
70
|
+
format: markdown
|
71
|
+
hide_branch_rate: false
|
72
|
+
hide_complexity: true
|
73
|
+
indicators: true
|
74
|
+
output: both
|
75
|
+
# https://github.com/irongut/CodeCoverageSummary#thresholds
|
76
|
+
thresholds: "75 85"
|
77
|
+
continue-on-error: ${{ matrix.experimental != 'false' }}
|
78
|
+
|
79
|
+
- name: Add Coverage PR Comment
|
80
|
+
uses: marocchino/sticky-pull-request-comment@v2
|
81
|
+
if: ${{ github.event_name == 'pull_request' }}
|
82
|
+
with:
|
83
|
+
recreate: true
|
84
|
+
path: code-coverage-results.md
|
85
|
+
continue-on-error: ${{ matrix.experimental != 'false' }}
|
86
|
+
|
87
|
+
- name: Coveralls
|
88
|
+
uses: coverallsapp/github-action@master
|
89
|
+
with:
|
90
|
+
github-token: ${{ secrets.GITHUB_TOKEN }}
|
91
|
+
continue-on-error: ${{ matrix.experimental != 'false' }}
|
@@ -0,0 +1,54 @@
|
|
1
|
+
name: Legacy Ruby Support
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- 'main'
|
7
|
+
tags:
|
8
|
+
- '!*' # Do not execute on tags
|
9
|
+
pull_request:
|
10
|
+
branches:
|
11
|
+
- '*'
|
12
|
+
# Allow manually triggering the workflow.
|
13
|
+
workflow_dispatch:
|
14
|
+
|
15
|
+
# Cancels all previous workflow runs for the same branch that have not yet completed.
|
16
|
+
concurrency:
|
17
|
+
# The concurrency group contains the workflow name and the branch name.
|
18
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
19
|
+
cancel-in-progress: true
|
20
|
+
|
21
|
+
jobs:
|
22
|
+
test:
|
23
|
+
name: Ruby ${{ matrix.ruby }}
|
24
|
+
if: "!contains(github.event.commits[0].message, '[ci skip]') && !contains(github.event.commits[0].message, '[skip ci]')"
|
25
|
+
env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
|
26
|
+
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
|
27
|
+
strategy:
|
28
|
+
fail-fast: false
|
29
|
+
matrix:
|
30
|
+
experimental: [false]
|
31
|
+
rubygems:
|
32
|
+
- "2.7.11"
|
33
|
+
bundler:
|
34
|
+
- none
|
35
|
+
gemfile:
|
36
|
+
- legacy
|
37
|
+
ruby:
|
38
|
+
- "2.6"
|
39
|
+
- "2.5"
|
40
|
+
- "2.4"
|
41
|
+
runs-on: ubuntu-20.04
|
42
|
+
continue-on-error: ${{ matrix.experimental || endsWith(matrix.ruby, 'head') }}
|
43
|
+
steps:
|
44
|
+
- name: Checkout
|
45
|
+
uses: actions/checkout@v4
|
46
|
+
- name: Setup Ruby & Bundle
|
47
|
+
uses: ruby/setup-ruby@v1
|
48
|
+
with:
|
49
|
+
ruby-version: ${{ matrix.ruby }}
|
50
|
+
rubygems: ${{ matrix.rubygems }}
|
51
|
+
bundler: ${{ matrix.bundler }}
|
52
|
+
bundler-cache: true
|
53
|
+
- name: Run tests
|
54
|
+
run: bundle exec rspec
|
@@ -0,0 +1,43 @@
|
|
1
|
+
name: Code Style
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- 'main'
|
7
|
+
tags:
|
8
|
+
- '!*' # Do not execute on tags
|
9
|
+
pull_request:
|
10
|
+
branches:
|
11
|
+
- '*'
|
12
|
+
|
13
|
+
jobs:
|
14
|
+
rubocop:
|
15
|
+
name: RuboCop
|
16
|
+
strategy:
|
17
|
+
fail-fast: false
|
18
|
+
matrix:
|
19
|
+
experimental: [false]
|
20
|
+
rubygems:
|
21
|
+
- latest
|
22
|
+
bundler:
|
23
|
+
- latest
|
24
|
+
gemfile:
|
25
|
+
- style
|
26
|
+
ruby:
|
27
|
+
- "3.2"
|
28
|
+
|
29
|
+
runs-on: ubuntu-latest
|
30
|
+
env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
|
31
|
+
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
|
32
|
+
steps:
|
33
|
+
- name: Checkout
|
34
|
+
uses: actions/checkout@v4
|
35
|
+
- name: Setup Ruby & Bundle
|
36
|
+
uses: ruby/setup-ruby@v1
|
37
|
+
with:
|
38
|
+
ruby-version: ${{ matrix.ruby }}
|
39
|
+
rubygems: ${{ matrix.rubygems }}
|
40
|
+
bundler: ${{ matrix.bundler }}
|
41
|
+
bundler-cache: true
|
42
|
+
- name: Run RuboCop Gradual
|
43
|
+
run: bundle exec rake rubocop_gradual:check
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
{
|
2
|
+
"lib/omniauth/strategies/jwt.rb:543932255": [
|
3
|
+
[60, 9, 76, "Lint/RescueException: Avoid rescuing the `Exception` class. Perhaps you meant to rescue `StandardError`?", 967033479]
|
4
|
+
],
|
5
|
+
"omniauth-jwt2.gemspec:998952283": [
|
6
|
+
[18, 16, 16, "Packaging/GemspecGit: Avoid using git to produce lists of files. Downstreams often need to build your package in an environment that does not have git (on purpose). Use some pure Ruby alternative, like `Dir` or `Dir.glob`.", 1973161220]
|
7
|
+
],
|
8
|
+
"spec/lib/omniauth/strategies/jwt_spec.rb:2698313308": [
|
9
|
+
[3, 1, 34, "RSpec/FilePath: Spec path should end with `omni_auth/strategies/jwt*_spec.rb`.", 1935033905],
|
10
|
+
[3, 1, 34, "RSpec/SpecFilePathFormat: Spec path should end with `omni_auth/strategies/jwt*_spec.rb`.", 1935033905],
|
11
|
+
[12, 13, 25, "RSpec/DescribedClass: Use `described_class` instead of `OmniAuth::Strategies::JWT`.", 2234488924],
|
12
|
+
[19, 11, 15, "RSpec/ContextWording: Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.", 391893083],
|
13
|
+
[20, 5, 42, "RSpec/MultipleExpectations: Example has too many expectations [2/1].", 4106660663],
|
14
|
+
[29, 11, 16, "RSpec/ContextWording: Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.", 1409468707],
|
15
|
+
[51, 7, 51, "RSpec/MultipleExpectations: Example has too many expectations [2/1].", 4149552871],
|
16
|
+
[51, 7, 531, "RSpec/ExampleLength: Example has too many lines. [6/5]", 2143440997],
|
17
|
+
[91, 3, 3512, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [10/5]", 2363831099],
|
18
|
+
[110, 7, 7, "RSpec/NamedSubject: Name your test subject if you need to reference it explicitly.", 1892732441],
|
19
|
+
[111, 7, 7, "RSpec/NamedSubject: Name your test subject if you need to reference it explicitly.", 1892732441],
|
20
|
+
[116, 9, 6, "RSpec/ExpectInHook: Do not use `expect` in `before` hook", 1179768986],
|
21
|
+
[116, 9, 20, "RSpec/StubbedMock: Prefer `allow` over `expect` when configuring a response.", 2951559342],
|
22
|
+
[116, 33, 7, "RSpec/MessageSpies: Prefer `have_received` for setting message expectations. Setup `rack_request` as a spy using `allow` or `instance_spy`.", 1384559950],
|
23
|
+
[130, 5, 56, "Performance/RedundantMerge: Use `algos[OpenSSL::PKey::EC] = %w[ES256 ES384 ES512]` instead of `algos.merge!(OpenSSL::PKey::EC => %w[ES256 ES384 ES512])`.", 2983772293],
|
24
|
+
[133, 9, 846, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [10/5]", 3520352246],
|
25
|
+
[152, 22, 7, "RSpec/NamedSubject: Name your test subject if you need to reference it explicitly.", 1892732441],
|
26
|
+
[160, 5, 310, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [10/5]", 3501674141],
|
27
|
+
[160, 13, 28, "RSpec/ContextWording: Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.", 1877551307],
|
28
|
+
[170, 18, 7, "RSpec/NamedSubject: Name your test subject if you need to reference it explicitly.", 1892732441],
|
29
|
+
[174, 5, 515, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [10/5]", 1246671601],
|
30
|
+
[185, 9, 7, "RSpec/NamedSubject: Name your test subject if you need to reference it explicitly.", 1892732441],
|
31
|
+
[189, 18, 7, "RSpec/NamedSubject: Name your test subject if you need to reference it explicitly.", 1892732441],
|
32
|
+
[193, 5, 537, "RSpec/MultipleMemoizedHelpers: Example group has too many memoized helpers [10/5]", 3770030886],
|
33
|
+
[205, 9, 7, "RSpec/NamedSubject: Name your test subject if you need to reference it explicitly.", 1892732441],
|
34
|
+
[209, 18, 7, "RSpec/NamedSubject: Name your test subject if you need to reference it explicitly.", 1892732441]
|
35
|
+
],
|
36
|
+
"spec/support/hash.rb:812296649": [
|
37
|
+
[2, 3, 110, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 3570181400]
|
38
|
+
]
|
39
|
+
}
|
data/.simplecov
ADDED
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 2.3.8
|
data/Gemfile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in omniauth-jwt.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
# Development dependencies that rely on Ruby version >=
|
7
|
+
# Style
|
8
|
+
eval_gemfile "gemfiles/contexts/style.gemfile"
|
9
|
+
|
10
|
+
# Coverage
|
11
|
+
eval_gemfile "gemfiles/contexts/coverage.gemfile"
|
12
|
+
|
13
|
+
# Testing
|
14
|
+
eval_gemfile "gemfiles/contexts/testing.gemfile"
|
15
|
+
|
16
|
+
# Debug
|
17
|
+
eval_gemfile "gemfiles/contexts/debug.gemfile"
|
data/Guardfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
Copyright (c) 2013 Michael Bleigh
|
2
|
+
Copyright (c) 2023 Peter Boling of railsbling.com
|
3
|
+
|
4
|
+
MIT License
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
7
|
+
a copy of this software and associated documentation files (the
|
8
|
+
"Software"), to deal in the Software without restriction, including
|
9
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
10
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
11
|
+
permit persons to whom the Software is furnished to do so, subject to
|
12
|
+
the following conditions:
|
13
|
+
|
14
|
+
The above copyright notice and this permission notice shall be
|
15
|
+
included in all copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
18
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
19
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
20
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
21
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
22
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
23
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
# OmniAuth::JWT
|
2
|
+
|
3
|
+
<div id="badges">
|
4
|
+
|
5
|
+
[![Current][🚎ciwfi]][🚎ciwf] [![Coverage][🖐cowfi]][🖐cowf] [![Style][🧮swfi]][🧮swf]
|
6
|
+
|
7
|
+
[![Legacy][🧮lwfi]][🧮lwf] [![Ancient][🧮awfi]][🧮awf]
|
8
|
+
|
9
|
+
---
|
10
|
+
|
11
|
+
[![Liberapay Patrons][⛳liberapay-img]][⛳liberapay]
|
12
|
+
<span class="badge-buymeacoffee">
|
13
|
+
[![Sponsor Me][🖇sponsor-img]][🖇sponsor]
|
14
|
+
<a href="https://ko-fi.com/O5O86SNP4" target='_blank' title="Donate to my FLOSS or refugee efforts at ko-fi.com"><img src="https://img.shields.io/badge/buy%20me%20coffee-donate-yellow.svg" alt="Buy Me Coffee donation button" /></a>
|
15
|
+
</span>
|
16
|
+
<span class="badge-patreon">
|
17
|
+
<a href="https://patreon.com/galtzo" title="Donate to my FLOSS or refugee efforts using Patreon"><img src="https://img.shields.io/badge/patreon-donate-yellow.svg" alt="Patreon donate button" /></a>
|
18
|
+
</span>
|
19
|
+
|
20
|
+
</div>
|
21
|
+
|
22
|
+
[🚎ciwf]: https://github.com/pboling/omniauth-jwt2/actions/workflows/ci.yml
|
23
|
+
[🚎ciwfi]: https://github.com/pboling/omniauth-jwt2/actions/workflows/ci.yml/badge.svg
|
24
|
+
[🖐cowf]: https://github.com/pboling/omniauth-jwt2/actions/workflows/coverage.yml
|
25
|
+
[🖐cowfi]: https://github.com/pboling/omniauth-jwt2/actions/workflows/coverage.yml/badge.svg
|
26
|
+
[🧮swf]: https://github.com/pboling/omniauth-jwt2/actions/workflows/style.yml
|
27
|
+
[🧮swfi]: https://github.com/pboling/omniauth-jwt2/actions/workflows/style.yml/badge.svg
|
28
|
+
[🧮lwf]: https://github.com/pboling/omniauth-jwt2/actions/workflows/legacy.yml
|
29
|
+
[🧮lwfi]: https://github.com/pboling/omniauth-jwt2/actions/workflows/legacy.yml/badge.svg
|
30
|
+
[🧮awf]: https://github.com/pboling/omniauth-jwt2/actions/workflows/ancient.yml
|
31
|
+
[🧮awfi]: https://github.com/pboling/omniauth-jwt2/actions/workflows/ancient.yml/badge.svg
|
32
|
+
|
33
|
+
[⛳liberapay-img]: https://img.shields.io/liberapay/patrons/pboling.svg?logo=liberapay
|
34
|
+
[⛳liberapay]: https://liberapay.com/pboling/donate
|
35
|
+
[🖇sponsor-img]: https://img.shields.io/badge/Sponsor_Me!-pboling.svg?style=social&logo=github
|
36
|
+
[🖇sponsor]: https://github.com/sponsors/pboling
|
37
|
+
|
38
|
+
[JSON Web Token](http://self-issued.info/docs/draft-ietf-oauth-json-web-token.html) (JWT) is a simple
|
39
|
+
way to send verified information between two parties online. This can be useful as a mechanism for
|
40
|
+
providing Single Sign-On (SSO) to an application by allowing an authentication server to send a validated
|
41
|
+
claim and log the user in. This is how [Zendesk does SSO](https://support.zendesk.com/hc/en-us/articles/4408845838874-Enabling-JWT-JSON-Web-Token-single-sign-on),
|
42
|
+
for example.
|
43
|
+
|
44
|
+
OmniAuth::JWT provides a clean, simple wrapper on top of JWT so that you can easily implement this kind
|
45
|
+
of SSO either between your own applications or allow third parties to delegate authentication.
|
46
|
+
|
47
|
+
## History
|
48
|
+
|
49
|
+
This library is a fork of the [original](https://github.com/mbleigh/omniauth-jwt)
|
50
|
+
by Michael Bleigh which stopped development in 2013.
|
51
|
+
It incorporates *all* of the fixes and features from the main forks by Aha, Discourse,
|
52
|
+
and GitLab (which has been vendored inside GitLab, and isn't even in the fork network).
|
53
|
+
|
54
|
+
## Installation
|
55
|
+
|
56
|
+
Add this line to your application's Gemfile:
|
57
|
+
|
58
|
+
gem 'omniauth-jwt2'
|
59
|
+
|
60
|
+
And then execute:
|
61
|
+
|
62
|
+
$ bundle
|
63
|
+
|
64
|
+
Or install it yourself as:
|
65
|
+
|
66
|
+
$ gem install omniauth-jwt2
|
67
|
+
|
68
|
+
## Usage
|
69
|
+
|
70
|
+
You use OmniAuth::JWT just like you do any other OmniAuth strategy:
|
71
|
+
|
72
|
+
```ruby
|
73
|
+
use OmniAuth::JWT, "SHAREDSECRET", auth_url: "http://example.com/login"
|
74
|
+
```
|
75
|
+
|
76
|
+
The first parameter is the shared secret that will be used by the external authenticator to verify
|
77
|
+
that. You must also specify the `auth_url` option to tell the strategy where to redirect to log
|
78
|
+
in. Other available options are:
|
79
|
+
|
80
|
+
* **algorithm:** the algorithm to use to decode the JWT token. This is `HS256` by default but can
|
81
|
+
be set to anything supported by [ruby-jwt](https://github.com/progrium/ruby-jwt)
|
82
|
+
* **uid_claim:** this determines which claim will be used to uniquely identify the user. Defaults
|
83
|
+
to `email`
|
84
|
+
* **required_claims:** array of claims that are required to make this a valid authentication call.
|
85
|
+
Defaults to `['name', 'email']`
|
86
|
+
* **info_map:** array mapping claim values to info hash values. Defaults to mapping `name` and `email`
|
87
|
+
to the same in the info hash.
|
88
|
+
* **valid_within:** integer of how many seconds of time skew you will allow. Defaults to `nil`. If this
|
89
|
+
is set, the `iat` claim becomes required and must be within the specified number of seconds of the
|
90
|
+
current time. This helps to prevent replay attacks.
|
91
|
+
|
92
|
+
### Authentication Process
|
93
|
+
|
94
|
+
When you authenticate through `omniauth-jwt` you can send users to `/auth/jwt` and it will redirect
|
95
|
+
them to the URL specified in the `auth_url` option. From there, the provider must generate a JWT
|
96
|
+
and send it to the `/auth/jwt/callback` URL as a "jwt" parameter:
|
97
|
+
|
98
|
+
/auth/jwt/callback?jwt=ENCODEDJWTGOESHERE
|
99
|
+
|
100
|
+
An example of how to do that in Sinatra:
|
101
|
+
|
102
|
+
```ruby
|
103
|
+
require "jwt"
|
104
|
+
|
105
|
+
get "/login/sso/other-app" do
|
106
|
+
# assuming the user is already logged in and this is available as current_user
|
107
|
+
claims = {
|
108
|
+
id: current_user.id,
|
109
|
+
name: current_user.name,
|
110
|
+
email: current_user.email,
|
111
|
+
iat: Time.now.to_i,
|
112
|
+
}
|
113
|
+
|
114
|
+
payload = JWT.encode(claims, ENV["SSO_SECRET"])
|
115
|
+
redirect "http://other-app.com/auth/jwt/callback?jwt=#{payload}"
|
116
|
+
end
|
117
|
+
```
|
118
|
+
|
119
|
+
## Contributing
|
120
|
+
|
121
|
+
1. Fork it
|
122
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
123
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
124
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
125
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
|
3
|
+
require "rspec/core/rake_task"
|
4
|
+
RSpec::Core::RakeTask.new(:spec)
|
5
|
+
|
6
|
+
desc "alias test task to spec"
|
7
|
+
task test: :spec
|
8
|
+
|
9
|
+
begin
|
10
|
+
require "kettle-soup-cover"
|
11
|
+
Kettle::Soup::Cover.install_tasks
|
12
|
+
rescue LoadError
|
13
|
+
# NOOP
|
14
|
+
end
|
15
|
+
|
16
|
+
begin
|
17
|
+
require "rubocop/lts"
|
18
|
+
Rubocop::Lts.install_tasks
|
19
|
+
rescue LoadError
|
20
|
+
# NOOP
|
21
|
+
end
|
22
|
+
|
23
|
+
task default: :spec
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
4
|
+
|
5
|
+
source "https://rubygems.org"
|
6
|
+
|
7
|
+
# Gemfile is only for local development.
|
8
|
+
# On CI we only need the gemspecs' dependencies (including development dependencies).
|
9
|
+
# Exceptions, if any, will be found in gemfiles/*
|
10
|
+
|
11
|
+
# Testing
|
12
|
+
gem "rack", "~> 2.1.4.3" # ruby 2.2.2
|
13
|
+
gem "json", "~> 2.5.1" # ruby 2.0
|
14
|
+
|
15
|
+
# Debugging
|
16
|
+
eval_gemfile "contexts/debug.gemfile"
|
17
|
+
|
18
|
+
gemspec path: "../"
|
19
|
+
|
20
|
+
gem "omniauth", "< 2"
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# Testing
|
2
|
+
gem "ed25519", "~> 1.3" # ruby 2.4
|
3
|
+
gem "json", "~> 2.6", ">= 2.6.3" # ruby 2.3
|
4
|
+
gem "openssl", ">= 2.0" # ruby 2.3, v3.0 is >= 2.6, v3.2 is >= 2.7
|
5
|
+
gem "openssl-signature_algorithm", "~> 1.3" # ruby 2.4
|
6
|
+
gem "rack", "~> 3.0", ">= 3.0.8" # ruby 2.4
|
7
|
+
gem "rack-session", "~> 2.0" # ruby 2.4
|
8
|
+
gem "rspec-block_is_expected", "~> 1.0", ">= 1.0.5" # ruby 1.8.7
|