Files
cloudpods/pkg/mcclient/token.go
T
Qiu Jian bc02b3b433 1.
取消userCred.IsSystemAdmin(),在使用policy的应用中,通过userCred.IsAdminAllow判断是否是管理员且具备相应的权限。获取token时,需要传入policy.FilterPolicyCredential,将普通userCred转换成支持rbac的userCred
2. 在应用启动时候,必须设置 SetServiceType,否则退出
2018-11-30 23:00:11 +08:00

61 lines
1.2 KiB
Go

package mcclient
import (
"time"
"yunion.io/x/jsonutils"
"yunion.io/x/pkg/gotypes"
)
type ExternalService struct {
Name string
Url string
}
type Endpoint struct {
Id string
RegionId string
ServiceId string
ServiceName string
Url string
Interface string
}
type IIdentityProvider interface {
GetProjectId() string
GetUserId() string
GetTenantId() string
}
type TokenCredential interface {
gotypes.ISerializable
IServiceCatalog
IIdentityProvider
GetTokenString() string
GetDomainId() string
GetDomainName() string
GetTenantName() string
GetProjectName() string
GetUserName() string
GetRoles() []string
GetExpires() time.Time
IsValid() bool
ValidDuration() time.Duration
// IsAdmin() bool
HasSystemAdminPrivelege() bool
IsAdminAllow(service string, resource string, action string, extra ...string) bool
GetRegions() []string
GetServiceCatalog() IServiceCatalog
GetCatalogData(serviceTypes []string, region string) jsonutils.JSONObject
GetInternalServices(region string) []string
GetExternalServices(region string) []ExternalService
GetEndpoints(region string, endpointType string) []Endpoint
ToJson() jsonutils.JSONObject
}