kanbanworkflowstimelinescrumrubyroadmapproject-planningproject-managementopenprojectangularissue-trackerifcgantt-chartganttbug-trackerboardsbcf
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
957 B
46 lines
957 B
7 years ago
|
require 'warden/basic_auth'
|
||
|
|
||
|
module OpenProject
|
||
|
module Authentication
|
||
|
module Strategies
|
||
|
module Warden
|
||
|
# Intended to be used as the last strategy in warden so that the
|
||
|
# anonymous user is returned if no other strategy applies
|
||
|
class AnonymousFallback < ::Warden::Strategies::BasicAuth
|
||
|
def self.configuration
|
||
|
@configuration ||= {}
|
||
|
end
|
||
|
|
||
|
def self.user
|
||
|
User.anonymous
|
||
|
end
|
||
|
|
||
|
def username
|
||
|
nil
|
||
|
end
|
||
|
|
||
|
def password
|
||
|
nil
|
||
|
end
|
||
|
|
||
|
##
|
||
|
# Always valid unless session based. We are using it as a fallback after all.
|
||
|
def valid?
|
||
|
!session
|
||
|
end
|
||
|
|
||
|
def authenticate_user(_username, _password)
|
||
|
self.class.user
|
||
|
end
|
||
|
|
||
|
private
|
||
|
|
||
|
def session
|
||
|
env['rack.session']
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|