service

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 1, 2022 License: Apache-2.0 Imports: 76 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultClient         = "tkeel"
	DefaultClientSecurity = "tkeel"
	DefaultClientDomain   = "tkeel.io"
	TokenTypeBearer       = "Bearer"
	TypeAuthInternal      = "internal"
	TypeAuthExternal      = "external"

	TypeProviderOIDC = "OIDCIdentityProvider"
)

Variables

View Source
var (
	ErrGetOpenapiIdentify = errors.New("error get openapi identify")
	ErrPluginRegistered   = errors.New("plugin is registered")
)
View Source
var ErrSecretNotMatch = errors.New("secret not match")

Functions

func ExtraConfigKey added in v1.0.0

func ExtraConfigKey(key string) string

func InitUserRoleCollector added in v1.0.0

func InitUserRoleCollector(db *gorm.DB)

func KeyOfTenantIdentityProvider added in v0.4.0

func KeyOfTenantIdentityProvider(tenantID string) string

func NewCollectValue added in v1.0.0

func NewCollectValue(val *structpb.Value) (*tdtl.Collect, error)

func NewStructValue added in v1.0.0

func NewStructValue(cc *tdtl.Collect) *structpb.Value

func ProviderRegister added in v0.4.0

func ProviderRegister(ctx context.Context, data []byte) error

Types

type AuthenticationService added in v0.4.0

type AuthenticationService struct {
	pb.UnimplementedAuthenticationServer
	// contains filtered or unexported fields
}

func NewAuthenticationService added in v0.4.0

func NewAuthenticationService(m *manage.Manager, userDB *gorm.DB, conf *TokenConf,
	rbacOp *casbin.SyncedEnforcer, prOp proute.Operator, profileOp *ProfileService, tpOp rbac.TenantPluginMgr,
) *AuthenticationService

func (*AuthenticationService) Authenticate added in v0.4.0

nolint

type AuthorizeRequest added in v0.4.0

type AuthorizeRequest struct {
	ResponseType        oauth2v4.ResponseType
	ClientID            string
	Scope               string
	RedirectURI         string
	State               string
	UserID              string
	CodeChallenge       string
	CodeChallengeMethod oauth2v4.CodeChallengeMethod
	AccessTokenExp      time.Duration
	Request             *http.Request
}

AuthorizeRequest authorization request.

type ConfigService added in v0.4.0

type ConfigService struct {
	pb.UnimplementedConfigServer
	// contains filtered or unexported fields
}

func NewConfigService added in v0.4.0

func NewConfigService(k8s *kubernetes.Client, kvOp kv.Operator) *ConfigService

func (*ConfigService) DelPlatformConfig added in v1.0.0

func (s *ConfigService) DelPlatformConfig(ctx context.Context, req *pb.PlatformConfigRequest) (*structpb.Value, error)

func (*ConfigService) GetDeploymentConfig added in v0.4.0

func (s *ConfigService) GetDeploymentConfig(ctx context.Context, req *emptypb.Empty) (*pb.GetDeploymentConfigResponse, error)

func (*ConfigService) GetPlatformConfig added in v1.0.0

func (s *ConfigService) GetPlatformConfig(ctx context.Context, req *pb.PlatformConfigRequest) (*structpb.Value, error)

func (*ConfigService) SetPlatformExtraConfig added in v1.0.0

func (s *ConfigService) SetPlatformExtraConfig(ctx context.Context, req *pb.SetPlatformExtraConfigRequest) (*structpb.Value, error)

type EToken added in v0.4.0

type EToken struct {
	EntityID   string `json:"entity_id"`
	EntityType string `json:"entity_type"`
	Owner      string `json:"owner"`
	TenantID   string `json:"tenant_id"`
	CreatedAt  int64  `json:"created_at"`
	ExpiredAt  int64  `json:"expired_at"`
}

func (*EToken) MD5ID added in v0.4.0

func (token *EToken) MD5ID(i *int) string

type EntityTokenService added in v0.4.0

