Sha256: 48bc006c46ffbec052098571bd8677721ce50b290efd839008e1e83f8676dec5

Contents?: true

Size: 638 Bytes

Versions: 2

Compression:

Stored size: 638 Bytes

Contents

module Gollum::Auth
  class Request < Rack::Request
    WRITE_PATH_RE = %r{
      ^/
      (gollum/)? # This path prefix was introduced in Gollum 5
      (create/|edit/|delete/|rename/|revert/|uploadFile$|upload_file$)
    }x

    def requires_authentication?(allow_unauthenticated_readonly)
      !allow_unauthenticated_readonly || is_write_path?
    end

    def store_author_in_session(user)
      session['gollum.author'] = { name: user.name, email: user.email }
    end

    private

    # Returns true if path is a write path that would change the wiki.
    def is_write_path?
      !!(path_info =~ WRITE_PATH_RE)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gollum-auth-0.7.1 lib/gollum/auth/request.rb
gollum-auth-0.7.0 lib/gollum/auth/request.rb