praxis 0.11pre → 0.11

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
  SHA1:
3
- metadata.gz: 5925b03e5020e28fc79530a6991c3f030897996d
4
- data.tar.gz: f301a81c0628df629ae32e805debbb653b0c2477
3
+ metadata.gz: 7960840baedd63fd90ba742127ea630a1a89f517
4
+ data.tar.gz: 929381294a8cde6e414b7926f0fd9655e22922c8
5
5
  SHA512:
6
- metadata.gz: f573ece40063959ee3df1a11db4a36563acd44c68bc7ad70192f90bb8268501b4c128e504ba8080406037303a6fa5dbbf4a854d741843c80aae559df6b2a0f63
7
- data.tar.gz: 3adb04192e7414e607482a44f2a8f9f83618dee6b0202094ee77c77d4d46ae0dd63e5579dd55e87ed76aa6212a0a294229108d8c5bd8d8bd841de417cf73fb63
6
+ metadata.gz: dfc5dd11264658cf30725d82c8e486677891e7962482b3591d91f436d6e276fd271197a0581bff14515862fa550d14bfd83d9a8393bfd1c4c2c78491657f60fc
7
+ data.tar.gz: 3542d98aa2815c381e2a29918ededd147b259987c502aad77344f345289825005c0d4f1350febd2a26ab69578a6af0542664d7c6ee318f9cc0f26071b317395f
data/.gitignore CHANGED
@@ -8,3 +8,4 @@ _site/
8
8
  .tmp/
9
9
  node_modules/
10
10
  *.css.map
11
+ pkg
@@ -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)
@@ -1,3 +1,3 @@
1
1
  module Praxis
2
- VERSION = '0.11pre'
2
+ VERSION = '0.11'
3
3
  end
@@ -1,3 +1 @@
1
- ---
2
- :type: GlobalSessionAuthenticator
3
- :options: {}
1
+ authentication_default: false
@@ -0,0 +1,3 @@
1
+ ---
2
+ :type: GlobalSessionAuthenticator
3
+ :options: {}
@@ -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 AuthenticationPlugin, config_file: 'config/authentication.yml'
19
+ application.bootloader.use SimpleAuthenticationPlugin, config_file: 'config/authentication.yml'
20
20
  application.bootloader.use AuthorizationPlugin
21
21
 
22
22
  application.bootloader.use PraxisMapperPlugin
@@ -63,7 +63,7 @@ class GlobalSessionAuthenticator < Authenticator
63
63
  end
64
64
 
65
65
 
66
- module AuthenticationPlugin
66
+ module ComplexAuthenticationPlugin
67
67
  include Praxis::PluginConcern
68
68
 
69
69
  class Plugin < Praxis::Plugin
@@ -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.11pre
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: 1.3.1
979
+ version: '0'
978
980
  requirements: []
979
981
  rubyforge_project:
980
982
  rubygems_version: 2.2.2