taskinator_ui 0.1.0 → 0.1.1

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
  SHA256:
3
- metadata.gz: 97f775b342af29cff581b4367d7ddd723a9efac20a7af5ddbbbb465d47b5a99f
4
- data.tar.gz: ce586f511c32214c706964b941ad3d0e3d14bb2fd90ab4c164610d90b71c0e00
3
+ metadata.gz: 399be4dfe6be3c754c86c5422a8cf22030d57999f3e88f7091373ea1181eabad
4
+ data.tar.gz: 50d621fc5a417a3311024e40bcfcaf9e9826299bf051f1a6f188a2f30ed10415
5
5
  SHA512:
6
- metadata.gz: 4dc61c2f71155ced014d843addd3eba0c6037778f6d1bc61f16156fa0aa052982c771f9774ffb968735744c9e6052049b2497cf42318537bdfc8c2eb474a2bf2
7
- data.tar.gz: a858248ed643e25f74e53e4bda2a34833512c3b79cc9b17e1ad5420d35f46c40f326b3304fe95af2ae4c463412d36f4d76180ebf4b965a4ce3b7981a559b9e6d
6
+ metadata.gz: c3adbaf6c711056198c45609b9aa65320c6ebc1084773c3c340f78adbee269605ff6172c245b66483e5edee0b9374896dfb2deea012df739b4dfb618ba0e15e3
7
+ data.tar.gz: 1d2e67d5d650afe00cfdea0d0af282ccb0ac731ba67f99b509deae7439931647d4305f0ecab06a8f2db337e0fa4ab1b001aa0e42981a5fb4e81985c2a0c0e301
data/README.md CHANGED
@@ -26,6 +26,22 @@ mount TaskinatorUi::Engine, at: '/taskinator'
26
26
 
27
27
  Run `rails server` and navigate to `http://localhost:3000/taskinator/`
28
28
 
29
+ ## HTTP Basic Auth
30
+
31
+ To add basic auth add the line into initializer:
32
+
33
+ ```ruby
34
+ # config/initializers/taskinator.rb
35
+
36
+ TaskinatorUi.http_basic_auth = ->(user, password) { user == 'username' && password == 'password' }
37
+ ```
38
+
39
+ You can use your database if needed:
40
+
41
+ ```ruby
42
+ TaskinatorUi.http_basic_auth = ->(email, password) { User.admin.find_by(email: email)&.authenticate(password) }
43
+ ```
44
+
29
45
  ## Known issues
30
46
 
31
47
  If you use Rails in API only mode it can happen that you have `Rack::MethodOverride` middleware disabled.
@@ -1,4 +1,11 @@
1
1
  module TaskinatorUi
2
2
  class ApplicationController < ActionController::Base
3
+ before_action :authenticate, if: -> { TaskinatorUi.http_basic_auth }
4
+
5
+ protected
6
+
7
+ def authenticate
8
+ authenticate_or_request_with_http_basic(nil, nil, &TaskinatorUi.http_basic_auth)
9
+ end
3
10
  end
4
11
  end
@@ -1,3 +1,3 @@
1
1
  module TaskinatorUi
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/lib/taskinator_ui.rb CHANGED
@@ -2,5 +2,5 @@ require "taskinator_ui/version"
2
2
  require "taskinator_ui/engine"
3
3
 
4
4
  module TaskinatorUi
5
- # Your code goes here...
5
+ cattr_accessor :http_basic_auth
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: taskinator_ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bogdan Guban
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-24 00:00:00.000000000 Z
11
+ date: 2023-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails