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


Golang EntityManager.IsUserPartOfAGroup方法代碼示例

本文整理匯總了Golang中ibm-security-innovation/libsecurity-go/entity.EntityManager.IsUserPartOfAGroup方法的典型用法代碼示例。如果您正苦於以下問題:Golang EntityManager.IsUserPartOfAGroup方法的具體用法?Golang EntityManager.IsUserPartOfAGroup怎麽用?Golang EntityManager.IsUserPartOfAGroup使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ibm-security-innovation/libsecurity-go/entity.EntityManager的用法示例。


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

示例1: GetUserPermissions

// Get all the permissions of a given user to a given resource-
// return the user's list of permissions to the given resource
// The permissions may be listed as the user's permissions, permissions to groups
// in which the user is a member or permissions that are given to 'all'
func GetUserPermissions(el *en.EntityManager, userName string, resourceName string) (PermissionsMap, error) {
	lock.Lock()
	defer lock.Unlock()

	if el == nil {
		return nil, fmt.Errorf("Error: EntityManager is nil")
	}
	err := en.IsEntityNameValid(userName)
	if err != nil {
		return nil, err
	}
	err = en.IsEntityNameValid(resourceName)
	if err != nil {
		return nil, err
	}
	permissions := make(PermissionsMap)
	data, err := el.GetPropertyAttachedToEntity(resourceName, stc.AclPropertyName)
	if err != nil {
		return nil, fmt.Errorf("Resource '%v' dose not have an ACL property", resourceName)
	}
	acl, ok := data.(*Acl)
	if ok == false {
		return nil, fmt.Errorf("Resource '%v' ACL property is in the wrong type", resourceName)
	}
	for name, p := range acl.Permissions {
		if name == userName || name == stc.AclAllEntryName || el.IsUserPartOfAGroup(name, userName) {
			for permission, _ := range p.Permissions {
				permissions[permission] = ""
			}
		}
	}
	logger.Trace.Println("The permissions of:", userName, "are:", permissions)
	return permissions, nil
}
開發者ID:kopzhangwx,項目名稱:libsecurity-go,代碼行數:38,代碼來源:acl.go


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