doorkeeper-jwt 0.2.1 → 0.3.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
2
  SHA1:
3
- metadata.gz: b002cd43174cb7dee9362bc8a8c15bdaf090e341
4
- data.tar.gz: eec5f2cffa66c2f83662388b810ff4fb0ec14de4
3
+ metadata.gz: 64ffd893f885b14b10051ffdf40d0c7cce87dbfa
4
+ data.tar.gz: 4c18d275274d40a52694984a4cb68a9fd14b6962
5
5
  SHA512:
6
- metadata.gz: 86c9a2ad56ba7f28444ba570223555fd5e43e555091d8b2984c47b0e6b16c247c052e92458a1fa9ab5d4ad5bcd8344eb9b4a5e4dab4d54b02cde6141fa1835aa
7
- data.tar.gz: 5824759b0bfb152e7daba0273139aa0d019060c15b17eb02205235ed441c3403d15527de919d18e8567bb23431dcbd49cbe0d7181e94ee19f33ce7f314792560
6
+ metadata.gz: 9860fc149da0ca854fc47872c78b86dfbca10e09cfddc59e24c74c4edf80d8688f86a4167d5ec72b1be75ce044f1f361ccbacd1d1a790891cd4f6a966f64af5f
7
+ data.tar.gz: 6a39bc5136d5ce4dbdf72b43a006403d10c70383445ae30bd61ae0eb16dd03aa0d66b4e116872cca8c0e6cff694cb832bd24e7a669fd973ccaa210a5444438bf
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ *.gem
@@ -0,0 +1,13 @@
1
+ Metrics/BlockLength:
2
+ Exclude:
3
+ - spec/**/*
4
+
5
+ LineLength:
6
+ Exclude:
7
+ - spec/**/*
8
+
9
+ StringLiterals:
10
+ Enabled: false
11
+
12
+ Style/Documentation:
13
+ Enabled: false
@@ -1,6 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.1
4
- addons:
5
- code_climate:
6
- repo_token: a44faab4cd18aeb4898a374736ac95bbb1de26015e9f53d5c809109e11df1149
3
+ - 2.2
4
+ - 2.3
5
+ - 2.4
6
+ - 2.5
@@ -4,10 +4,20 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/).
6
6
 
