'Check if access should be allowed for the request.'

def SecurityCheck(self, func, request, *args, **kwargs):

    try:
        auth_header = request.headers.get('Authorization', '')
        if (not auth_header.startswith(self.BEARER_PREFIX)):
            raise crypt.AppIdentityError('JWT    token    is    missing.')
        token = auth_header[len(self.BEARER_PREFIX):]
        auth_domain = config.CONFIG['AdminUI.firebase_auth_domain']
        project_id = auth_domain.split('.')[0]
        idinfo = client.verify_id_token(token, project_id, cert_uri=self.CERT_URI)
        if (idinfo['iss'] != (self.SECURE_TOKEN_PREFIX + project_id)):
            raise crypt.AppIdentityError('Wrong    issuer.')
        request.user = idinfo['email']
    except crypt.AppIdentityError as e:
        if (request.path != '/'):
            return self.AuthError(('JWT    token    validation    failed:    %s' % e))
    return func(request, *args, **kwargs)
