當前位置: 首頁>>代碼示例>>Golang>>正文


Golang UserIdentityInfo.GetProviderUserName方法代碼示例

本文整理匯總了Golang中github.com/openshift/origin/pkg/auth/api.UserIdentityInfo.GetProviderUserName方法的典型用法代碼示例。如果您正苦於以下問題:Golang UserIdentityInfo.GetProviderUserName方法的具體用法?Golang UserIdentityInfo.GetProviderUserName怎麽用?Golang UserIdentityInfo.GetProviderUserName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/openshift/origin/pkg/auth/api.UserIdentityInfo的用法示例。


在下文中一共展示了UserIdentityInfo.GetProviderUserName方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: createIdentityAndMapping

// createIdentityAndMapping creates an identity with a valid user reference for the given identity info
func (p *provisioningIdentityMapper) createIdentityAndMapping(ctx kapi.Context, info authapi.UserIdentityInfo) (kuser.Info, error) {
	// Build the part of the identity we know about
	identity := &userapi.Identity{
		ObjectMeta: kapi.ObjectMeta{
			Name: info.GetIdentityName(),
		},
		ProviderName:     info.GetProviderName(),
		ProviderUserName: info.GetProviderUserName(),
		Extra:            info.GetExtra(),
	}

	// Get or create a persisted user pointing to the identity
	persistedUser, err := p.provisioningStrategy.UserForNewIdentity(ctx, getPreferredUserName(identity), identity)
	if err != nil {
		return nil, err
	}

	// Create the identity pointing to the persistedUser
	identity.User = kapi.ObjectReference{
		Name: persistedUser.Name,
		UID:  persistedUser.UID,
	}
	if _, err := p.identity.CreateIdentity(ctx, identity); err != nil {
		return nil, err
	}

	return &kuser.DefaultInfo{
		Name:   persistedUser.Name,
		UID:    string(persistedUser.UID),
		Groups: persistedUser.Groups,
	}, nil
}
開發者ID:RomainVabre,項目名稱:origin,代碼行數:33,代碼來源:provision.go

示例2: UserFor

func (m *TestUserIdentityMapper) UserFor(identityInfo api.UserIdentityInfo) (user.Info, error) {
	m.Identity = identityInfo
	username := identityInfo.GetProviderUserName()
	if preferredUsername := identityInfo.GetExtra()[api.IdentityPreferredUsernameKey]; len(preferredUsername) > 0 {
		username = preferredUsername
	}
	return &user.DefaultInfo{Name: username}, nil
}
開發者ID:RomainVabre,項目名稱:origin,代碼行數:8,代碼來源:requestheader_test.go

示例3: UserFor

func (m *testUserIdentityMapper) UserFor(identityInfo api.UserIdentityInfo) (user.Info, error) {
	return &user.DefaultInfo{Name: identityInfo.GetProviderUserName()}, nil
}
開發者ID:RomainVabre,項目名稱:origin,代碼行數:3,代碼來源:anyauthpassword_test.go


注:本文中的github.com/openshift/origin/pkg/auth/api.UserIdentityInfo.GetProviderUserName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。