breath 0.1.2 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b2785b5ee6dbd2e81dad460ef63f97dcfcb481e93e72d1805019c12911766e55
4
- data.tar.gz: 29c3bcfc6c28916d7a5dbf54bb9937688f008d938c2d27135219f4ec34c6dd72
3
+ metadata.gz: 1cf89b5445e113d7198d4a9a9aa4ddfc1af8a09c0faec9eb4af344ad151b2af1
4
+ data.tar.gz: 3efb2e128154bc6e7c0ecbfad3997d338f15d871f7c898d3ab943d53e7aecd91
5
5
  SHA512:
6
- metadata.gz: 6749ed6e952b1da8a7e5074f33810293c63d1e1629df7390319f6d4e28fa79948df168c25abb1cc0b5d457c30648fd427a62b089c9b40eef6df2892bb9a4a517
7
- data.tar.gz: fb538d0d914d31c9e693b64fe24bcc7d615b7c6bacb77fcb70b9c82d05b425614cb94d902fc8e8301383f3a6ea8705f2d5389895ee437489a2f5630d965b246a
6
+ metadata.gz: 1e267a0b8ec0aee65ad28e47d3c3e58daceddb9f37e019c6ea548e61906af86d413ab266c64b35a444c3bac4876c67cb27578a737984d79b8e9161dfdbc9f4d8
7
+ data.tar.gz: 1b2d1fbbb58ac30cd6e7a3dd3283ba33f807724cf962e96f1cbc1b0c228bb7fcda18854ee27a368173616fc5bb46b373ab0162e3f3e401ee4e31c32c7ff88efc
data/README.md CHANGED
@@ -1,8 +1,7 @@
1
1
  # Breath
2
- Short description and motivation.
3
-
4
- ## Usage
5
- How to use my plugin.
2
+ Rails authentication plugin with API mode.<br />
3
+ Easy introducing login, logout.<br/>
4
+ Compact features set.
6
5
 
7
6
  ## Installation
8
7
  Add this line to your application's Gemfile:
@@ -21,6 +20,101 @@ Or install it yourself as:
21
20
  $ gem install breath
22
21
  ```
23
22
 
23
+ ## Usage
24
+ ### Introduce
25
+
26
+ #### Model
27
+ If you want to introduce a authentication to `User` model.<br/>
28
+ Add these lines to `user.rb` like bellow.
29
+ ```ruby
30
+ class User < ApplicationRecord
31
+ include Breath::Model
32
+
33
+ attr_breath :email
34
+ end
35
+ ```
36
+ Here, with `attr_breath`, you need to specify the user's attribute with authentication.
37
+
38
+ #### Migration
39
+ In migration file, you need to add `password_digest`, and `remember_digest` attributes.<br/>
40
+ And if you specify the email attribute within `attr_breath`, you need to add `email` attribute in migration file.
41
+ ```ruby
42
+ class CreateUsers < ActiveRecord::Migration[7.0]
43
+ def change
44
+ create_table :users do |t|
45
+ t.string :email
46
+ t.string :password_digest
47
+ t.string :remember_digest
48
+
49
+ t.timestamps
50
+ end
51
+ end
52
+ end
53
+ ```
54
+ After these lines you added, excute `bundle exec rails db:migrate`.
55
+
56
+
57
+ #### Controller
58
+ You need to construct the directory like bellow.
59
+ ```
60
+ /app/controllers
61
+ - application_controller.rb
62
+
63
+ /users
64
+ - application_controller.rb
65
+ - sessions_controller.rb
66
+ ```
67
+
68
+ - app/contorllers/users/application_controller.rb
69
+ ```ruby
70
+ class Users::ApplicationController < ApplicationController
71
+ include Breath::ApplicationControllerHelper
72
+ before_action :authenticate!
73
+
74
+ crsf_protect true
75
+ end
76
+ ```
77
+ Here, if `csrf_protect` is `true`, CSRF protection is enabled.<br/>
78
+
79
+ - app/controllers/users/sessions_controller.rb
80
+ ```ruby
81
+ class Users::SessionsController < Users::ApplicationController
82
+ include Breath::SessionsControllerHelper
83
+ end
84
+ ```
85
+
86
+ `Breath::ApplicationControllerHelper` intoroduce the user's authorization.<br/>
87
+ `Breath::SessionsControllerHelper` introduce the actions `login`, and `logout`.
88
+
89
+ After you added these lines, show `bundle exec rails routes` command.<br/>
90
+ You can see these routes are added.
91
+ ```
92
+ GET /users/login
93
+ POST /users/login
94
+ DELETE /users/logout
95
+ ```
96
+
97
+ Then, you don't need write the codes to introduce authorizations.
98
+
99
+ #### Config
100
+ This plugin need cookie, and you can configure the cookie expires like bellow.<br/>
101
+ ```ruby
102
+ module YourApp
103
+ class Application < Rails::Application
104
+ ...
105
+
106
+ config.breath_expires = 3.days
107
+ end
108
+ end
109
+ ```
110
+ If you don't configure this, cookie is set permanently.
111
+
112
+ #### Last Work
113
+ You need to create view side.<br/>
114
+ In view side, you have remaining works.<br/>
115
+ if you `csrf_protect true`, you need to introduce `withCredentials: true` option in client side.<br/>
116
+ And, write csrf token into the cookie with `csrf_token` key.
117
+
24
118
  ## Contributing
25
119
  Contribution directions go here.
26
120
 
@@ -44,7 +44,7 @@ module Breath
44
44
  end
45
45
 
46
46
  define_method :sessions_params do
47
- params.require(:sessions).permit(target_class.auth_attribute.to_sym, :password, :password_confirmation)
47
+ params.require(:sessions).permit(target_class.auth_attribute.to_sym, :password)
48
48
  end
49
49
  end
50
50
 
@@ -1,3 +1,3 @@
1
1
  module Breath
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: breath
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - testCodeV01