DMAO-WardenJWT 0.2.0 → 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: 9775a6a050d93f11776108149cca585c5c84ccdf
4
- data.tar.gz: 172829a613241f61b7db2ee66b61aa226a4b8562
3
+ metadata.gz: 2a14436fd64a92c2d7974536611ef7d32f80c4e6
4
+ data.tar.gz: 2b70e9034bdce68159aae057aaf500b785886484
5
5
  SHA512:
6
- metadata.gz: 7cb8db6251637ab18d38be8b82cdc3171556b9ffc0b212593197cdd75cf1cf9970f83fb1f379b3f72608ea69f3996f5ec395ebf4e5139fe10c48d2adfbf3cb1a
7
- data.tar.gz: b3fa6c1a414c2f5da80caeac21f31270cdeb83c877fa07e0fd703927226eacc38de7b43af1447498db83f6ca37706bf5fb06e9364275961696a4868fac0e5755
6
+ metadata.gz: d7bb07942951266b14b81319f8a31f95456a1e2a138ea4868477268e9d14bc07b8b06c13ef1a06599a268525baaef1b4456ec5cfd9bd6dc24f32c00578cc99b2
7
+ data.tar.gz: 6c296c180c02e55f686f0e620e2860da4e433afd3f5c1aa351c87694a6f1c29f65ebd596043f837b7901fe343e15bcf53b1382d0c43e12df3db82eb3d894f5ee
data/README.md CHANGED
@@ -1,15 +1,15 @@
1
- # WardenJWT
1
+ # DMAO-WardenJWT
2
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/WardenJWT`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Warden Strategy for DMA Online JWT Authentication. Checks for a JWT (JSON Web Token) in either the Authorization header as a Bearer token or the get parameters of the request.
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ On successful authentication it returns an instance of DMAO::WardenJWT::User which has attributes and methods for checking the users institution as well as authenticated roles.
6
6
 
7
7
  ## Installation
8
8
 
9
9
  Add this line to your application's Gemfile:
10
10
 
11
11
  ```ruby
12
- gem 'WardenJWT'
12
+ gem 'DMAO-WardenJWT'
13
13
  ```
14
14
 
15
15
  And then execute:
@@ -18,11 +18,35 @@ And then execute:
18
18
 
19
19
  Or install it yourself as:
20
20
 
21
- $ gem install WardenJWT
21
+ $ gem install Bundle-WardenJWT
22
22
 
23
23
  ## Usage
24
24
 
25
- TODO: Write usage instructions here
25
+ DMAO-WardenJWT requires the following environment variables to be set, this can be done using the [dotenv gem](https://rubygems.org/gems/dotenv).
26
+
27
+ | Environment Variable | Description |
28
+ | --- | --- |
29
+ | JWT_VERIFY_ISS | Boolean for whether to verify the token issuer (false allows for jwt_issuer to be nil) |
30
+ | JWT_VERIFY_AUD | Boolean for whether to verify the token audience (false allows for jwt_audience to be nil) |
31
+ | JWT_VERIFY_IAT | Boolean for whether to verify the issued at timestamp of the token |
32
+ | JWT_SECRET | The secret used to verify the integrity of the JWT (required) |
33
+ | JWT_ISSUER | The issuer of the JWT (required) |
34
+ | JWT_AUDIENCE | The audience for the JWT (required) |
35
+ | JWT_CUSTOM_CLAIMS_ATTRIBUTE | The name of the claim within the JWT to extract as the DMA Online custom claims (`dmao` is a sensible default) |
36
+
37
+ ### Failure App
38
+
39
+ **DMAO-WardenJWT** does not define a failure app. Handling authentication failure should be handled within the service/application using this.
40
+
41
+ ### Rails Usage
42
+
43
+ After including the gem add the following to `config/application.rb`. This is correct for using with Rails 5 when in API mode.
44
+
45
+ ```ruby
46
+ config.middleware.insert_after Rack::ETag, Warden::Manager do |manager|
47
+ manager.default_strategies :jwt
48
+ end
49
+ ```
26
50
 
27
51
  ## Development
28
52
 
@@ -32,10 +56,9 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
32
56
 
33
57
  ## Contributing
34
58
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/WardenJWT.
59
+ Bug reports and pull requests are welcome on GitHub at https://github.com/lulibrary/DMAO-WardenJWT.
36
60
 
37
61
 
38
62
  ## License
39
63
 
40
64
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
-
@@ -23,7 +23,7 @@ module DMAO
23
23
 
24
24
  def bearer_token
25
25
  pattern = /^Bearer /
26
- header = request.get_header('HTTP_AUTHORIZATION') # <= env
26
+ header = request.env['HTTP_AUTHORIZATION'] # <= env
27
27
  header.gsub(pattern, '') if header && header.match(pattern)
28
28
  end
29
29
 
@@ -1,5 +1,5 @@
1
1
  module DMAO
2
2
  module WardenJWT
3
- VERSION = "0.2.0"
3
+ VERSION = "0.3.0"
4
4
  end
5
- end
5
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: DMAO-WardenJWT
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Robinson