Documentation
¶
Overview ¶
Package mock_gokontrol is a generated GoMock package.
Index ¶
- Variables
- type CertForSign
- type Certificate
- type Claims
- type DefaultKontrol
- func (k DefaultKontrol) AddSimpleObjectWithDefaultPolicy(ctx context.Context, externalid string, serviceid string, servicekey string) (*ObjectPermission, error)
- func (k DefaultKontrol) CreateCert(obj *Object, policy []*Policy, enforce []*Policy, extendServiceIds []string) (*CertForSign, string, string, error)
- func (k DefaultKontrol) CreatePolicy(ctx context.Context, servicekey string, policy *Policy) error
- func (k DefaultKontrol) GetObjectExtendServiceIds(ctx context.Context, objId string) ([]string, error)
- func (k DefaultKontrol) IssueCertForClient(ctx context.Context, externalID string, serID string) (*ObjectPermission, error)
- func (k DefaultKontrol) IssueCertForService(ctx context.Context, objID string, serID string) (*ObjectPermission, error)
- func (k DefaultKontrol) UpdateObject(ctx context.Context, obj *Object, servicekey string) error
- func (k DefaultKontrol) UpdatePolicy(ctx context.Context, servicekey string, policy *Policy) error
- func (k DefaultKontrol) ValidateToken(c context.Context, jwtToken string, reqPath string, reqMethod string) (*Object, error)
- type Kontrol
- type KontrolOption
- type KontrolStore
- type MockKontrol
- func (m *MockKontrol) AddSimpleObjectWithDefaultPolicy(ctx context.Context, externalid, serviceid, servicekey string) (*ObjectPermission, error)
- func (m *MockKontrol) CreateCert(obj *Object, policy, enforce []*Policy, objectExtendServiceIds []string) (*CertForSign, string, string, error)
- func (m *MockKontrol) CreatePolicy(ctx context.Context, servicekey string, policy *Policy) error
- func (m *MockKontrol) EXPECT() *MockKontrolMockRecorder
- func (m *MockKontrol) GetObjectExtendServiceIds(ctx context.Context, objId string) ([]string, error)
- func (m *MockKontrol) IssueCertForClient(ctx context.Context, externalID, serID string) (*ObjectPermission, error)
- func (m *MockKontrol) IssueCertForService(ctx context.Context, objID, externalid string) (*ObjectPermission, error)
- func (m *MockKontrol) UpdateObject(ctx context.Context, obj *Object, servicekey string) error
- func (m *MockKontrol) UpdatePolicy(ctx context.Context, servicekey string, policy *Policy) error
- func (m *MockKontrol) ValidateToken(c context.Context, token, reqPath, reqMethod string) (*Object, error)
- type MockKontrolMockRecorder
- func (mr *MockKontrolMockRecorder) AddSimpleObjectWithDefaultPolicy(ctx, externalid, serviceid, servicekey interface{}) *gomock.Call
- func (mr *MockKontrolMockRecorder) CreateCert(obj, policy, enforce, objectExtendServiceIds interface{}) *gomock.Call
- func (mr *MockKontrolMockRecorder) CreatePolicy(ctx, servicekey, policy interface{}) *gomock.Call
- func (mr *MockKontrolMockRecorder) GetObjectExtendServiceIds(ctx, objId interface{}) *gomock.Call
- func (mr *MockKontrolMockRecorder) IssueCertForClient(ctx, externalID, serID interface{}) *gomock.Call
- func (mr *MockKontrolMockRecorder) IssueCertForService(ctx, objID, externalid interface{}) *gomock.Call
- func (mr *MockKontrolMockRecorder) UpdateObject(ctx, obj, servicekey interface{}) *gomock.Call
- func (mr *MockKontrolMockRecorder) UpdatePolicy(ctx, servicekey, policy interface{}) *gomock.Call
- func (mr *MockKontrolMockRecorder) ValidateToken(c, token, reqPath, reqMethod interface{}) *gomock.Call
- type MockKontrolStore
- func (m *MockKontrolStore) CreateObject(c context.Context, obj *Object) error
- func (m *MockKontrolStore) CreatePolicy(c context.Context, policy *Policy) error
- func (m *MockKontrolStore) EXPECT() *MockKontrolStoreMockRecorder
- func (m *MockKontrolStore) ExpiredObjectsByPolicy(c context.Context, policyId string) error
- func (m *MockKontrolStore) GetObjectByExternalID(c context.Context, extid, serviceid string) (*Object, error)
- func (m *MockKontrolStore) GetObjectByID(c context.Context, id string) (*Object, error)
- func (m *MockKontrolStore) GetObjectByToken(c context.Context, token string, timestamp int64) (*Object, error)
- func (m *MockKontrolStore) GetObjectServiceMesh(c context.Context, objectId string) ([]*ObjectServiceMess, error)
- func (m *MockKontrolStore) GetPolicyByID(c context.Context, id string) (*Policy, error)
- func (m *MockKontrolStore) GetServiceByExternalId(c context.Context, externalId string) (*Service, error)
- func (m *MockKontrolStore) GetServiceByID(c context.Context, id string) (*Service, error)
- func (m *MockKontrolStore) UpdateObject(c context.Context, obj *Object) error
- func (m *MockKontrolStore) UpdatePolicy(c context.Context, policy *Policy) error
- type MockKontrolStoreMockRecorder
- func (mr *MockKontrolStoreMockRecorder) CreateObject(c, obj interface{}) *gomock.Call
- func (mr *MockKontrolStoreMockRecorder) CreatePolicy(c, policy interface{}) *gomock.Call
- func (mr *MockKontrolStoreMockRecorder) ExpiredObjectsByPolicy(c, policyId interface{}) *gomock.Call
- func (mr *MockKontrolStoreMockRecorder) GetObjectByExternalID(c, extid, serviceid interface{}) *gomock.Call
- func (mr *MockKontrolStoreMockRecorder) GetObjectByID(c, id interface{}) *gomock.Call
- func (mr *MockKontrolStoreMockRecorder) GetObjectByToken(c, token, timestamp interface{}) *gomock.Call
- func (mr *MockKontrolStoreMockRecorder) GetObjectServiceMesh(c, objectId interface{}) *gomock.Call
- func (mr *MockKontrolStoreMockRecorder) GetPolicyByID(c, id interface{}) *gomock.Call
- func (mr *MockKontrolStoreMockRecorder) GetServiceByExternalId(c, externalId interface{}) *gomock.Call
- func (mr *MockKontrolStoreMockRecorder) GetServiceByID(c, id interface{}) *gomock.Call
- func (mr *MockKontrolStoreMockRecorder) UpdateObject(c, obj interface{}) *gomock.Call
- func (mr *MockKontrolStoreMockRecorder) UpdatePolicy(c, policy interface{}) *gomock.Call
- type Object
- type ObjectPermission
- type ObjectServiceMess
- type Policy
- type Service
Constants ¶
This section is empty.
Variables ¶
var CommonError = commonerror{ NOT_FOUND: errors.New("not found"), OBJECT_NOT_FOUND: errors.New("object not found"), PERMISSION_NOT_FOUND: errors.New("permission not found"), POLICY_NOT_FOUND: errors.New("policy not found"), SERVICE_NOT_FOUND: errors.New("service not found"), INVALID_TOKEN: errors.New("invalid or expired token"), INVALID_SERVICE: errors.New("invalid service"), INVALID_POLICY: errors.New("invalid policy"), INVALID_OBJECT: errors.New("invalid object"), MALFORM_PERMISSION: errors.New("policy permission malform"), }
var DefaultKontrolOption = KontrolOption{
DefaultTimeout: 1800,
SecretKey: "secret",
}
Default config for kontrol
var ObjectPolicyStatus = objectpolicystatus{
INIT: "",
ENABLE: "enable",
DISABLE: "disable",
DEFAULT: "default",
}
var ObjectStatus = objectstatus{
INIT: "",
ENABLE: "enable",
DISABLE: "disable",
}
var PolicyPermission = policypermission{
ANY: 0,
TRUE: 1,
FALSE: 2,
}
var ServiceStatus = objectstatus{
INIT: "",
ENABLE: "enable",
DISABLE: "disable",
}
Functions ¶
This section is empty.
Types ¶
type CertForSign ¶
type CertForSign struct { ID string `json:"id"` GlobalID string `json:"global_id"` ExternalID string `json:"external_id"` ServiceID string `json:"service_id"` ExpiryDate int64 `json:"expiry_date"` Scope []string `json:"scope"` Attributes map[string]interface{} `json:"attributes"` Permission map[string]map[string]bool `json:"permission"` }
type Certificate ¶
type Certificate struct { CertForSign Token string `json:"token"` ExpiryDate int64 `json:"expiry_date"` }
type Claims ¶
type Claims struct { Permission map[string]map[string]bool `json:"permission"` Token string `json:"token"` jwt.StandardClaims }
Claims -- JWT claim use for specific customize
type DefaultKontrol ¶
type DefaultKontrol struct { Option KontrolOption // contains filtered or unexported fields }
DefaultKontrol simple Kontrol
func (DefaultKontrol) AddSimpleObjectWithDefaultPolicy ¶
func (k DefaultKontrol) AddSimpleObjectWithDefaultPolicy(ctx context.Context, externalid string, serviceid string, servicekey string) (*ObjectPermission, error)
AddSimpleObjectWithDefaultPolicy add object with default service schema
func (DefaultKontrol) CreateCert ¶
func (k DefaultKontrol) CreateCert(obj *Object, policy []*Policy, enforce []*Policy, extendServiceIds []string) (*CertForSign, string, string, error)
CreateCert create final cert then sign
func (DefaultKontrol) CreatePolicy ¶
CreatePolicy create a policy
func (DefaultKontrol) GetObjectExtendServiceIds ¶
func (DefaultKontrol) IssueCertForClient ¶
func (k DefaultKontrol) IssueCertForClient(ctx context.Context, externalID string, serID string) (*ObjectPermission, error)
IssueCertForClient issue cert for current time, does not authen, must be authen-ed beforehand
func (DefaultKontrol) IssueCertForService ¶
func (k DefaultKontrol) IssueCertForService(ctx context.Context, objID string, serID string) (*ObjectPermission, error)
IssueCertForService issue cert for issued time, does not authn, must be authn-ed beforehand
func (DefaultKontrol) UpdateObject ¶
UpdateObject update Object info
func (DefaultKontrol) UpdatePolicy ¶
func (DefaultKontrol) ValidateToken ¶
func (k DefaultKontrol) ValidateToken(c context.Context, jwtToken string, reqPath string, reqMethod string) (*Object, error)
ValidateToken validate the given token
type Kontrol ¶
type Kontrol interface { ValidateToken(c context.Context, token string, reqPath string, reqMethod string) (*Object, error) // validate if token existed, for tighter check, use IssueCertForService IssueCertForService(ctx context.Context, objID string, externalid string) (*ObjectPermission, error) // get client cert for service to store AddSimpleObjectWithDefaultPolicy(ctx context.Context, externalid string, serviceid string, servicekey string) (*ObjectPermission, error) //service create new object UpdateObject(ctx context.Context, obj *Object, servicekey string) error //service update object CreateCert(obj *Object, policy []*Policy, enforce []*Policy, objectExtendServiceIds []string) (*CertForSign, string, string, error) // internal use, centralise function to issue permission CreatePolicy(ctx context.Context, servicekey string, policy *Policy) error UpdatePolicy(ctx context.Context, servicekey string, policy *Policy) error IssueCertForClient(ctx context.Context, externalID string, serID string) (*ObjectPermission, error) // issue cert for client when login success GetObjectExtendServiceIds(ctx context.Context, objId string) ([]string, error) // GET LIST EXTEND SERVICE THAT OBJECT CAN ACCESS }
func NewBasicKontrol ¶
func NewBasicKontrol(store KontrolStore) Kontrol
NewBasicKontrol simple Kontrol with default option, stores still have to be provided
type KontrolOption ¶
KontrolOption kontrol config options
type KontrolStore ¶
type KontrolStore interface { GetObjectByToken(c context.Context, token string, timestamp int64) (*Object, error) CreateObject(c context.Context, obj *Object) error UpdateObject(c context.Context, obj *Object) error GetObjectByID(c context.Context, id string) (*Object, error) GetObjectByExternalID(c context.Context, extid string, serviceid string) (*Object, error) GetPolicyByID(c context.Context, id string) (*Policy, error) CreatePolicy(c context.Context, policy *Policy) error UpdatePolicy(c context.Context, policy *Policy) error ExpiredObjectsByPolicy(c context.Context, policyId string) error GetServiceByID(c context.Context, id string) (*Service, error) GetServiceByExternalId(c context.Context, externalId string) (*Service, error) GetObjectServiceMesh(c context.Context, objectId string) ([]*ObjectServiceMess, error) }
type MockKontrol ¶
type MockKontrol struct {
// contains filtered or unexported fields
}
MockKontrol is a mock of Kontrol interface.
func NewMockKontrol ¶
func NewMockKontrol(ctrl *gomock.Controller) *MockKontrol
NewMockKontrol creates a new mock instance.
func (*MockKontrol) AddSimpleObjectWithDefaultPolicy ¶
func (m *MockKontrol) AddSimpleObjectWithDefaultPolicy(ctx context.Context, externalid, serviceid, servicekey string) (*ObjectPermission, error)
AddSimpleObjectWithDefaultPolicy mocks base method.
func (*MockKontrol) CreateCert ¶
func (m *MockKontrol) CreateCert(obj *Object, policy, enforce []*Policy, objectExtendServiceIds []string) (*CertForSign, string, string, error)
CreateCert mocks base method.
func (*MockKontrol) CreatePolicy ¶
CreatePolicy mocks base method.
func (*MockKontrol) EXPECT ¶
func (m *MockKontrol) EXPECT() *MockKontrolMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockKontrol) GetObjectExtendServiceIds ¶
func (m *MockKontrol) GetObjectExtendServiceIds(ctx context.Context, objId string) ([]string, error)
GetObjectExtendServiceIds mocks base method.
func (*MockKontrol) IssueCertForClient ¶
func (m *MockKontrol) IssueCertForClient(ctx context.Context, externalID, serID string) (*ObjectPermission, error)
IssueCertForClient mocks base method.
func (*MockKontrol) IssueCertForService ¶
func (m *MockKontrol) IssueCertForService(ctx context.Context, objID, externalid string) (*ObjectPermission, error)
IssueCertForService mocks base method.
func (*MockKontrol) UpdateObject ¶
UpdateObject mocks base method.
func (*MockKontrol) UpdatePolicy ¶
UpdatePolicy mocks base method.
func (*MockKontrol) ValidateToken ¶
func (m *MockKontrol) ValidateToken(c context.Context, token, reqPath, reqMethod string) (*Object, error)
ValidateToken mocks base method.
type MockKontrolMockRecorder ¶
type MockKontrolMockRecorder struct {
// contains filtered or unexported fields
}
MockKontrolMockRecorder is the mock recorder for MockKontrol.
func (*MockKontrolMockRecorder) AddSimpleObjectWithDefaultPolicy ¶
func (mr *MockKontrolMockRecorder) AddSimpleObjectWithDefaultPolicy(ctx, externalid, serviceid, servicekey interface{}) *gomock.Call
AddSimpleObjectWithDefaultPolicy indicates an expected call of AddSimpleObjectWithDefaultPolicy.
func (*MockKontrolMockRecorder) CreateCert ¶
func (mr *MockKontrolMockRecorder) CreateCert(obj, policy, enforce, objectExtendServiceIds interface{}) *gomock.Call
CreateCert indicates an expected call of CreateCert.
func (*MockKontrolMockRecorder) CreatePolicy ¶
func (mr *MockKontrolMockRecorder) CreatePolicy(ctx, servicekey, policy interface{}) *gomock.Call
CreatePolicy indicates an expected call of CreatePolicy.
func (*MockKontrolMockRecorder) GetObjectExtendServiceIds ¶
func (mr *MockKontrolMockRecorder) GetObjectExtendServiceIds(ctx, objId interface{}) *gomock.Call
GetObjectExtendServiceIds indicates an expected call of GetObjectExtendServiceIds.
func (*MockKontrolMockRecorder) IssueCertForClient ¶
func (mr *MockKontrolMockRecorder) IssueCertForClient(ctx, externalID, serID interface{}) *gomock.Call
IssueCertForClient indicates an expected call of IssueCertForClient.
func (*MockKontrolMockRecorder) IssueCertForService ¶
func (mr *MockKontrolMockRecorder) IssueCertForService(ctx, objID, externalid interface{}) *gomock.Call
IssueCertForService indicates an expected call of IssueCertForService.
func (*MockKontrolMockRecorder) UpdateObject ¶
func (mr *MockKontrolMockRecorder) UpdateObject(ctx, obj, servicekey interface{}) *gomock.Call
UpdateObject indicates an expected call of UpdateObject.
func (*MockKontrolMockRecorder) UpdatePolicy ¶
func (mr *MockKontrolMockRecorder) UpdatePolicy(ctx, servicekey, policy interface{}) *gomock.Call
UpdatePolicy indicates an expected call of UpdatePolicy.
func (*MockKontrolMockRecorder) ValidateToken ¶
func (mr *MockKontrolMockRecorder) ValidateToken(c, token, reqPath, reqMethod interface{}) *gomock.Call
ValidateToken indicates an expected call of ValidateToken.
type MockKontrolStore ¶
type MockKontrolStore struct {
// contains filtered or unexported fields
}
MockKontrolStore is a mock of KontrolStore interface.
func NewMockKontrolStore ¶
func NewMockKontrolStore(ctrl *gomock.Controller) *MockKontrolStore
NewMockKontrolStore creates a new mock instance.
func (*MockKontrolStore) CreateObject ¶
func (m *MockKontrolStore) CreateObject(c context.Context, obj *Object) error
CreateObject mocks base method.
func (*MockKontrolStore) CreatePolicy ¶
func (m *MockKontrolStore) CreatePolicy(c context.Context, policy *Policy) error
CreatePolicy mocks base method.
func (*MockKontrolStore) EXPECT ¶
func (m *MockKontrolStore) EXPECT() *MockKontrolStoreMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockKontrolStore) ExpiredObjectsByPolicy ¶
func (m *MockKontrolStore) ExpiredObjectsByPolicy(c context.Context, policyId string) error
ExpiredObjectsByPolicy mocks base method.
func (*MockKontrolStore) GetObjectByExternalID ¶
func (m *MockKontrolStore) GetObjectByExternalID(c context.Context, extid, serviceid string) (*Object, error)
GetObjectByExternalID mocks base method.
func (*MockKontrolStore) GetObjectByID ¶
GetObjectByID mocks base method.
func (*MockKontrolStore) GetObjectByToken ¶
func (m *MockKontrolStore) GetObjectByToken(c context.Context, token string, timestamp int64) (*Object, error)
GetObjectByToken mocks base method.
func (*MockKontrolStore) GetObjectServiceMesh ¶
func (m *MockKontrolStore) GetObjectServiceMesh(c context.Context, objectId string) ([]*ObjectServiceMess, error)
GetObjectServiceMesh mocks base method.
func (*MockKontrolStore) GetPolicyByID ¶
GetPolicyByID mocks base method.
func (*MockKontrolStore) GetServiceByExternalId ¶
func (m *MockKontrolStore) GetServiceByExternalId(c context.Context, externalId string) (*Service, error)
GetServiceByExternalId mocks base method.
func (*MockKontrolStore) GetServiceByID ¶
GetServiceByID mocks base method.
func (*MockKontrolStore) UpdateObject ¶
func (m *MockKontrolStore) UpdateObject(c context.Context, obj *Object) error
UpdateObject mocks base method.
func (*MockKontrolStore) UpdatePolicy ¶
func (m *MockKontrolStore) UpdatePolicy(c context.Context, policy *Policy) error
UpdatePolicy mocks base method.
type MockKontrolStoreMockRecorder ¶
type MockKontrolStoreMockRecorder struct {
// contains filtered or unexported fields
}
MockKontrolStoreMockRecorder is the mock recorder for MockKontrolStore.
func (*MockKontrolStoreMockRecorder) CreateObject ¶
func (mr *MockKontrolStoreMockRecorder) CreateObject(c, obj interface{}) *gomock.Call
CreateObject indicates an expected call of CreateObject.
func (*MockKontrolStoreMockRecorder) CreatePolicy ¶
func (mr *MockKontrolStoreMockRecorder) CreatePolicy(c, policy interface{}) *gomock.Call
CreatePolicy indicates an expected call of CreatePolicy.
func (*MockKontrolStoreMockRecorder) ExpiredObjectsByPolicy ¶
func (mr *MockKontrolStoreMockRecorder) ExpiredObjectsByPolicy(c, policyId interface{}) *gomock.Call
ExpiredObjectsByPolicy indicates an expected call of ExpiredObjectsByPolicy.
func (*MockKontrolStoreMockRecorder) GetObjectByExternalID ¶
func (mr *MockKontrolStoreMockRecorder) GetObjectByExternalID(c, extid, serviceid interface{}) *gomock.Call
GetObjectByExternalID indicates an expected call of GetObjectByExternalID.
func (*MockKontrolStoreMockRecorder) GetObjectByID ¶
func (mr *MockKontrolStoreMockRecorder) GetObjectByID(c, id interface{}) *gomock.Call
GetObjectByID indicates an expected call of GetObjectByID.
func (*MockKontrolStoreMockRecorder) GetObjectByToken ¶
func (mr *MockKontrolStoreMockRecorder) GetObjectByToken(c, token, timestamp interface{}) *gomock.Call
GetObjectByToken indicates an expected call of GetObjectByToken.
func (*MockKontrolStoreMockRecorder) GetObjectServiceMesh ¶
func (mr *MockKontrolStoreMockRecorder) GetObjectServiceMesh(c, objectId interface{}) *gomock.Call
GetObjectServiceMesh indicates an expected call of GetObjectServiceMesh.
func (*MockKontrolStoreMockRecorder) GetPolicyByID ¶
func (mr *MockKontrolStoreMockRecorder) GetPolicyByID(c, id interface{}) *gomock.Call
GetPolicyByID indicates an expected call of GetPolicyByID.
func (*MockKontrolStoreMockRecorder) GetServiceByExternalId ¶
func (mr *MockKontrolStoreMockRecorder) GetServiceByExternalId(c, externalId interface{}) *gomock.Call
GetServiceByExternalId indicates an expected call of GetServiceByExternalId.
func (*MockKontrolStoreMockRecorder) GetServiceByID ¶
func (mr *MockKontrolStoreMockRecorder) GetServiceByID(c, id interface{}) *gomock.Call
GetServiceByID indicates an expected call of GetServiceByID.
func (*MockKontrolStoreMockRecorder) UpdateObject ¶
func (mr *MockKontrolStoreMockRecorder) UpdateObject(c, obj interface{}) *gomock.Call
UpdateObject indicates an expected call of UpdateObject.
func (*MockKontrolStoreMockRecorder) UpdatePolicy ¶
func (mr *MockKontrolStoreMockRecorder) UpdatePolicy(c, policy interface{}) *gomock.Call
UpdatePolicy indicates an expected call of UpdatePolicy.
type Object ¶
type Object struct { ID string GlobalID string ExternalID string ServiceID string Status string Attributes map[string]interface{} // ignore for now, extension Token string ExpiryDate int64 ApplyPolicy []*Policy }
Object is basic entity
type ObjectPermission ¶
ObjectPermission Contains object and it's permission
type ObjectServiceMess ¶
ObjectServiceMess support for grand permission access cross service