type EntityTokenService struct {
	EntityTokenOp TokenOperator
	pb.UnimplementedEntityTokenServer
}

func NewEntityTokenService added in v0.4.0

func NewEntityTokenService(operator TokenOperator) *EntityTokenService

func (*EntityTokenService) CreateEntityToken added in v0.4.0

func (*EntityTokenService) DeleteEntityToken added in v0.4.0

func (s *EntityTokenService) DeleteEntityToken(ctx context.Context, req *pb.TokenInfoRequest) (*emptypb.Empty, error)

func (*EntityTokenService) TokenInfo added in v0.4.0

type EntryService added in v0.3.0

type EntryService struct {
	pb.UnimplementedEntryServer
	// contains filtered or unexported fields
}

func NewEntryService added in v0.3.0

func NewEntryService(pOp plugin.Operator, tpOp rbac.TenantPluginMgr, rbacOp *casbin.SyncedEnforcer) *EntryService

func (*EntryService) GetEntries added in v0.3.0

func (s *EntryService) GetEntries(ctx context.Context, req *emptypb.Empty) (*pb.GetEntriesResponse, error)

type KeelServiceV1 added in v0.3.0

type KeelServiceV1 struct {
	// contains filtered or unexported fields
}

func NewKeelServiceV1 added in v0.3.0

func NewKeelServiceV1(conf *config.Configuration, client dapr.Client) *KeelServiceV1

func (*KeelServiceV1) Filter added in v0.3.0

func (s *KeelServiceV1) Filter() restful.FilterFunction

func (*KeelServiceV1) ProxyPlugin added in v0.3.0

func (s *KeelServiceV1) ProxyPlugin(
	resp http.ResponseWriter, req *http.Request,
) error

type MetricsService added in v1.0.0

type MetricsService struct {
	MetricsHandler http.Handler
}

func NewMetricsService added in v1.0.0

func NewMetricsService(mtrCollectors ...prometheus.Collector) *MetricsService

func (*MetricsService) Metrics added in v1.0.0

func (svc *MetricsService) Metrics(req *go_restful.Request, resp *go_restful.Response)

type Oauth2ServiceV1

type Oauth2ServiceV1 struct {
	pb.UnimplementedOauth2Server
	// contains filtered or unexported fields
}

func NewOauth2ServiceV1

func NewOauth2ServiceV1(adminPasswd string, kvOp kv.Operator, pOp plugin.Operator) *Oauth2ServiceV1

func (*Oauth2ServiceV1) AddPluginWhiteList added in v0.3.0

func (s *Oauth2ServiceV1) AddPluginWhiteList(ctx context.Context,
	req *pb.AddPluginWhiteListRequest) (*emptypb.Empty, error)

func (*Oauth2ServiceV1) IssueAdminToken added in v0.3.0

func (*Oauth2ServiceV1) IssuePluginToken added in v0.3.0

func (*Oauth2ServiceV1) UpdateAdminPassword added in v0.4.0

func (s *Oauth2ServiceV1) UpdateAdminPassword(ctx context.Context, req *pb.UpdateAdminPasswordRequest) (*emptypb.Empty, error)

func (*Oauth2ServiceV1) VerifyToken added in v0.4.0

func (s *Oauth2ServiceV1) VerifyToken(ctx context.Context, empty *emptypb.Empty) (*emptypb.Empty, error)

type OauthService added in v0.4.0

type OauthService struct {
	Config     *TokenConf
	Manager    *manage.Manager
	UserDB     *gorm.DB
	DaprStore  string
	DaprClient dapr.Client

	RBACOp *casbin.SyncedEnforcer
	pb.UnimplementedOauthServer
	// contains filtered or unexported fields
}

func NewOauthService added in v0.4.0

func NewOauthService(m *manage.Manager, userDB *gorm.DB, conf *TokenConf, daprClient dapr.Client, daprstore string, k8s *kubernetes.Client, rbac *casbin.SyncedEnforcer) *OauthService

func (*OauthService) Authenticate added in v0.4.0

