calib-rails 0.1.8 → 0.1.9

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: 2b835fdf877c7f3170cbd2ffd0e04e7307122e2c1da9dbb84d8a959b42fb0e45
4
- data.tar.gz: 7658a46b51fb03b637c7563d8579956af53c7d511897b21ade25b7f27b989a11
3
+ metadata.gz: 3c136ae28f6cd9225817e20d584b8fe3a10c2eeb94fb0954cb0e5c35203f361b
4
+ data.tar.gz: c355b4cba03b6b191d0cbf0a47e0830cb09a9c11e7fdfbf1428bb8b800311474
5
5
  SHA512:
6
- metadata.gz: 2c85811ffbb49bb116d008c560947dcc54173849183996bb389ce0109358dcd89cd4448d946175ee0c6b7d52bd5f779e3fd3479b4d33a96fc741e328ac9a10a0
7
- data.tar.gz: 2625dd135e9963f844cf2bf0dfe702732f16e8f5f4ef6f503451712207cb267c699acd2cf2b8631f941dfadd06eb314fac38bbef2e5adf81a2b6aece504f33dd
6
+ metadata.gz: b327099d26cef807af1c22101dd7600c36c9ccd1469e79b2c382dc9024c3f9e1c5a611980f9cecac1bdfad141272a3db7344222da71d04a019ba40724ad95df2
7
+ data.tar.gz: 6f7adea3885ab9dc94ad99bd8b7ab83bd7037259a66af3d1b336738c33aaa7bb0ce83131afabdd3913bcd470095db215ad261568d7bf9603bb3d04b71d959b17
data/README.md CHANGED
@@ -1,8 +1,11 @@
1
1
  # Calib::Rails
2
- Short description and motivation.
2
+ Calib::Rails is modules of something tips for Rails.
3
3
 
4
4
  ## Usage
5
- How to use my plugin.
5
+ Please read rdocs.
6
+
7
+ - [Calib::Controllers::BasicAuth](http://www.rubydoc.info/gems/calib-rails/Calib/Controllers/BasicAuth)
8
+ - [Calib::Devise::FriendlyForwardable](http://www.rubydoc.info/gems/calib-rails/Calib/Devise/FriendlyForwardable)
6
9
 
7
10
  ## Installation
8
11
  Add this line to your application's Gemfile:
@@ -21,8 +24,5 @@ Or install it yourself as:
21
24
  $ gem install calib-rails
22
25
  ```
23
26
 
24
- ## Contributing
25
- Contribution directions go here.
26
-
27
27
  ## License
28
28
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -1,40 +1,45 @@
1
+ # == A Module for Basic Authentication
2
+ # authenticated status stored in session.
3
+ # avoid frequently logging in
4
+ #
1
5
  # [usage]
2
- # include Calib::Controller::BasicAuth
6
+ # class ApplicationController < ActionController::Base
7
+ # include Calib::Controllers::BasicAuth
8
+ # basic_auth(user: 'myuser', pass: 'secret')
9
+ # ...
10
+ # end
11
+ #
3
12
  # basic_auth # read ENV['BASIC_AUTH_USER'] and ENV['BASIC_AUTH_PASS']
4
13
  # basic_auth(user: 'myuser', pass: 'secret') # standard
5
14
  #
6
15
  # basic_auth(user: 'myuser', pass: 'secret') do
7
16
  # request.domain != 'localhost' # localhost is unblocked domain.
8
17
  # end
9
- module Calib
10
- module Controllers
11
- module BasicAuth
12
- extend ActiveSupport::Concern
18
+ module Calib::Controllers::BasicAuth
19
+ extend ActiveSupport::Concern
13
20
 
14
- included do
15
- class_attribute :basic_auth_user, :basic_auth_pass, :basic_auth_session_key, :basic_auth_block
21
+ included do
22
+ class_attribute :basic_auth_user, :basic_auth_pass, :basic_auth_session_key, :basic_auth_block
16
23
 
17
- def self.basic_auth(user: ENV['BASIC_AUTH_USER'], password: ENV['BASIC_AUTH_PASS'], key: :basic_auth, &block)
18
- self.basic_auth_user = user
19
- self.basic_auth_pass = password
20
- self.basic_auth_session_key = key
21
- self.basic_auth_block = block
22
- end
24
+ def self.basic_auth(user: ENV['BASIC_AUTH_USER'], password: ENV['BASIC_AUTH_PASS'], key: :basic_auth, &block)
25
+ self.basic_auth_user = user
26
+ self.basic_auth_pass = password
27
+ self.basic_auth_session_key = key
28
+ self.basic_auth_block = block
29
+ end
23
30
 
24
- before_action -> {
25
- return if self.class.basic_auth_user.blank?
26
- return if session[self.class.basic_auth_session_key].present?
27
- return if self.class.basic_auth_block.present? && !self.class.basic_auth_block.call(request)
31
+ before_action -> {
32
+ return if self.class.basic_auth_user.blank?
33
+ return if session[self.class.basic_auth_session_key].present?
34
+ return if self.class.basic_auth_block.present? && !self.class.basic_auth_block.call(request)
28
35
 
29
- authenticate_or_request_with_http_basic do |user, pass|
30
- if user == self.class.basic_auth_user && pass == self.class.basic_auth_pass
31
- session[self.class.basic_auth_session_key] = true
32
- return true
33
- end
34
- false
35
- end
36
- }
37
- end
38
- end
36
+ authenticate_or_request_with_http_basic do |user, pass|
37
+ if user == self.class.basic_auth_user && pass == self.class.basic_auth_pass
38
+ session[self.class.basic_auth_session_key] = true
39
+ return true
40
+ end
41
+ false
42
+ end
43
+ }
39
44
  end
40
45
  end
@@ -1,5 +1,5 @@
1
1
  module Calib
2
2
  module Rails
3
- VERSION = '0.1.8'
3
+ VERSION = '0.1.9'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: calib-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - ms2sato