tiny_auth 1.0.0 → 2.0.0
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 +5 -5
- data/README.md +2 -2
- data/lib/tiny_auth/controller.rb +4 -7
- data/lib/tiny_auth/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ff3ff4ff25d9895b64f12d3e506d3c4ebba61c5c0ba702afc37501aeb13dc956
|
4
|
+
data.tar.gz: 6f71e8f393807eb1b5ab944d720982a7b14e4cbb43a00f2ede0f822ad8cb85cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8d987c6ca4ef3387d245a9f4e6a263729a928839466617b227db3592d96ffce8605513fbf78f63d33802de18712c36a97b04f8961570a7fb3e57c45e2101341
|
7
|
+
data.tar.gz: 72c2cee4eb4bc47dbe50dfa55473d3ae3be6eca231ebbd5581d000c633dfffe204c79493f9171a51087cffa419135ef3392ebe09416623b42c70a569e8787445
|
data/README.md
CHANGED
@@ -56,9 +56,9 @@ Oh, and you can add authentication to your controllers:
|
|
56
56
|
|
57
57
|
```ruby
|
58
58
|
class ApplicationController < ActionController::Base
|
59
|
-
|
59
|
+
include TinyAuth::Controller.new(model: User)
|
60
60
|
|
61
|
-
|
61
|
+
before_action :authenticate_user
|
62
62
|
|
63
63
|
def index
|
64
64
|
if user_signed_in?
|
data/lib/tiny_auth/controller.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require "active_support/core_ext/object/blank"
|
2
2
|
|
3
3
|
module TinyAuth
|
4
|
-
|
4
|
+
class Controller < Module
|
5
5
|
# Extract a token from a request
|
6
6
|
# @param request [ActionDispatch::HTTP::Request]
|
7
7
|
# @return [String,nil]
|
@@ -15,13 +15,12 @@ module TinyAuth
|
|
15
15
|
# resource.
|
16
16
|
# @param model [ActiveRecord::Base]
|
17
17
|
# @param name [Symbol] Used to define methods like `current_user`
|
18
|
-
# @param options [Hash] Additional arguments for `before_action`
|
19
18
|
#
|
20
19
|
# @example
|
21
20
|
# class ApplicationController < ActionController::Base
|
22
|
-
#
|
21
|
+
# include TinyAuth::Controller.new(model: User)
|
23
22
|
#
|
24
|
-
#
|
23
|
+
# before_action :authenticate_user
|
25
24
|
#
|
26
25
|
# def index
|
27
26
|
# if user_signed_in?
|
@@ -31,7 +30,7 @@ module TinyAuth
|
|
31
30
|
# end
|
32
31
|
# end
|
33
32
|
# end
|
34
|
-
def
|
33
|
+
def initialize(model:, name: model.model_name.singular)
|
35
34
|
authenticate = :"authenticate_#{name}"
|
36
35
|
current = :"current_#{name}"
|
37
36
|
current_ivar = :"@current_#{name}"
|
@@ -51,8 +50,6 @@ module TinyAuth
|
|
51
50
|
instance_variable_set(current_ivar, resource)
|
52
51
|
end
|
53
52
|
end
|
54
|
-
|
55
|
-
before_action(authenticate, **options)
|
56
53
|
end
|
57
54
|
end
|
58
55
|
end
|
data/lib/tiny_auth/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tiny_auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ray Zane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -164,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
164
164
|
version: '0'
|
165
165
|
requirements: []
|
166
166
|
rubyforge_project:
|
167
|
-
rubygems_version: 2.6
|
167
|
+
rubygems_version: 2.7.6
|
168
168
|
signing_key:
|
169
169
|
specification_version: 4
|
170
170
|
summary: Bare-minimum authentication for APIs
|