praxis 0.11pre → 0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/lib/praxis/bootloader_stages/plugin_config_load.rb +2 -1
- data/lib/praxis/version.rb +1 -1
- data/spec/spec_app/config/authentication.yml +1 -3
- data/spec/spec_app/config/complex_authentication.yml +3 -0
- data/spec/spec_app/config/environment.rb +1 -1
- data/spec/support/{spec_authentication_plugin.rb → spec_complex_authentication_plugin.rb} +1 -1
- data/spec/support/spec_simple_authentication_plugin.rb +69 -0
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7960840baedd63fd90ba742127ea630a1a89f517
|
4
|
+
data.tar.gz: 929381294a8cde6e414b7926f0fd9655e22922c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dfc5dd11264658cf30725d82c8e486677891e7962482b3591d91f436d6e276fd271197a0581bff14515862fa550d14bfd83d9a8393bfd1c4c2c78491657f60fc
|
7
|
+
data.tar.gz: 3542d98aa2815c381e2a29918ededd147b259987c502aad77344f345289825005c0d4f1350febd2a26ab69578a6af0542664d7c6ee318f9cc0f26071b317395f
|
data/.gitignore
CHANGED
@@ -4,8 +4,9 @@ module Praxis
|
|
4
4
|
|
5
5
|
def execute
|
6
6
|
application.plugins.each do |config_key, plugin|
|
7
|
+
context = [plugin.class.name]
|
7
8
|
value = plugin.load_config!
|
8
|
-
object = plugin.config_attribute.load(value)
|
9
|
+
object = plugin.config_attribute.load(value, context)
|
9
10
|
|
10
11
|
if object
|
11
12
|
application.config.send("#{config_key}=", object)
|
data/lib/praxis/version.rb
CHANGED
@@ -16,7 +16,7 @@ Praxis::Application.configure do |application|
|
|
16
16
|
|
17
17
|
application.middleware SetHeader, 'Spec-Middleware', 'used'
|
18
18
|
|
19
|
-
application.bootloader.use
|
19
|
+
application.bootloader.use SimpleAuthenticationPlugin, config_file: 'config/authentication.yml'
|
20
20
|
application.bootloader.use AuthorizationPlugin
|
21
21
|
|
22
22
|
application.bootloader.use PraxisMapperPlugin
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
|
3
|
+
module SimpleAuthenticationPlugin
|
4
|
+
include Praxis::PluginConcern
|
5
|
+
|
6
|
+
class Plugin < Praxis::Plugin
|
7
|
+
include Singleton
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@options = {config_file: 'config/authentication.yml'}
|
11
|
+
end
|
12
|
+
|
13
|
+
def config_key
|
14
|
+
:authentication
|
15
|
+
end
|
16
|
+
|
17
|
+
def prepare_config!(node)
|
18
|
+
node.attributes do
|
19
|
+
attribute :authentication_default, Attributor::Boolean, default: false
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.authenticate(request)
|
24
|
+
request.current_user == 'guest'
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
module Request
|
31
|
+
def current_user
|
32
|
+
'guest'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
module Controller
|
37
|
+
extend ActiveSupport::Concern
|
38
|
+
|
39
|
+
included do
|
40
|
+
before :action do |controller|
|
41
|
+
action = controller.request.action
|
42
|
+
if action.authentication_required
|
43
|
+
Plugin.authenticate(controller.request)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
module ActionDefinition
|
52
|
+
extend ActiveSupport::Concern
|
53
|
+
|
54
|
+
included do
|
55
|
+
decorate_docs do |action, docs|
|
56
|
+
docs[:authentication_required] = action.authentication_required
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def requires_authentication(value)
|
61
|
+
@authentication_required = value
|
62
|
+
end
|
63
|
+
|
64
|
+
def authentication_required
|
65
|
+
@authentication_required ||= false
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: praxis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.11'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josep M. Blanquer
|
@@ -914,6 +914,7 @@ files:
|
|
914
914
|
- spec/spec_app/config/active_record.yml
|
915
915
|
- spec/spec_app/config/authentication.yml
|
916
916
|
- spec/spec_app/config/authorization.yml
|
917
|
+
- spec/spec_app/config/complex_authentication.yml
|
917
918
|
- spec/spec_app/config/environment.rb
|
918
919
|
- spec/spec_app/config/praxis_mapper.yml
|
919
920
|
- spec/spec_app/config/sequel_model.yml
|
@@ -926,11 +927,12 @@ files:
|
|
926
927
|
- spec/spec_app/design/resources/instances.rb
|
927
928
|
- spec/spec_app/design/resources/volumes.rb
|
928
929
|
- spec/spec_helper.rb
|
929
|
-
- spec/support/spec_authentication_plugin.rb
|
930
930
|
- spec/support/spec_authorization_plugin.rb
|
931
|
+
- spec/support/spec_complex_authentication_plugin.rb
|
931
932
|
- spec/support/spec_media_types.rb
|
932
933
|
- spec/support/spec_praxis_mapper_plugin.rb
|
933
934
|
- spec/support/spec_resource_definitions.rb
|
935
|
+
- spec/support/spec_simple_authentication_plugin.rb
|
934
936
|
- tasks/loader.thor
|
935
937
|
- tasks/thor/app.rb
|
936
938
|
- tasks/thor/example.rb
|
@@ -972,9 +974,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
972
974
|
version: '2.1'
|
973
975
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
974
976
|
requirements:
|
975
|
-
- - "
|
977
|
+
- - ">="
|
976
978
|
- !ruby/object:Gem::Version
|
977
|
-
version:
|
979
|
+
version: '0'
|
978
980
|
requirements: []
|
979
981
|
rubyforge_project:
|
980
982
|
rubygems_version: 2.2.2
|