Sha256: 667d606bbe4b79eecbbc2df22e9f84ca18bc559775ceba523cdeed8c5632f7fb
Contents?: true
Size: 1.23 KB
Versions: 36
Compression:
Stored size: 1.23 KB
Contents
require 'singleton' module SimpleAuthenticationPlugin include Praxis::PluginConcern class Plugin < Praxis::Plugin include Singleton def initialize @options = {config_file: 'config/authentication.yml'} end def config_key :authentication end def prepare_config!(node) node.attributes do attribute :authentication_default, Attributor::Boolean, default: false end end def self.authenticate(request) request.current_user == 'guest' end end module Request def current_user 'guest' end end module Controller extend ActiveSupport::Concern included do before :action do |controller| action = controller.request.action if action.authentication_required Plugin.authenticate(controller.request) end end end end module ActionDefinition extend ActiveSupport::Concern included do decorate_docs do |action, docs| docs[:authentication_required] = action.authentication_required end end def requires_authentication(value) @authentication_required = value end def authentication_required @authentication_required ||= false end end end
Version data entries
36 entries across 36 versions & 1 rubygems