roda-token-auth 0.1.1 → 0.1.2
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 +4 -4
- data/.rubocop.yml +14 -0
- data/README.md +4 -0
- data/lib/roda/plugins/token_auth.rb +8 -2
- data/lib/roda/plugins/token_auth/version.rb +1 -1
- data/roda-token-auth.gemspec +1 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a2f178d75b2e1d4f93565b315ab3b7589aac20b
|
4
|
+
data.tar.gz: fa89830b7f3624bf4856f6cfc09335ea80f306e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5cda2b692f981ad528065f1c7dc43e58d1b86da3fddaabad0fec78bdbedc717b91c16d63c0971243800ad6f0f8f4d9b99ac8ea0c485a71a6c8c0a8894ef94bcf
|
7
|
+
data.tar.gz: bcbd68a8c52574f5798460784f2a66ac8ad1525b0130f621b8327bad9796d8891450da195d941eb2b78bec2e25c262e74ab04c069b33b9bcd99b11a6a0e45d9f
|
data/.rubocop.yml
ADDED
data/README.md
CHANGED
@@ -3,6 +3,10 @@
|
|
3
3
|
Adds token authentication to Roda.
|
4
4
|
Based on [Roda Basic Auth](https://github.com/badosu/roda-basic-auth)
|
5
5
|
|
6
|
+
[](https://badge.fury.io/rb/roda-token-auth)
|
7
|
+
[](https://travis-ci.org/raivil/roda-token-auth)
|
8
|
+
[](https://codeclimate.com/github/raivil/roda-token-auth/maintainability)
|
9
|
+
|
6
10
|
## Installation
|
7
11
|
|
8
12
|
Add this line to your application's Gemfile:
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require "roda"
|
3
3
|
require "roda/plugins/token_auth/version"
|
4
|
+
require "json"
|
4
5
|
|
5
6
|
module Roda::RodaPlugins
|
6
7
|
module TokenAuth
|
@@ -8,7 +9,10 @@ module Roda::RodaPlugins
|
|
8
9
|
token_variable: "X-Token",
|
9
10
|
secret_variable: "X-Secret",
|
10
11
|
unauthorized_headers: proc do |_opts|
|
11
|
-
{ "Content-Type" => "application/json"
|
12
|
+
{ "Content-Type" => "application/json" }
|
13
|
+
end,
|
14
|
+
unauthorized_body: proc do |_opts|
|
15
|
+
{ errors: "Invalid Credentials", success: false}
|
12
16
|
end
|
13
17
|
}.freeze
|
14
18
|
|
@@ -28,7 +32,9 @@ module Roda::RodaPlugins
|
|
28
32
|
auth_secret = header_variable(auth_opts, :secret_variable)
|
29
33
|
return if authenticator.call(auth_token, auth_secret)
|
30
34
|
auth_opts[:unauthorized]&.call(self)
|
31
|
-
halt [401,
|
35
|
+
halt [401,
|
36
|
+
auth_opts[:unauthorized_headers].call(auth_opts),
|
37
|
+
[auth_opts[:unauthorized_body].call(auth_opts).to_json]]
|
32
38
|
end
|
33
39
|
|
34
40
|
def header_variable(auth_opts, variable_name)
|
data/roda-token-auth.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roda-token-auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ronaldo Raivil
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: roda
|
@@ -86,6 +86,20 @@ dependencies:
|
|
86
86
|
- - '='
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: 0.7.0
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: json
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '2.0'
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '2.0'
|
89
103
|
description: Plugin that adds token authentication methods to Roda
|
90
104
|
email:
|
91
105
|
- raivil@gmail.com
|
@@ -95,6 +109,7 @@ extra_rdoc_files: []
|
|
95
109
|
files:
|
96
110
|
- ".gitignore"
|
97
111
|
- ".rspec"
|
112
|
+
- ".rubocop.yml"
|
98
113
|
- ".travis.yml"
|
99
114
|
- Gemfile
|
100
115
|
- LICENSE.txt
|