Sha256: 1be1376e0c43a611845ce82771eade49d7db429e0c775048c4bf6e508f061d6a
Contents?: true
Size: 1.25 KB
Versions: 23
Compression:
Stored size: 1.25 KB
Contents
# frozen_string_literal: true require 'singleton' module SimpleAuthenticationPlugin include Praxis::PluginConcern class Plugin < Praxis::Plugin include Singleton def initialize @options = { config_file: 'config/authentication.yml' } super 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 Plugin.authenticate(controller.request) if action.authentication_required 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
23 entries across 23 versions & 1 rubygems