Sha256: 62066af818a194a49eb81c87f01fc53472942355aa001ddb7c45fb9b49ec1ffc
Contents?: true
Size: 932 Bytes
Versions: 2
Compression:
Stored size: 932 Bytes
Contents
module Precious class EditingAuth < Sinatra::Base def initialize(app) @app = app end def call(env) @env = env # Blocks all potentially editable pages. Use EditingAuth::whitelist_pages to unblock pages. unless (env["REQUEST_METHOD"] == "GET") || App::settings.wiki_options[:allow_editing] return block unless excluded_page? end @app.call(env) end def block [403, {'Content-Type' => 'text/html', 'Content-Length' => '9'}, ['Forbidden']] end def excluded_page? return false if env["REQUEST_PATH"].nil? whitelist_pages.any? do |whitelisted_page| env["REQUEST_PATH"].include? whitelisted_page end end private # List pages paths as str that you want to whitelist. # Pages will be compared with env["REQUEST_PATH"] using String::include? method. def whitelist_pages return ["/compare/"] end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
gollum-3.1.1 | lib/gollum/editing_auth.rb |
gollum-3.1.0 | lib/gollum/editing_auth.rb |