Class: Whoops::AuthorizedServiceLookup
- Inherits:
-
Object
- Object
- Whoops::AuthorizedServiceLookup
- Defined in:
- app/models/whoops/authorized_service_lookup.rb
Overview
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
Instance Method Summary collapse
-
#authorized_services ⇒ Object
Overwrite this in your subclasses if you want to implement authorized services.
-
#filter_authorized(services) ⇒ Object
if there are services given, then show all services however, if we’re looking at authorized services, then “all services” means “all authorized services”.
-
#initialize(key) ⇒ AuthorizedServiceLookup
constructor
A new instance of AuthorizedServiceLookup.
- #service_authorized?(service) ⇒ Boolean
Constructor Details
#initialize(key) ⇒ AuthorizedServiceLookup
Returns a new instance of AuthorizedServiceLookup.
16 17 18 |
# File 'app/models/whoops/authorized_service_lookup.rb', line 16 def initialize(key) @key = key end |
Instance Method Details
#authorized_services ⇒ Object
Overwrite this in your subclasses if you want to implement authorized services
36 37 38 |
# File 'app/models/whoops/authorized_service_lookup.rb', line 36 def [] end |
#filter_authorized(services) ⇒ Object
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
29 30 31 32 |
# File 'app/models/whoops/authorized_service_lookup.rb', line 29 def (services) matches = services.select{ |s| (s) } matches.empty? ? : matches end |
#service_authorized?(service) ⇒ Boolean
40 41 42 |
# File 'app/models/whoops/authorized_service_lookup.rb', line 40 def (service) .blank? || /^(#{.join("|")})/ =~ service end |