If the JWT has a user filter, verify that the filtered
        user value matches the user in the URL.
540980
def has_permission(self, request, view):
        
        user_filter = self._get_user_filter(request)
        if not user_filter:
            # no user filters are present in the token to limit access
            return True

        username_param = get_username_param(request)
        allowed = user_filter == username_param
        if not allowed:
            log.warning(
                u"Permission JwtHasUserFilterForRequestedUser: user_filter %s doesn't match username %s.",
                user_filter,
                username_param,
            )
        return allowed
180720
def verify_user_alias(user, token):
    
    if token.to_alias_type == 'EMAIL':
        if token.to_alias == getattr(user, api_settings.PASSWORDLESS_USER_EMAIL_FIELD_NAME):
            setattr(user, api_settings.PASSWORDLESS_USER_EMAIL_VERIFIED_FIELD_NAME, True)
    elif token.to_alias_type == 'MOBILE':
        if token.to_alias == getattr(user, api_settings.PASSWORDLESS_USER_MOBILE_FIELD_NAME):
            setattr(user, api_settings.PASSWORDLESS_USER_MOBILE_VERIFIED_FIELD_NAME, True)
    else:
        return False
    user.save()
    return True
1258890
def validate_filter(self, key, filter_value):
        
        ok = False
        seek = u"filter[%s]" % key
        value = None
        for link in self.schema['links']:
            if link['rel'] == 'instances':
               for property in link['properties']:
                   if seek == property:
                       value = link['properties'][property]
                       ok = True
        if not ok:
            return False
        ok = self._is_type(filter_value, value['type'])
        # if string with type add validation
        if ok is True and value['type'] == 'string' and 'format' in value.keys():
            ok = self._validate_json_format(filter_value, value)
            
        return ok
528070
public boolean matchesFilter(String filter, int priValue, int secValue) {

        filter = filter.toLowerCase();
        return m_parameters[priValue].toLowerCase().contains(filter)
            || m_parameters[secValue].toLowerCase().contains(filter);
    }
818873
function verifyUsernameDoesNotExist(req, res, next) {
  var username = req.body.username;
  var dataStore = req.app.dataStore;

  // Check for an existing employee REST resource - /employees/{username}
  var resource = new swagger.Resource('/employees', username, null);
  dataStore.get(resource, function(err, resource) {
    if (resource) {
      // The username already exists, so send an HTTP 409 (Conflict)
      res.sendStatus(409);
    }
    else {
      next();
    }
  });
}
688159
function(req, res, user) {
    var jsonWebTokens = waterlock.config.jsonWebTokens || {};
    var expiryUnit = (jsonWebTokens.expiry && jsonWebTokens.expiry.unit) || 'days';
    var expiryLength = (jsonWebTokens.expiry && jsonWebTokens.expiry.length) || 7;
    var expires = moment().add(expiryLength, expiryUnit).valueOf();
    var issued = Date.now();
    user = user || req.session.user;

    var token = jwt.encode({
      iss: user.id + '|' + req.remoteAddress,
      sub: jsonWebTokens.subject,
      aud: jsonWebTokens.audience,
      exp: expires,
      nbf: issued,
      iat: issued,
      jti: uuid.v1()
    }, jsonWebTokens.secret);

    return {
      token: token,
      expires: expires
    };
  }
924259
private boolean matches(String filter, String value) {
        if (filter == null) {
            return true;
        }
        return filter.equals(value);
    }
543005
def _in(field, filter_value):
        
        valid = False
        if field in filter_value:
            valid = True
        return valid
1202778
def has_permission(self, request, view):
        
        course_key = CourseKey.from_string(view.kwargs.get('course_id'))
        jwt_filters = decode_jwt_filters(request.auth)
        for filter_type, filter_value in jwt_filters:
            if filter_type == 'content_org' and filter_value == course_key.org:
                return True
        log.warning(
            u"Permission JwtHasContentOrgFilterForRequestedCourse: no filter found for %s.",
            course_key.org,
        )
        return False
1048412
function(req, user){
      req.session.authenticated = true;
      req.session.user = user;
    }
573382
function(authResult, redirectUrl) {
        if (authResult.user) {
          handleSignedInUser(authResult.user);
        }
        if (authResult.additionalUserInfo) {
          document.getElementById('is-new-user').textContent =
              authResult.additionalUserInfo.isNewUser ?
              'New User' : 'Existing User';
        }
        // Do not redirect.
        return false;
      }
1248982
def matches(self, filter_props):
        """"""
        if filter_props is None:
            return False

        found_one = False
        for key, value in filter_props.items():
            if key in self.properties and value != self.properties[key]:
                return False
            elif key in self.properties and value == self.properties[key]:
                found_one = True

        return found_one
540912
def authenticated(self, user_token, **validation_context):
        
        token = self.token_storage.get(user_token)
        if token and token.validate(user_token, **validation_context):
            return True

        return False
923030
protected Object checkUserAgent(ServerUserHandlerClass handler, ApiUser userAgent) {
        if(handler.getUserClass().isAssignableFrom(userAgent.getClass()))
            return userAgent;
        return UserAgentUtil.getGameUser(userAgent, handler.getUserClass());
    }
569581
function validateAskPermission (token) {
  const header = jwt.decode(token)

  return validateToken(token) && header[ASK_CLAIM_KEY]
}
524639
public static Expectations successfullyReachedProtectedResourceWithJwtCookie(String testAction, String protectedUrl, String username) {
        return successfullyReachedProtectedResourceWithJwtCookie(testAction, protectedUrl, username, JwtFatConstants.DEFAULT_ISS_REGEX);
    }
386749
def is_api_filter(self, filter_field):
        """"""
        if self.filter_type == 'server':
            for choice in self.filter_choices:
                if (choice[0] == filter_field and len(choice) > 2 and
                        choice[2]):
                    return True
        return False