class Gollum::Auth::App
Public Class Methods
new(app, users, opts = { })
click to toggle source
# File lib/gollum/auth.rb, line 15 def initialize(app, users, opts = { }) @app = app users.each { |args| User.new(args).save! } @opts = { allow_unauthenticated_readonly: false }.merge(opts) end
Public Instance Methods
call(env)
click to toggle source
# File lib/gollum/auth.rb, line 21 def call(env) request = Request.new(env) if request.requires_authentication?(@opts[:allow_unauthenticated_readonly]) auth = Rack::Auth::Basic::Request.new(env) if auth.provided? && auth.basic? && user = User.find_by_credentials(auth.credentials) request.store_author_in_session(user) else return not_authorized end end @app.call(env) end