func (s *OauthService) Authenticate(ctx context.Context, empty *emptypb.Empty) (*pb.AuthenticateResponse, error)

func (*OauthService) Authorize added in v0.4.0

func (*OauthService) CheckGrantType added in v0.4.0

func (s *OauthService) CheckGrantType(gt oauth2v4.GrantType) bool

CheckGrantType check allows grant type.

func (*OauthService) GetAccessToken added in v0.4.0

GetAccessToken access token. //nolint.

func (*OauthService) GetAuthorizeToken added in v0.4.0

func (s *OauthService) GetAuthorizeToken(ctx context.Context, req *AuthorizeRequest) (oauth2v4.TokenInfo, error)

GetAuthorizeToken get authorization token(code). //nolint.

func (*OauthService) GetIdentityProvider added in v1.0.0

func (*OauthService) IdentityProviderRegister added in v1.0.0

func (s *OauthService) IdentityProviderRegister(ctx context.Context, req *pb.IdProviderRegisterRequest) (*pb.IdProviderRegisterResponse, error)

func (*OauthService) IdentityProviderTemplate added in v1.0.0

func (s *OauthService) IdentityProviderTemplate(ctx context.Context, req *pb.IdProviderTemplateRequest) (*pb.IdProviderTemplateResponse, error)

func (*OauthService) OIDCRegister added in v0.4.0

func (*OauthService) ResetPassword added in v0.4.0

func (*OauthService) Token added in v0.4.0

func (s *OauthService) Token(ctx context.Context, req *pb.TokenRequest) (*pb.TokenResponse, error)

nolint

func (*OauthService) TokenRevoke added in v0.4.0

func (*OauthService) UpdatePassword added in v0.4.0

func (*OauthService) ValidationTokenRequest added in v0.4.0

func (s *OauthService) ValidationTokenRequest(r *pb.TokenRequest) (oauth2v4.GrantType, *oauth2v4.TokenGenerateRequest, error)

ValidationTokenRequest the token request validation.

type PluginServiceV1

type PluginServiceV1 struct {
	pb.UnimplementedPluginServer
	// contains filtered or unexported fields
}

func NewPluginServiceV1

func NewPluginServiceV1(rbacOp *casbin.SyncedEnforcer, db *gorm.DB, conf *config.TkeelConf, kvOp kv.Operator, pOp plugin.Operator,
	prOp proute.Operator, tpOp rbac.TenantPluginMgr, openapi openapi.Client,
) *PluginServiceV1

func (*PluginServiceV1) GetPlugin

func (*PluginServiceV1) InstallPlugin added in v0.3.0

func (*PluginServiceV1) ListEnabledTenants added in v0.4.0

func (*PluginServiceV1) ListPlugin

func (*PluginServiceV1) TMRegisterPlugin added in v1.0.0

func (s *PluginServiceV1) TMRegisterPlugin(ctx context.Context,
	req *pb.TMRegisterPluginRequest,
) (*emptypb.Empty, error)

func (*PluginServiceV1) TMTenantDisable added in v1.0.0

func (s *PluginServiceV1) TMTenantDisable(ctx context.Context,
	req *pb.TMTenantDisableRequest,
) (*emptypb.Empty, error)

func (*PluginServiceV1) TMTenantEnable added in v1.0.0

func (s *PluginServiceV1) TMTenantEnable(ctx context.Context,
	req *pb.TMTenantEnableRequest,
) (*emptypb.Empty, error)

func (*PluginServiceV1) TMUpdatePluginIdentify added in v0.4.0

func (s *PluginServiceV1) TMUpdatePluginIdentify(ctx context.Context,
	req *pb.TMUpdatePluginIdentifyRequest,
) (*emptypb.Empty, error)

func (*PluginServiceV1) TenantDisable added in v0.4.0

func (s *PluginServiceV1) TenantDisable(ctx context.Context,
	req *pb.TenantDisableRequest,
) (*emptypb.Empty, error)

func (*PluginServiceV1) TenantEnable added in v0.4.0

