roda-token-auth 0.1.1 → 0.1.2

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: 4a2f0a5fd3e8b811a98a716e4303d61ff0a6e8e4
4
- data.tar.gz: ea373a28681c13f0cc720676192e5dbd9f9b3e6d
3
+ metadata.gz: 6a2f178d75b2e1d4f93565b315ab3b7589aac20b
4
+ data.tar.gz: fa89830b7f3624bf4856f6cfc09335ea80f306e0
5
5
  SHA512:
6
- metadata.gz: 142f7945d68ce8d3a843a4412f65849d95bd6c4e8e51ca6260864ce16bd75f48b84d36388e5158805d729019ade179e1ab56006fc9a843c2c483abcad52bae1f
7
- data.tar.gz: 98f361759ffa36708713da3a127a7d87bb738f137db45a90909b6c06839cba4c61059f6bf40f7125fc0d131b1be5b002f8f79d7a098a14356d74ea97a9cd5a03
6
+ metadata.gz: 5cda2b692f981ad528065f1c7dc43e58d1b86da3fddaabad0fec78bdbedc717b91c16d63c0971243800ad6f0f8f4d9b99ac8ea0c485a71a6c8c0a8894ef94bcf
7
+ data.tar.gz: bcbd68a8c52574f5798460784f2a66ac8ad1525b0130f621b8327bad9796d8891450da195d941eb2b78bec2e25c262e74ab04c069b33b9bcd99b11a6a0e45d9f
@@ -0,0 +1,14 @@
1
+ require: rubocop-rspec
2
+
3
+ Style/Lambda:
4
+ EnforcedStyle: literal
5
+
6
+ Style/StringLiterals:
7
+ EnforcedStyle: double_quotes
8
+
9
+ Metrics/LineLength:
10
+ Max: 120
11
+ AllowURI: true
12
+
13
+ Style/FirstHashElementLineBreak:
14
+ Enabled: true
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
+ [![Gem Version](https://badge.fury.io/rb/roda-token-auth.svg)](https://badge.fury.io/rb/roda-token-auth)
7
+ [![Build Status](https://travis-ci.org/raivil/roda-token-auth.svg?branch=master)](https://travis-ci.org/raivil/roda-token-auth)
8
+ [![Maintainability](https://api.codeclimate.com/v1/badges/c27ee51a6ea057c86ab3/maintainability)](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", "Content-Length" => "0" }
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, auth_opts[:unauthorized_headers].call(auth_opts), []]
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)
@@ -3,7 +3,7 @@
3
3
  class Roda
4
4
  module RodaPlugins
5
5
  module TokenAuth
6
- VERSION = "0.1.1".freeze
6
+ VERSION = "0.1.2".freeze
7
7
  end
8
8
  end
9
9
  end
@@ -35,4 +35,5 @@ Gem::Specification.new do |spec|
35
35
  spec.add_development_dependency "rake", "~> 10.0"
36
36
  spec.add_development_dependency "rspec", "~> 3.0"
37
37
  spec.add_development_dependency "rack-test", "0.7.0"
38
+ spec.add_development_dependency "json", "~> 2.0"
38
39
  end
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.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 00:00:00.000000000 Z
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