Fix unsafe handling of granted authorities