// ConvertUsernameToIdentifier converts a username into an identifier. It tries validated email addresses first. If
// there are none, attempt to use validated phone numbers. If the user also doesn't have any of those, keep the username
180544
func ConvertUsernameToIdentifier(username string, usrMgr *user.Manager, valMgr *validation.Manager) (string, error) {
	userIdentifier := username
	usr, err := usrMgr.GetByName(username)
	if err != nil {
		return userIdentifier, err
	}
	// check for a validated email address
	for _, email := range usr.EmailAddresses {
		validated, err := valMgr.IsEmailAddressValidated(username, email.EmailAddress)
		if err != nil {
			return userIdentifier, err
		}
		if validated {
			return email.EmailAddress, err
		}
	}
	// try the phone numbers
	for _, phone := range usr.Phonenumbers {
		validated, err := valMgr.IsPhonenumberValidated(username, phone.Phonenumber)
		if err != nil {
			return userIdentifier, err
		}
		if validated {
			return phone.Phonenumber, err
		}
	}
	// No verified email or phone number. Fallback to username
	return userIdentifier, err
}
476041
func Convert_v1_Identity_To_user_Identity(in *v1.Identity, out *user.Identity, s conversion.Scope) error {
	return autoConvert_v1_Identity_To_user_Identity(in, out, s)
}
467808
func (s *IdentityService) GetUserByOIDCIdentity(id services.ExternalIdentity) (services.User, error) {
	users, err := s.GetUsers()
	if err != nil {
		return nil, trace.Wrap(err)
	}
	for _, u := range users {
		for _, uid := range u.GetOIDCIdentities() {
			if uid.Equals(&id) {
				return u, nil
			}
		}
	}
	return nil, trace.NotFound("user with identity %q not found", &id)
}
211342
func Convert_user_Identity_To_v1_Identity(in *user.Identity, out *v1.Identity, s conversion.Scope) error {
	return autoConvert_user_Identity_To_v1_Identity(in, out, s)
}
1085969
func Convert_config_LDAPPasswordIdentityProvider_To_v1_LDAPPasswordIdentityProvider(in *config.LDAPPasswordIdentityProvider, out *v1.LDAPPasswordIdentityProvider, s conversion.Scope) error {
	return autoConvert_config_LDAPPasswordIdentityProvider_To_v1_LDAPPasswordIdentityProvider(in, out, s)
}
1368706
func (s *CreateResourceServerInput) SetIdentifier(v string) *CreateResourceServerInput {
	s.Identifier = &v
	return s
}
972624
func Convert_v1_BasicAuthPasswordIdentityProvider_To_config_BasicAuthPasswordIdentityProvider(in *v1.BasicAuthPasswordIdentityProvider, out *config.BasicAuthPasswordIdentityProvider, s conversion.Scope) error {
	return autoConvert_v1_BasicAuthPasswordIdentityProvider_To_config_BasicAuthPasswordIdentityProvider(in, out, s)
}
325342
func Convert_v1_IdentityList_To_user_IdentityList(in *v1.IdentityList, out *user.IdentityList, s conversion.Scope) error {
	return autoConvert_v1_IdentityList_To_user_IdentityList(in, out, s)
}
571486
func (defaultNodeIdentifier) NodeIdentity(u user.Info) (string, bool) {
	// Make sure we're a node, and can parse the node name
	if u == nil {
		return "", false
	}

	userName := u.GetName()
	if !strings.HasPrefix(userName, nodeUserNamePrefix) {
		return "", false
	}

	isNode := false
	for _, g := range u.GetGroups() {
		if g == user.NodesGroup {
			isNode = true
			break
		}
	}
	if !isNode {
		return "", false
	}

	nodeName := strings.TrimPrefix(userName, nodeUserNamePrefix)
	return nodeName, true
}
1364660
func (t *typeParser) nextIdentifier() (id string, found bool) {
	startIndex := t.index
	for t.index < len(t.input) && isIdentifierChar(t.input[t.index]) {
		t.index++
	}
	if startIndex == t.index {
		return "", false
	}
	return t.input[startIndex:t.index], true
}
882122
func (_class AuthClass) GetSubjectIdentifier(sessionID SessionRef, subjectName string) (_retval string, _err error) {
	_method := "auth.get_subject_identifier"
	_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
	if _err != nil {
		return
	}
	_subjectNameArg, _err := convertStringToXen(fmt.Sprintf("%s(%s)", _method, "subject_name"), subjectName)
	if _err != nil {
		return
	}
	_result, _err := _class.client.APICall(_method, _sessionIDArg, _subjectNameArg)
	if _err != nil {
		return
	}
	_retval, _err = convertStringToGo(_method + " -> ", _result.Value)
	return
}
891283
func identifyUserToChan(
	ctx context.Context, nug idutil.NormalizedUsernameGetter,
	identifier idutil.Identifier, name kbname.NormalizedUsername,
	id keybase1.UserOrTeamID, t tlf.Type, offline keybase1.OfflineAvailability,
	errChan chan error) {
	errChan <- identifyUser(ctx, nug, identifier, name, id, t, offline)
}
130722
func toIdentifier(s string) string {
	// replace bad chars with _
	s = replaceBadChars(strings.TrimSpace(s))

	// fix 2 or more __ and remove leading numbers/underscores
	s = underscoreRE.ReplaceAllString(s, "_")
	s = leadingRE.ReplaceAllString(s, "_")

	// remove leading/trailing underscores
	s = strings.TrimLeft(s, "_")
	s = strings.TrimRight(s, "_")

	return s
}
6730
func (i IdentifierSet) AddIdentifiers(idents Identifiers) {
	for _, ident := range idents {
		i.Add(ident)
	}
}
1373453
func ConvertUsersSimple(request *http.Request, identityIDs []interface{}) []*app.GenericData {
	ops := []*app.GenericData{}
	for _, identityID := range identityIDs {
		data, _ := ConvertUserSimple(request, identityID)
		ops = append(ops, data)
	}
	return ops
}
1315004
func identityReferencesUser(identity *userapi.Identity, user *userapi.User) bool {
	return identity.User.Name == user.Name && identity.User.UID == user.UID
}
1172208
func unsetIdentityUser(identity *userapi.Identity) bool {
	if !hasUserMapping(identity) {
		return false
	}
	identity.User = corev1.ObjectReference{}
	return true
}