7
+ ## [0.3.0] - 2018-10-01
8
+
9
+ ### Added
10
+
11
+ - Bump JWT gem version. Via [#27](https://github.com/doorkeeper-gem/doorkeeper-jwt/pull/27) by [@pacop](https://github.com/pacop/)
12
+
7
13
  ## [0.2.1] - 2017-06-07
14
+
8
15
  ### Fixed
16
+
9
17
  - The `token_headers` proc now passes `opts` like the other config methods. Fixed via #19 by @travisofthenorth.
10
18
 
11
19
  ## [0.2.0] - 2017-05-25
20
+
12
21
  ### Added
22
+
13
23
  - Added support for ["kid" (Key ID) Header Parameter](https://tools.ietf.org/html/rfc7515#section-4.1.4) @travisofthenorth. Allows custom token headers.
data/Gemfile CHANGED
@@ -4,4 +4,3 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  gem 'coveralls', require: false
7
- gem "codeclimate-test-reporter", group: :test, require: nil
data/README.md CHANGED
@@ -1,10 +1,11 @@
1
- [![Coverage Status](https://coveralls.io/repos/chriswarren/doorkeeper-jwt/badge.svg?branch=master)](https://coveralls.io/r/chriswarren/doorkeeper-jwt?branch=master)
2
- [![Build Status](https://travis-ci.org/chriswarren/doorkeeper-jwt.svg?branch=master)](https://travis-ci.org/chriswarren/doorkeeper-jwt)
3
- [![Code Climate](https://codeclimate.com/github/chriswarren/doorkeeper-jwt/badges/gpa.svg)](https://codeclimate.com/github/chriswarren/doorkeeper-jwt)
1
+ [![Coverage Status](https://coveralls.io/repos/github/doorkeeper-gem/doorkeeper-jwt/badge.svg?branch=master)](https://coveralls.io/github/doorkeeper-gem/doorkeeper-jwt?branch=master)
2
+ [![Build Status](https://travis-ci.org/doorkeeper-gem/doorkeeper-jwt.svg?branch=master)](https://travis-ci.org/doorkeeper-gem/doorkeeper-jwt)
3
+ [![Maintainability](https://api.codeclimate.com/v1/badges/ca4d81b49acabda27e0c/maintainability)](https://codeclimate.com/github/doorkeeper-gem/doorkeeper-jwt/maintainability)
4
4
 
5
5
  # Doorkeeper::JWT
6
6
 
7
- Doorkeeper JWT adds JWT token support to the Doorkeeper OAuth library. Requires Doorkeeper 2.2.0 or newer.
7
+ Doorkeeper JWT adds JWT token support to the Doorkeeper OAuth library. Confirmed to work with Doorkeeper 2.2.x - 4.x.
8
+ Untested with later versions of Doorkeeper.
8
9
 
9
10
  ```ruby
10
11
  gem 'doorkeeper'
@@ -31,7 +32,7 @@ Or install it yourself as:
31
32
  In your `doorkeeper.rb` initializer add the follow to the `Doorkeeper.configure` block:
32
33
 
33
34
  ```ruby
34
- access_token_generator "Doorkeeper::JWT"
35
+ access_token_generator '::Doorkeeper::JWT'
35
36
  ```
36
37
 
37
38
  Then add a `Doorkeeper::JWT.configure` block below the `Doorkeeper.configure` block to set your JWT preferences.
@@ -46,6 +47,10 @@ Doorkeeper::JWT.configure do
46
47
  user = User.find(opts[:resource_owner_id])
47
48
 
48
49
  {
50
+ iss: 'My App',
51
+ iat: Time.current.utc.to_i,
52
+ jti: SecureRandom.uuid, # @see JWT reserved claims - https://tools.ietf.org/html/draft-jones-json-web-token-07#page-7
53
+
49
54
  user: {
50
55
  id: user.id,
51
56
  email: user.email
@@ -68,14 +73,14 @@ Doorkeeper::JWT.configure do
68
73
  # Set the encryption secret. This would be shared with any other applications
69
74
  # that should be able to read the payload of the token.
70
75
  # Defaults to "secret"
71
- secret_key "MY-SECRET"
76
+ secret_key ENV['JWT_SECRET']
72
77
 
73
78
  # If you want to use RS* encoding specify the path to the RSA key
74
79
  # to use for signing.
75
80
  # If you specify a secret_key_path it will be used instead of secret_key
76
- secret_key_path "path/to/file.pem"
81
+ secret_key_path File.join('path', 'to', 'file.pem')
77
82
 
78
- # Specify encryption type. Supports any algorithim in
83
+ # Specify encryption type. Supports any algorithm in
79
84
  # https://github.com/progrium/ruby-jwt
80
85
  # defaults to nil
81
86
  encryption_method :hs512
@@ -84,9 +89,12 @@ end
84
89
 
85
90
  ## Development
86
91
 
87
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
92
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive
93
+ prompt that will allow you to experiment.
88
94
 
89
- 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` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
95
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update
96
+ the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the
97
+ version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
90
98
 
91
99
  ## Contributing
92
100
 
data/Rakefile CHANGED
@@ -3,5 +3,5 @@ require "rspec/core/rake_task"
3
3
 
4
4
  RSpec::Core::RakeTask.new
5
5
 
6
- task :default => :spec
7
- task :test => :spec
6
+ task default: :spec
7
+ task test: :spec
@@ -1,16 +1,15 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require 'doorkeeper-jwt/version'
5
4
 
6
5
  Gem::Specification.new do |spec|
7
6
  spec.name = "doorkeeper-jwt"
8
- spec.version = Doorkeeper::JWT::VERSION
7
+ spec.version = Doorkeeper::JWT.gem_version
9
8
  spec.authors = ["Chris Warren"]
10
9
  spec.email = ["chris@expectless.com"]
11
10
 
12
- spec.summary = %q{JWT token generator for Doorkeeper}
13
- spec.description = %q{JWT token generator extension for Doorkeeper}
11
+ spec.summary = 'JWT token generator for Doorkeeper'
12
+ spec.description = 'JWT token generator extension for Doorkeeper'
14
13
  spec.homepage = "https://github.com/chriswarren/doorkeeper-jwt"
15
14
  spec.license = "MIT"
16
15
 
@@ -19,10 +18,10 @@ Gem::Specification.new do |spec|
19
18
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
19
  spec.require_paths = ["lib"]
21
20
 
22
- spec.add_dependency "jwt", "~> 1.5.2", ">= 1.5.2"
21
+ spec.add_dependency "jwt", "~> 2.1.0", ">= 2.1.0"
23
22
 
24
23
  spec.add_development_dependency "bundler", "~> 1.8", ">= 1.8"
24
+ spec.add_development_dependency "pry", "~> 0"
25
25
  spec.add_development_dependency "rake", "~> 10.0", ">= 10.0"
26
26
  spec.add_development_dependency "rspec", "~> 3.2.0", ">= 3.2"
27
- spec.add_development_dependency "pry", "~> 0"
28
27
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "doorkeeper-jwt/version"
2
4
  require "doorkeeper-jwt/config"
3
5
  require 'jwt'
@@ -41,7 +43,7 @@ module Doorkeeper
41
43
  end
42
44
 
43
45
  def encryption_method
44
- return nil unless Doorkeeper::JWT.configuration.encryption_method
46
+ return "none" unless Doorkeeper::JWT.configuration.encryption_method
45
47
  Doorkeeper::JWT.configuration.encryption_method.to_s.upcase
46
48
  end
47
49
 
@@ -51,13 +53,13 @@ module Doorkeeper
51
53
 
52
54
  def application_secret(opts)
53
55
  if opts[:application].nil?
54
- fail "JWT `use_application_secret` is enabled but application is " \
56
+ raise "JWT `use_application_secret` is enabled but application is " \
55
57
  "nil. This can happen if `client_id` was absent in the request " \
56
58
  "params."
57
59
  end
58
60
 
59
61
  if opts[:application][:secret].nil?
60
- fail "JWT `use_application_secret` is enabled but the application " \
62
+ raise "JWT `use_application_secret` is enabled but the application " \
61
63
  "secret is nil."
62
64
  end
63
65
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Doorkeeper
2
4
  module JWT
3
5
  class MissingConfiguration < StandardError
@@ -11,7 +13,7 @@ module Doorkeeper
11
13
  end
12
14
 
13
15
  def self.configuration
14
- @config || (fail MissingConfiguration.new)
16
+ @config || (raise MissingConfiguration)
15
17
  end
16
18
 
17
19
  class Config
@@ -27,7 +29,7 @@ module Doorkeeper
27
29
 
28
30
  def use_application_secret(use_application_secret)
29
31
  @config.instance_variable_set(
30
- "@use_application_secret",
32
+ '@use_application_secret',
31
33
  use_application_secret
32
34
  )
33
35
  end
@@ -42,7 +44,8 @@ module Doorkeeper
42
44
 
43
45
  def encryption_method(encryption_method)
44
46
  @config.instance_variable_set(
45
- '@encryption_method', encryption_method)
47
+ '@encryption_method', encryption_method
48
+ )
46
49
  end
47
50
  end
48
51
 
@@ -81,17 +84,17 @@ module Doorkeeper
81
84
  Builder.instance_eval do
82
85
  define_method name do |*args, &block|
83
86
  # TODO: is builder_class option being used?
84
- value = unless attribute_builder
85
- block ? block : args.first
86
- else
87
+ value = if attribute_builder
87
88
  attribute_builder.new(&block).build
89
+ else
90
+ block || args.first
88
91
  end
89
92
 
90
93
  @config.instance_variable_set(:"@#{attribute}", value)
91
94
  end
92
95
  end
93
96
 
94
- define_method attribute do |*args|
97
+ define_method attribute do |*|
95
98
  if instance_variable_defined?(:"@#{attribute}")
96
99
  instance_variable_get(:"@#{attribute}")
97
100
  else
@@ -110,7 +113,7 @@ module Doorkeeper
110
113
  extend Option
111
114
 
112
115
  option :token_payload,
113
- default: proc{ { token: SecureRandom.method(:hex) } }
116
+ default: proc { { token: SecureRandom.method(:hex) } }
114
117
  option :token_headers, default: proc { {} }
115
118
  option :use_application_secret, default: false
116
119
  option :secret_key, default: nil
@@ -1 +1,3 @@
1
- require "doorkeeper-jwt/version"
1
+ # frozen_string_literal: true
2
+
3
+ require 'doorkeeper-jwt/version'
@@ -1,5 +1,20 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Doorkeeper
2
4
  module JWT
3
- VERSION = "0.2.1".freeze
5
+ def self.gem_version
6
+ Gem::Version.new VERSION::STRING
7
+ end
8
+
9
+ module VERSION
10
+ # Semantic versioning
11
+ MAJOR = 0
12
+ MINOR = 3
13
+ TINY = 0
14
+ PRE = nil
15
+
16
+ # Full version number
17
+ STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
18
+ end
4
19
  end
5
20
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: doorkeeper-jwt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Warren
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-06-08 00:00:00.000000000 Z
11
+ date: 2018-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jwt
@@ -16,20 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.5.2
19
+ version: 2.1.0
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 1.5.2
22
+ version: 2.1.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - "~>"
28
28
  - !ruby/object:Gem::Version
29
- version: 1.5.2
29
+ version: 2.1.0
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 1.5.2
32
+ version: 2.1.0
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: bundler
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -50,6 +50,20 @@ dependencies:
50
50
  - - ">="
51
51
  - !ruby/object:Gem::Version
52
52
  version: '1.8'
53
+ - !ruby/object:Gem::Dependency
54
+ name: pry
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ type: :development
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
53
67
  - !ruby/object:Gem::Dependency
54
68
  name: rake
55
69
  requirement: !ruby/object:Gem::Requirement
@@ -90,20 +104,6 @@ dependencies:
90
104
  - - ">="
91
105
  - !ruby/object:Gem::Version
92
106
  version: '3.2'
93
- - !ruby/object:Gem::Dependency
94
- name: pry
95
- requirement: !ruby/object:Gem::Requirement
96
- requirements:
97
- - - "~>"
98
- - !ruby/object:Gem::Version
99
- version: '0'
100
- type: :development
101
- prerelease: false
102
- version_requirements: !ruby/object:Gem::Requirement
103
- requirements:
104
- - - "~>"
105
- - !ruby/object:Gem::Version
106
- version: '0'
107
107
  description: JWT token generator extension for Doorkeeper
108
108
  email:
109
109
  - chris@expectless.com
@@ -113,6 +113,7 @@ extra_rdoc_files: []
113
113
  files:
114
114
  - ".gitignore"
115
115
  - ".rspec"
116
+ - ".rubocop.yml"
116
117
  - ".travis.yml"
117
118
  - CHANGELOG.md
118
119
  - Gemfile
@@ -146,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
147
  version: '0'
147
148
  requirements: []
148
149
  rubyforge_project:
149
- rubygems_version: 2.6.4
150
+ rubygems_version: 2.6.11
150
151
  signing_key:
151
152
  specification_version: 4
152
153
  summary: JWT token generator for Doorkeeper