本文整理匯總了Golang中github.com/cloudawan/cloudone_utility/rbac.User.HasPermission方法的典型用法代碼示例。如果您正苦於以下問題:Golang User.HasPermission方法的具體用法?Golang User.HasPermission怎麽用?Golang User.HasPermission使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cloudawan/cloudone_utility/rbac.User
的用法示例。
在下文中一共展示了User.HasPermission方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: SetPrivilegeHiddenTag
func SetPrivilegeHiddenTag(data map[interface{}]interface{}, tagName string, user *rbac.User, method string, path string) {
if user.HasPermission(componentName, method, path) {
data[tagName] = "<div class='btn-group'>"
} else {
data[tagName] = "<div hidden>"
}
}
示例2: GetDashboardTabMenu
func GetDashboardTabMenu(user *rbac.User, activeTab string) string {
if user == nil {
return ""
}
buffer := bytes.Buffer{}
buffer.WriteByte('\n')
if user.HasPermission(componentName, "GET", "/gui/dashboard/topology") {
if activeTab == "topology" {
buffer.WriteString(" <li role='presentation' class='active'><a href='#' role='tab' >Topology</a></li>\n")
} else {
buffer.WriteString(" <li role='presentation'><a href='/gui/dashboard/topology/' role='tab' >Topology</a></li>\n")
}
}
if user.HasPermission(componentName, "GET", "/gui/dashboard/healthcheck") {
if activeTab == "healthcheck" {
buffer.WriteString(" <li role='presentation' class='active'><a href='#' role='tab' >Health Check</a></li>\n")
} else {
buffer.WriteString(" <li role='presentation'><a href='/gui/dashboard/healthcheck/list' role='tab' >Health Check</a></li>\n")
}
}
if user.HasPermission(componentName, "GET", "/gui/dashboard/bluegreen") {
if activeTab == "bluegreen" {
buffer.WriteString(" <li role='presentation' class='active'><a href='#' role='tab' >BlueGreen</a></li>\n")
} else {
buffer.WriteString(" <li role='presentation'><a href='/gui/dashboard/bluegreen/' role='tab' >BlueGreen</a></li>\n")
}
}
if user.HasPermission(componentName, "GET", "/gui/dashboard/appservice") {
if activeTab == "appservice" {
buffer.WriteString(" <li role='presentation' class='active'><a href='#' role='tab' >AppService</a></li>\n")
} else {
buffer.WriteString(" <li role='presentation'><a href='/gui/dashboard/appservice/' role='tab' >AppService</a></li>\n")
}
}
if user.HasPermission(componentName, "GET", "/gui/dashboard/deploy") {
if activeTab == "deploy" {
buffer.WriteString(" <li role='presentation' class='active'><a href='#' role='tab' >Deployment</a></li>\n")
} else {
buffer.WriteString(" <li role='presentation'><a href='/gui/dashboard/deploy/' role='tab' >Deployment</a></li>\n")
}
}
return buffer.String()
}
示例3: GetSystemRBACTabMenu
func GetSystemRBACTabMenu(user *rbac.User, activeTab string) string {
if user == nil {
return ""
}
buffer := bytes.Buffer{}
buffer.WriteByte('\n')
if user.HasPermission(componentName, "GET", "/gui/system/rbac/user/list") {
if activeTab == "user" {
buffer.WriteString(" <li role='presentation' class='active'><a href='#' role='tab' >User</a></li>\n")
} else {
buffer.WriteString(" <li role='presentation'><a href='/gui/system/rbac/user/list' role='tab' >User</a></li>\n")
}
}
if user.HasPermission(componentName, "GET", "/gui/system/rbac/role/list") {
if activeTab == "role" {
buffer.WriteString(" <li role='presentation' class='active'><a href='#' role='tab' >Role</a></li>\n")
} else {
buffer.WriteString(" <li role='presentation'><a href='/gui/system/rbac/role/list' role='tab' >Role</a></li>\n")
}
}
return buffer.String()
}
示例4: GetSystemNotificationTabMenu
func GetSystemNotificationTabMenu(user *rbac.User, activeTab string) string {
if user == nil {
return ""
}
buffer := bytes.Buffer{}
buffer.WriteByte('\n')
if user.HasPermission(componentName, "GET", "/gui/system/notification/emailserver/list") {
if activeTab == "emailserver" {
buffer.WriteString(" <li role='presentation' class='active'><a href='#' role='tab' >Email Server</a></li>\n")
} else {
buffer.WriteString(" <li role='presentation'><a href='/gui/system/notification/emailserver/list' role='tab' >Email Server</a></li>\n")
}
}
if user.HasPermission(componentName, "GET", "/gui/system/notification/sms/list") {
if activeTab == "sms" {
buffer.WriteString(" <li role='presentation' class='active'><a href='#' role='tab' >SMS</a></li>\n")
} else {
buffer.WriteString(" <li role='presentation'><a href='/gui/system/notification/sms/list' role='tab' >SMS</a></li>\n")
}
}
return buffer.String()
}
示例5: GetLayoutMenu
func GetLayoutMenu(user *rbac.User) string {
if user == nil {
return ""
}
buffer := bytes.Buffer{}
buffer.WriteByte('\n')
// Dashboard
if user.HasChildPermission(componentName, "GET", "/gui/dashboard") {
buffer.WriteString(" <li class=''><a href='/gui/dashboard/topology'>Dashboard</a></li>\n")
}
// Repository
// Parent
if user.HasChildPermission(componentName, "GET", "/gui/repository") {
buffer.WriteString(" <li class='dropdown'>\n")
buffer.WriteString(" <a href='#' class='dropdown-toggle' data-toggle='dropdown' role='button' aria-expanded='false'>Repository<span class='caret'></span></a>\n")
buffer.WriteString(" <ul class='dropdown-menu' role='menu'>\n")
}
// Child
if user.HasPermission(componentName, "GET", "/gui/repository/imageinformation/list") {
buffer.WriteString(" <li><a href='/gui/repository/imageinformation/list'>Applications</a></li>\n")
}
if user.HasPermission(componentName, "GET", "/gui/repository/thirdparty/list") {
buffer.WriteString(" <li><a href='/gui/repository/thirdparty/list'>Third-party Services</a></li>\n")
}
if user.HasPermission(componentName, "GET", "/gui/repository/topologytemplate/list") {
buffer.WriteString(" <li><a href='/gui/repository/topologytemplate/list'>Topology template</a></li>\n")
}
// Parent
if user.HasChildPermission(componentName, "GET", "/gui/repository") {
buffer.WriteString(" </ul>\n")
buffer.WriteString(" </li>\n")
}
// Deploy
// Parent
if user.HasChildPermission(componentName, "GET", "/gui/deploy") {
buffer.WriteString(" <li class='dropdown'>\n")
buffer.WriteString(" <a href='#' class='dropdown-toggle' data-toggle='dropdown' role='button' aria-expanded='false'>Deploy<span class='caret'></span></a>\n")
buffer.WriteString(" <ul class='dropdown-menu' role='menu'>\n")
}
// Child
if user.HasPermission(componentName, "GET", "/gui/deploy/deploy/list") {
buffer.WriteString(" <li><a href='/gui/deploy/deploy/list'>Applications</a></li>\n")
}
if user.HasPermission(componentName, "GET", "/gui/deploy/deploybluegreen/list") {
buffer.WriteString(" <li><a href='/gui/deploy/deploybluegreen/list'>Blue Green Deployments</a></li>\n")
}
if user.HasPermission(componentName, "GET", "/gui/deploy/autoscaler/list") {
buffer.WriteString(" <li><a href='/gui/deploy/autoscaler/list'>Autoscalers</a></li>\n")
}
if user.HasPermission(componentName, "GET", "/gui/deploy/deployclusterapplication/list") {
buffer.WriteString(" <li><a href='/gui/deploy/deployclusterapplication/list'>Third-party Services</a></li>\n")
}
if user.HasPermission(componentName, "GET", "/gui/deploy/clone/topology") {
buffer.WriteString(" <li><a href='/gui/deploy/clone/select'>Clone Topology</a></li>\n")
}
// Parent
if user.HasChildPermission(componentName, "GET", "/gui/deploy") {
buffer.WriteString(" </ul>\n")
buffer.WriteString(" </li>\n")
}
// Inventory
// Parent
if user.HasChildPermission(componentName, "GET", "/gui/inventory") {
buffer.WriteString(" <li class='dropdown'>\n")
buffer.WriteString(" <a href='#' class='dropdown-toggle' data-toggle='dropdown' role='button' aria-expanded='false'>Inventory<span class='caret'></span></a>\n")
buffer.WriteString(" <ul class='dropdown-menu' role='menu'>\n")
}
// Child
if user.HasPermission(componentName, "GET", "/gui/inventory/replicationcontroller/list") {
buffer.WriteString(" <li><a href='/gui/inventory/replicationcontroller/list'>Replications</a></li>\n")
}
if user.HasPermission(componentName, "GET", "/gui/inventory/service/list") {
buffer.WriteString(" <li><a href='/gui/inventory/service/list'>Services</a></li>\n")
}
// Parent
if user.HasChildPermission(componentName, "GET", "/gui/inventory") {
buffer.WriteString(" </ul>\n")
buffer.WriteString(" </li>\n")
}
// Filesystem
// Parent
if user.HasChildPermission(componentName, "GET", "/gui/filesystem") {
buffer.WriteString(" <li class='dropdown'>\n")
buffer.WriteString(" <a href='#' class='dropdown-toggle' data-toggle='dropdown' role='button' aria-expanded='false'>Filesystem<span class='caret'></span></a>\n")
buffer.WriteString(" <ul class='dropdown-menu' role='menu'>\n")
}
// Child
if user.HasPermission(componentName, "GET", "/gui/filesystem/glusterfs/cluster/list") {
buffer.WriteString(" <li><a href='/gui/filesystem/glusterfs/cluster/list'>Glusterfs</a></li>\n")
}
// Parent
if user.HasChildPermission(componentName, "GET", "/gui/filesystem") {
buffer.WriteString(" </ul>\n")
buffer.WriteString(" </li>\n")
//.........這裏部分代碼省略.........