func (s *PluginServiceV1) TenantEnable(ctx context.Context,
	req *pb.TenantEnableRequest,
) (*emptypb.Empty, error)

func (*PluginServiceV1) UninstallPlugin added in v0.3.0

func (*PluginServiceV1) UpgradePlugin added in v1.0.0

type ProfileService added in v1.0.0

type ProfileService struct {
	pb.UnimplementedProfileServer

	ProfileOp plgprofile.ProfileOperator
	// contains filtered or unexported fields
}

func NewProfileService added in v1.0.0

func NewProfileService(plgOp plugin.Operator, profileOp plgprofile.ProfileOperator, daprHTTP dapr.Client, openapiClient openapi.Client, tenantDB *gorm.DB) *ProfileService

func (*ProfileService) GetProfileSchema added in v1.0.0

func (*ProfileService) GetTenantProfileData added in v1.0.0

func (*ProfileService) SetTenantProfileData added in v1.0.0

nolint

type RBACService added in v0.4.0

type RBACService struct {
	pb.UnimplementedRBACServer
	// contains filtered or unexported fields
}

func NewRBACService added in v0.4.0

func NewRBACService(db *gorm.DB, rbac *casbin.SyncedEnforcer, tenantPluginOp rbac.TenantPluginMgr) *RBACService

func (*RBACService) CheckRolePermission added in v0.4.0

func (*RBACService) CreateRoleBinding added in v0.4.0

func (s *RBACService) CreateRoleBinding(ctx context.Context, req *pb.CreateRoleBindingRequest) (*emptypb.Empty, error)

func (*RBACService) CreateRoles added in v0.4.0

func (s *RBACService) CreateRoles(ctx context.Context, req *pb.CreateRoleRequest) (*pb.CreateRoleResponse, error)

func (*RBACService) DeleteRole added in v0.4.0

func (*RBACService) DeleteRoleBinding added in v0.4.0

func (s *RBACService) DeleteRoleBinding(ctx context.Context, req *pb.DeleteRoleBindingRequest) (*emptypb.Empty, error)

func (*RBACService) GetRole added in v0.4.0

func (s *RBACService) GetRole(ctx context.Context, req *pb.GetRoleRequest) (*pb.GetRoleResponse, error)

func (*RBACService) ListPermissions added in v0.4.0

func (*RBACService) ListRole added in v0.4.0

func (*RBACService) TMAddPolicy added in v0.4.0

func (s *RBACService) TMAddPolicy(ctx context.Context, req *pb.TMPolicyRequest) (*emptypb.Empty, error)

func (*RBACService) TMAddRoleBinding added in v0.4.0

func (s *RBACService) TMAddRoleBinding(ctx context.Context, req *pb.TMRoleBindingRequest) (*emptypb.Empty, error)

func (*RBACService) TMDeletePolicy added in v0.4.0

func (s *RBACService) TMDeletePolicy(ctx context.Context, req *pb.TMPolicyRequest) (*emptypb.Empty, error)

func (*RBACService) TMDeleteRoleBinding added in v0.4.0

func (s *RBACService) TMDeleteRoleBinding(ctx context.Context, req *pb.TMRoleBindingRequest) (*emptypb.Empty, error)

func (*RBACService) UpdateRole added in v0.4.0

func (*RBACService) UpdateUserRoleBinding added in v0.4.0

func (s *RBACService) UpdateUserRoleBinding(ctx context.Context, req *pb.UpdateUserRoleBindingRequest) (*emptypb.Empty, error)

type RepoService added in v0.3.0

type RepoService struct {
	pb.UnimplementedRepoServer
}

func NewRepoService added in v0.3.0

func NewRepoService() *RepoService

func (*RepoService) CreateRepo added in v0.3.0

func (s *RepoService) CreateRepo(ctx context.Context, req *pb.CreateRepoRequest) (*emptypb.Empty, error)

func (*RepoService) DeleteRepo added in v0.3.0

func (*RepoService) GetRepoInstaller added in v0.3.0

