Sha256: 41a6da2539c163b29a8368cbf3a0458854383b37119736330eaa64a593147cfc
Contents?: true
Size: 1.52 KB
Versions: 2
Compression:
Stored size: 1.52 KB
Contents
# Authorized Service Lookups interact with filters to limit the # services which a user is allowed to see. This allows host # applications to more easily implement authorization. # # For example, if your Whoops installation is used by many different # teams, but you don't want the teams to see each others' data, you # could create a mapping between the team members' email addresses and # the services they're allowed to see. # # Since filters are used when viewing events or sending notifications, # the authorized service lookup allows you to modify the filters to # prevent the unauthorized services from being seen class Whoops::AuthorizedServiceLookup # @param key the value used to look up authorized services def initialize(key) @key = key end # if there are services given, then show all services # however, if we're looking at authorized services, then "all # services" means "all authorized services" # # if there is a filter on service then only allow authorized # services # # one thing to note is that if both services and authorized_services # are blank, then no filter will be applied to service at all def filter_authorized(services) matches = services.select{ |s| service_authorized?(s) } matches.empty? ? authorized_services : matches end # Overwrite this in your subclasses if you want to implement # authorized services def authorized_services [] end def service_authorized?(service) authorized_services.blank? || /^(#{authorized_services.join("|")})/ =~ service end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
whoops-0.5.5 | app/models/whoops/authorized_service_lookup.rb |
whoops-0.5.4 | app/models/whoops/authorized_service_lookup.rb |