okta_jwt_validation 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/.circleci/config.yml +54 -0
- data/.gitignore +13 -0
- data/.rspec +3 -0
- data/.rubocop.yml +51 -0
- data/.rubocop_todo.yml +12 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +95 -0
- data/LICENSE.txt +21 -0
- data/README.md +61 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/okta_jwt_validation.rb +8 -0
- data/lib/okta_jwt_validation/authenticate_api_request.rb +86 -0
- data/lib/okta_jwt_validation/version.rb +5 -0
- data/okta_jwt_validation.gemspec +45 -0
- metadata +189 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a12af9188edf566534a3328bf708e796b3528110
|
4
|
+
data.tar.gz: 67fe83fca35077d9b0880304590d05cf7d1484b1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5b66b2d8f42398ae3c721e1544f4333c12322074167c4c1b1531f04f56e629cecb6ef8a01505d97285651300630d8a01b8430fc81c04230bdcd421c67d5ce433
|
7
|
+
data.tar.gz: 7460302684f29ef24ef98f9bc9431de2a0421e010464ece2276b0dc5b06b2f630f879e1c973ec1063d51eb6f1222d07d6b9b9f4cdf29a1ca4591c1592cb08d73
|
@@ -0,0 +1,54 @@
|
|
1
|
+
version: 2
|
2
|
+
|
3
|
+
jobs:
|
4
|
+
build:
|
5
|
+
docker:
|
6
|
+
- image: circleci/ruby:2.5.1
|
7
|
+
|
8
|
+
working_directory: ~/repo
|
9
|
+
|
10
|
+
steps:
|
11
|
+
- checkout
|
12
|
+
|
13
|
+
# Download and cache dependencies
|
14
|
+
- restore_cache:
|
15
|
+
keys:
|
16
|
+
- v1-dependencies-{{ checksum "Gemfile.lock" }}
|
17
|
+
|
18
|
+
- run:
|
19
|
+
name: install dependencies
|
20
|
+
command: |
|
21
|
+
bundle install --jobs=4 --retry=3 --path vendor/bundle
|
22
|
+
|
23
|
+
- run:
|
24
|
+
name: Setup Code Climate test-reporter
|
25
|
+
command: |
|
26
|
+
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
27
|
+
chmod +x ./cc-test-reporter
|
28
|
+
- save_cache:
|
29
|
+
paths:
|
30
|
+
- ./vendor/bundle
|
31
|
+
key: v1-dependencies-{{ checksum "Gemfile.lock" }}
|
32
|
+
|
33
|
+
# run tests
|
34
|
+
- run:
|
35
|
+
name: run tests
|
36
|
+
command: |
|
37
|
+
./cc-test-reporter before-build
|
38
|
+
mkdir /tmp/test-results
|
39
|
+
TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"
|
40
|
+
|
41
|
+
bundle exec rspec --format progress \
|
42
|
+
--format RspecJunitFormatter \
|
43
|
+
--out /tmp/test-results/rspec.xml \
|
44
|
+
--format progress \
|
45
|
+
-- \
|
46
|
+
$TEST_FILES
|
47
|
+
./cc-test-reporter after-build --coverage-input-type simplecov --exit-code $?
|
48
|
+
|
49
|
+
# collect reports
|
50
|
+
- store_test_results:
|
51
|
+
path: /tmp/test-results
|
52
|
+
- store_artifacts:
|
53
|
+
path: /tmp/test-results
|
54
|
+
destination: test-results
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
2
|
+
|
3
|
+
Rails:
|
4
|
+
Enabled: true
|
5
|
+
AllCops:
|
6
|
+
TargetRubyVersion: 2.5.1
|
7
|
+
Exclude:
|
8
|
+
- "vendor/**/*"
|
9
|
+
- "db/schema.rb"
|
10
|
+
- "node_modules/**/*"
|
11
|
+
- bin/*
|
12
|
+
Layout/DotPosition:
|
13
|
+
Description: Checks the position of the dot in multi-line method calls.
|
14
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains
|
15
|
+
Enabled: true
|
16
|
+
EnforcedStyle: leading
|
17
|
+
SupportedStyles:
|
18
|
+
- leading
|
19
|
+
- trailing
|
20
|
+
Metrics/BlockLength:
|
21
|
+
Enabled: false
|
22
|
+
Style/AndOr:
|
23
|
+
Description: Use &&/|| instead of and/or.
|
24
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-and-or-or
|
25
|
+
Enabled: true
|
26
|
+
EnforcedStyle: conditionals
|
27
|
+
SupportedStyles:
|
28
|
+
- always
|
29
|
+
- conditionals
|
30
|
+
Style/ClassAndModuleChildren:
|
31
|
+
Enabled: true
|
32
|
+
EnforcedStyle: nested
|
33
|
+
SupportedStyles:
|
34
|
+
- compact
|
35
|
+
- nested
|
36
|
+
Style/MultilineIfModifier:
|
37
|
+
Enabled: false
|
38
|
+
Style/StringLiterals:
|
39
|
+
Description: Checks if uses of quotes match the configured preference.
|
40
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-string-literals
|
41
|
+
Enabled: true
|
42
|
+
EnforcedStyle: single_quotes
|
43
|
+
SupportedStyles:
|
44
|
+
- single_quotes
|
45
|
+
- double_quotes
|
46
|
+
Rails/DynamicFindBy:
|
47
|
+
Exclude:
|
48
|
+
- "spec/features/**/*"
|
49
|
+
Style/Documentation:
|
50
|
+
Description: Document classes and non-namespace modules.
|
51
|
+
Enabled: false
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2018-07-11 16:20:36 -0400 using RuboCop version 0.54.0.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 1
|
10
|
+
Style/Documentation:
|
11
|
+
Exclude:
|
12
|
+
- 'spec/**/*'
|
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at jfernandez@westernmilling.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
okta_jwt_validation (0.1.0)
|
5
|
+
json-jwt
|
6
|
+
jwt
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
activesupport (5.2.0)
|
12
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
13
|
+
i18n (>= 0.7, < 2)
|
14
|
+
minitest (~> 5.1)
|
15
|
+
tzinfo (~> 1.1)
|
16
|
+
aes_key_wrap (1.0.1)
|
17
|
+
ast (2.4.0)
|
18
|
+
bindata (2.4.3)
|
19
|
+
byebug (10.0.2)
|
20
|
+
coderay (1.1.2)
|
21
|
+
concurrent-ruby (1.0.5)
|
22
|
+
diff-lcs (1.3)
|
23
|
+
docile (1.3.1)
|
24
|
+
i18n (1.0.1)
|
25
|
+
concurrent-ruby (~> 1.0)
|
26
|
+
json (2.1.0)
|
27
|
+
json-jwt (1.9.4)
|
28
|
+
activesupport
|
29
|
+
aes_key_wrap
|
30
|
+
bindata
|
31
|
+
jwt (2.1.0)
|
32
|
+
method_source (0.9.0)
|
33
|
+
minitest (5.11.3)
|
34
|
+
parallel (1.12.1)
|
35
|
+
parser (2.5.1.2)
|
36
|
+
ast (~> 2.4.0)
|
37
|
+
powerpack (0.1.2)
|
38
|
+
pry (0.11.3)
|
39
|
+
coderay (~> 1.1.0)
|
40
|
+
method_source (~> 0.9.0)
|
41
|
+
pry-byebug (3.6.0)
|
42
|
+
byebug (~> 10.0)
|
43
|
+
pry (~> 0.10)
|
44
|
+
rainbow (3.0.0)
|
45
|
+
rake (10.5.0)
|
46
|
+
rspec (3.7.0)
|
47
|
+
rspec-core (~> 3.7.0)
|
48
|
+
rspec-expectations (~> 3.7.0)
|
49
|
+
rspec-mocks (~> 3.7.0)
|
50
|
+
rspec-core (3.7.1)
|
51
|
+
rspec-support (~> 3.7.0)
|
52
|
+
rspec-expectations (3.7.0)
|
53
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
54
|
+
rspec-support (~> 3.7.0)
|
55
|
+
rspec-mocks (3.7.0)
|
56
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
57
|
+
rspec-support (~> 3.7.0)
|
58
|
+
rspec-support (3.7.1)
|
59
|
+
rspec_junit_formatter (0.4.1)
|
60
|
+
rspec-core (>= 2, < 4, != 2.12.0)
|
61
|
+
rubocop (0.54.0)
|
62
|
+
parallel (~> 1.10)
|
63
|
+
parser (>= 2.5)
|
64
|
+
powerpack (~> 0.1)
|
65
|
+
rainbow (>= 2.2.2, < 4.0)
|
66
|
+
ruby-progressbar (~> 1.7)
|
67
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
68
|
+
ruby-progressbar (1.9.0)
|
69
|
+
simplecov (0.16.1)
|
70
|
+
docile (~> 1.1)
|
71
|
+
json (>= 1.8, < 3)
|
72
|
+
simplecov-html (~> 0.10.0)
|
73
|
+
simplecov-html (0.10.2)
|
74
|
+
thread_safe (0.3.6)
|
75
|
+
tzinfo (1.2.5)
|
76
|
+
thread_safe (~> 0.1)
|
77
|
+
unicode-display_width (1.4.0)
|
78
|
+
|
79
|
+
PLATFORMS
|
80
|
+
ruby
|
81
|
+
|
82
|
+
DEPENDENCIES
|
83
|
+
bundler (~> 1.16)
|
84
|
+
json-jwt
|
85
|
+
jwt
|
86
|
+
okta_jwt_validation!
|
87
|
+
pry-byebug
|
88
|
+
rake (~> 10.0)
|
89
|
+
rspec (~> 3.0)
|
90
|
+
rspec_junit_formatter
|
91
|
+
rubocop (~> 0.54.0)
|
92
|
+
simplecov
|
93
|
+
|
94
|
+
BUNDLED WITH
|
95
|
+
1.16.2
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Jose C Fernandez
|
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
|
13
|
+
all 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
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# okta_jwt_validation
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/okta_jwt_validation`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'okta_jwt_validation'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install okta_jwt_validation
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
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 tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/okta_jwt_validation. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
40
|
+
|
41
|
+
## Code of Conduct
|
42
|
+
|
43
|
+
Everyone interacting in the okta_jwt_validation project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/okta_jwt_validation/blob/master/CODE_OF_CONDUCT.md).
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
How to use:
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
token = OktaJwtValidation::AuthenticateApiRequest.new(
|
51
|
+
request: request,
|
52
|
+
okta_org: Figaro.env.OKTA_ORG,
|
53
|
+
okta_domain: Figaro.env.OKTA_DOMAIN,
|
54
|
+
okta_client_id: Figaro.env.OKTA_CLIENT_ID
|
55
|
+
).call
|
56
|
+
```
|
57
|
+
|
58
|
+
Where request is Rails ActionDispatch::Request to request a token.
|
59
|
+
|
60
|
+
The response is a signed JSON Web Signature](https://github.com/nov/json-jwt/wiki/JWS).
|
61
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "okta_jwt_validation"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json/jwt'
|
4
|
+
require 'jwt'
|
5
|
+
require 'net/http'
|
6
|
+
|
7
|
+
module OktaJwtValidation
|
8
|
+
class AuthenticateApiRequest
|
9
|
+
def initialize(options)
|
10
|
+
@request = options[:request]
|
11
|
+
@token = nil
|
12
|
+
@okta_org = options[:okta_org]
|
13
|
+
@okta_domain = options[:okta_domain]
|
14
|
+
@okta_client_id = options[:okta_client_id]
|
15
|
+
end
|
16
|
+
|
17
|
+
def call
|
18
|
+
authenticate_request
|
19
|
+
end
|
20
|
+
|
21
|
+
attr_accessor :request, :okta_org, :okta_domain, :okta_client_id
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def cache_key
|
26
|
+
'OKTA_PUBLIC_KEYS'
|
27
|
+
end
|
28
|
+
|
29
|
+
def site
|
30
|
+
"https://#{okta_org}.#{okta_domain}.com"
|
31
|
+
end
|
32
|
+
|
33
|
+
def authenticate_request
|
34
|
+
@token if token_valid?
|
35
|
+
end
|
36
|
+
|
37
|
+
def client_id
|
38
|
+
okta_client_id
|
39
|
+
end
|
40
|
+
|
41
|
+
def dirty_kid
|
42
|
+
dirty_token.last['kid']
|
43
|
+
end
|
44
|
+
|
45
|
+
def dirty_token
|
46
|
+
JWT.decode(request_token, nil, false)
|
47
|
+
end
|
48
|
+
|
49
|
+
def okta_keys
|
50
|
+
Rails.cache.fetch(cache_key, expires_in: 1.month) do
|
51
|
+
okta_keys = {}
|
52
|
+
uri = URI("#{site}/oauth2/v1/keys")
|
53
|
+
data = Net::HTTP.get(uri)
|
54
|
+
keys = JSON.parse(data)
|
55
|
+
keys['keys'].each { |k| okta_keys[k['kid']] = k.except('alg') }
|
56
|
+
okta_keys
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def parse_token
|
61
|
+
JSON::JWT.decode request_token, public_key
|
62
|
+
rescue StandardError
|
63
|
+
JSON::JWT.decode request_token, public_key(true)
|
64
|
+
end
|
65
|
+
|
66
|
+
def public_key(clear_cache = false)
|
67
|
+
Rails.cache.delete(cache_key) if clear_cache
|
68
|
+
JSON::JWK.new(okta_keys[dirty_kid])
|
69
|
+
end
|
70
|
+
|
71
|
+
def request_token
|
72
|
+
@request.headers['Authorization']
|
73
|
+
end
|
74
|
+
|
75
|
+
def token_valid?
|
76
|
+
@token = parse_token
|
77
|
+
if @token['iss'] != site ||
|
78
|
+
@token['aud'] != client_id ||
|
79
|
+
Time.strptime(@token['exp'].to_s, '%s') < Time.now.utc
|
80
|
+
return false
|
81
|
+
else
|
82
|
+
return true
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'okta_jwt_validation/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'okta_jwt_validation'
|
9
|
+
spec.version = OktaJwtValidation::VERSION
|
10
|
+
|
11
|
+
spec.authors = ['Jose C Fernandez']
|
12
|
+
spec.email = ['jfernandez@westernmilling.com']
|
13
|
+
|
14
|
+
spec.summary = 'Helper library for validating Okta jwt token.'
|
15
|
+
spec.description = 'Helper library for validating Okta jwt token.'
|
16
|
+
spec.homepage = 'https://github.com/westernmilling/okta-jwt-validation'
|
17
|
+
spec.license = 'MIT'
|
18
|
+
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org/"
|
21
|
+
else
|
22
|
+
raise 'RubyGems 2.0 or newer is required to protect against ' \
|
23
|
+
'public gem pushes.'
|
24
|
+
end
|
25
|
+
|
26
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
27
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
28
|
+
f.match(%r{^(test|spec|features)/})
|
29
|
+
end
|
30
|
+
end
|
31
|
+
spec.bindir = 'exe'
|
32
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
33
|
+
spec.require_paths = ['lib']
|
34
|
+
|
35
|
+
spec.add_dependency 'json-jwt'
|
36
|
+
spec.add_dependency 'jwt'
|
37
|
+
|
38
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
39
|
+
spec.add_development_dependency 'pry-byebug'
|
40
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
41
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
42
|
+
spec.add_development_dependency 'rspec_junit_formatter'
|
43
|
+
spec.add_development_dependency 'rubocop', '~> 0.54.0'
|
44
|
+
spec.add_development_dependency 'simplecov'
|
45
|
+
end
|
metadata
ADDED
@@ -0,0 +1,189 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: okta_jwt_validation
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jose C Fernandez
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-07-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: json-jwt
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: jwt
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.16'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.16'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry-byebug
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec_junit_formatter
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 0.54.0
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 0.54.0
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: simplecov
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
description: Helper library for validating Okta jwt token.
|
140
|
+
email:
|
141
|
+
- jfernandez@westernmilling.com
|
142
|
+
executables: []
|
143
|
+
extensions: []
|
144
|
+
extra_rdoc_files: []
|
145
|
+
files:
|
146
|
+
- ".circleci/config.yml"
|
147
|
+
- ".gitignore"
|
148
|
+
- ".rspec"
|
149
|
+
- ".rubocop.yml"
|
150
|
+
- ".rubocop_todo.yml"
|
151
|
+
- ".travis.yml"
|
152
|
+
- CODE_OF_CONDUCT.md
|
153
|
+
- Gemfile
|
154
|
+
- Gemfile.lock
|
155
|
+
- LICENSE.txt
|
156
|
+
- README.md
|
157
|
+
- Rakefile
|
158
|
+
- bin/console
|
159
|
+
- bin/setup
|
160
|
+
- lib/okta_jwt_validation.rb
|
161
|
+
- lib/okta_jwt_validation/authenticate_api_request.rb
|
162
|
+
- lib/okta_jwt_validation/version.rb
|
163
|
+
- okta_jwt_validation.gemspec
|
164
|
+
homepage: https://github.com/westernmilling/okta-jwt-validation
|
165
|
+
licenses:
|
166
|
+
- MIT
|
167
|
+
metadata:
|
168
|
+
allowed_push_host: https://rubygems.org/
|
169
|
+
post_install_message:
|
170
|
+
rdoc_options: []
|
171
|
+
require_paths:
|
172
|
+
- lib
|
173
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
174
|
+
requirements:
|
175
|
+
- - ">="
|
176
|
+
- !ruby/object:Gem::Version
|
177
|
+
version: '0'
|
178
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
179
|
+
requirements:
|
180
|
+
- - ">="
|
181
|
+
- !ruby/object:Gem::Version
|
182
|
+
version: '0'
|
183
|
+
requirements: []
|
184
|
+
rubyforge_project:
|
185
|
+
rubygems_version: 2.6.14
|
186
|
+
signing_key:
|
187
|
+
specification_version: 4
|
188
|
+
summary: Helper library for validating Okta jwt token.
|
189
|
+
test_files: []
|