func (*RepoService) ListAllRepoInstaller added in v0.4.0

func (*RepoService) ListRepo added in v0.3.0

func (s *RepoService) ListRepo(ctx context.Context, req *emptypb.Empty) (*pb.ListRepoResponse, error)

func (*RepoService) ListRepoInstaller added in v0.3.0

type TenantService added in v0.4.0

type TenantService struct {
	pb.UnimplementedTenantServer
	DB             *gorm.DB
	TenantPluginOp rbac.TenantPluginMgr
	RBACOp         *casbin.SyncedEnforcer
	DaprClient     dapr.Client
	DaprStore      string
}

func NewTenantService added in v0.4.0

func NewTenantService(db *gorm.DB, tenantPluginOp rbac.TenantPluginMgr, rbacOp *casbin.SyncedEnforcer, daprClient dapr.Client, daprStore string) *TenantService

func (*TenantService) AddTenantPlugin added in v0.4.0

func (*TenantService) CreateTenant added in v0.4.0

func (*TenantService) CreateUser added in v0.4.0

func (*TenantService) DeleteTenant added in v0.4.0

func (s *TenantService) DeleteTenant(ctx context.Context, req *pb.DeleteTenantRequest) (*emptypb.Empty, error)

func (*TenantService) DeleteTenantPlugin added in v0.4.0

func (*TenantService) DeleteUser added in v0.4.0

func (s *TenantService) DeleteUser(ctx context.Context, req *pb.DeleteUserRequest) (*emptypb.Empty, error)

func (*TenantService) GetResetPasswordKey added in v0.4.0

func (*TenantService) GetTenant added in v0.4.0

func (*TenantService) GetUser added in v0.4.0

func (*TenantService) ListTenant added in v0.4.0

func (*TenantService) ListTenantPlugin added in v0.4.0

func (*TenantService) ListUser added in v0.4.0

func (*TenantService) ResetPasswordKeyInfo added in v0.4.0

func (s *TenantService) ResetPasswordKeyInfo(ctx context.Context, req *pb.RPKInfoRequest) (*pb.RPKInfoResponse, error)

func (*TenantService) TenantByExactSearch added in v0.4.0

func (s *TenantService) TenantByExactSearch(ctx context.Context, req *pb.ExactTenantRequest) (*pb.ExactTenantResponse, error)

func (*TenantService) TenantPluginPermissible added in v0.4.0

func (s *TenantService) TenantPluginPermissible(ctx context.Context, req *pb.PluginPermissibleRequest) (*pb.PluginPermissibleResponse, error)

func (*TenantService) UpdateTenant added in v0.4.0

func (*TenantService) UpdateUser added in v0.4.0

type TokenConf added in v0.4.0

type TokenConf struct {
	AccessTokenExp  time.Duration
	RefreshTokenExp time.Duration

	TokenType         string               // token type.
	AllowedGrantTypes []oauth2v4.GrantType // allow the grant type.
}

type TokenOp added in v0.4.0

type TokenOp struct {
	// contains filtered or unexported fields
}

func NewEntityTokenOperator added in v0.4.0

func NewEntityTokenOperator(storeName string, client dapr.Client) *TokenOp

func (*TokenOp) CreateToken added in v0.4.0

func (e *TokenOp) CreateToken(ctx context.Context, entity *EToken) (token string, err error)

func (*TokenOp) DeleteToken added in v0.4.0

func (e *TokenOp) DeleteToken(ctx context.Context, key string) (err error)

func (*TokenOp) GetEntityInfo added in v0.4.0

func (e *TokenOp) GetEntityInfo(ctx context.Context, key string) (entity *EToken, err error)

type TokenOperator added in v0.4.0

type TokenOperator interface {
	CreateToken(ctx context.Context, entity *EToken) (token string, err error)
	GetEntityInfo(ctx context.Context, token string) (entity *EToken, err error)
	DeleteToken(ctx context.Context, token string) (err error)
}

Directories

Path Synopsis
v1

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL