credible 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -0
- data/Rakefile +5 -0
- data/app/controllers/credible/authentication/sessions_controller.rb +6 -1
- data/config/initializers/warden.rb +8 -5
- data/lib/credible/version.rb +1 -1
- metadata +30 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05b3dba3b165af862258747b7e148aee774dee9cc216dc74e1b4078508babe09
|
4
|
+
data.tar.gz: c2ff97929becec3437a9158715d8e4b6e81d4dbed5f15777c4f6a3e7719b3b5b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e95298a28975a795780892884d7948c425507d0ba66decea3ed61b9f3ecc4497ca61cbc7db218f7c75739a7cb9aa4ee4724207c8d5929be5d77c21dc825873d
|
7
|
+
data.tar.gz: 2cca460759ddb220a910cbb67fc3f29c5b5e0a097f44f890b2f76e49e9aa85178d20f132035f12b5c483af69f3bb4d7170155ca57cc8d0d8c13f9ee17c3bc578
|
data/README.md
CHANGED
@@ -3,6 +3,9 @@
|
|
3
3
|
[![Become a Patron](https://c5.patreon.com/external/logo/become_a_patron_button.png)](https://www.patreon.com/thombruce)
|
4
4
|
|
5
5
|
[![Gem](https://img.shields.io/gem/v/credible?logo=rubygems)](https://rubygems.org/gems/credible)
|
6
|
+
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/thombruce/credible/CI?logo=github)](https://github.com/thombruce/credible/actions)
|
7
|
+
[![Codecov](https://img.shields.io/codecov/c/github/thombruce/credible?logo=codecov)](https://codecov.io/gh/thombruce/credible)
|
8
|
+
[![GitHub issues](https://img.shields.io/github/issues-raw/thombruce/credible?logo=github)](https://github.com/thombruce/credible/issues)
|
6
9
|
|
7
10
|
[![License](https://img.shields.io/badge/license-MIT-green.svg)](MIT-LICENSE)
|
8
11
|
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg)](CODE_OF_CONDUCT.md)
|
data/Rakefile
CHANGED
@@ -4,6 +4,11 @@ rescue LoadError
|
|
4
4
|
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
5
|
end
|
6
6
|
|
7
|
+
# Load Dummy App Rakefile
|
8
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
9
|
+
load 'rails/tasks/engine.rake'
|
10
|
+
# /Load Dummy App Rakefile
|
11
|
+
|
7
12
|
require 'rdoc/task'
|
8
13
|
|
9
14
|
RDoc::Task.new(:rdoc) do |rdoc|
|
@@ -1,7 +1,8 @@
|
|
1
1
|
class Credible::Authentication::SessionsController < Credible::AuthenticationController
|
2
2
|
before_action :set_session, only: [:show, :destroy]
|
3
3
|
|
4
|
-
skip_before_action :authenticate!, only: [:new, :create]
|
4
|
+
skip_before_action :authenticate!, only: [:new, :create, :fail]
|
5
|
+
skip_after_action :verify_authorized, only: [:fail]
|
5
6
|
|
6
7
|
# GET /sessions
|
7
8
|
# GET /sessions.json
|
@@ -42,6 +43,10 @@ class Credible::Authentication::SessionsController < Credible::AuthenticationCon
|
|
42
43
|
head :no_content
|
43
44
|
end
|
44
45
|
|
46
|
+
def fail
|
47
|
+
render json: {}, status: :unauthorized
|
48
|
+
end
|
49
|
+
|
45
50
|
private
|
46
51
|
# Use callbacks to share common setup or constraints between actions.
|
47
52
|
def set_session
|
@@ -1,5 +1,5 @@
|
|
1
1
|
Rails.application.config.middleware.use Warden::Manager do |config|
|
2
|
-
config.failure_app = ->(env) { SessionsController.action(:
|
2
|
+
config.failure_app = ->(env) { Credible::Authentication::SessionsController.action(:fail).call(env) }
|
3
3
|
|
4
4
|
config.default_scope = :session
|
5
5
|
|
@@ -31,8 +31,9 @@ Warden::Strategies.add(:jwt) do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
session = ::Session.find(token[0]['data']['session_id'])
|
34
|
-
|
35
|
-
|
34
|
+
success!(session)
|
35
|
+
rescue ActiveRecord::RecordNotFound
|
36
|
+
fail!('Could not authenticate')
|
36
37
|
end
|
37
38
|
|
38
39
|
def store?
|
@@ -50,8 +51,10 @@ Warden::Strategies.add(:api_token) do
|
|
50
51
|
end
|
51
52
|
|
52
53
|
def authenticate!
|
53
|
-
session = ::Session.find_by(token: env['HTTP_API_TOKEN'])
|
54
|
-
|
54
|
+
session = ::Session.find_by!(token: env['HTTP_API_TOKEN'])
|
55
|
+
success!(session)
|
56
|
+
rescue ActiveRecord::RecordNotFound
|
57
|
+
fail!('Could not authenticate')
|
55
58
|
end
|
56
59
|
|
57
60
|
def store?
|
data/lib/credible/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: credible
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thom Bruce
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-04-
|
11
|
+
date: 2020-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -86,6 +86,34 @@ dependencies:
|
|
86
86
|
- - "~>"
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: 4.0.0.beta3
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: simplecov
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: 0.17.1
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 0.17.1
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: codecov
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
89
117
|
description: Provides token-based authentication for Rails API apps.
|
90
118
|
email:
|
91
119
|
- thom@thombruce.com
|