|
@@ -100,70 +100,70 @@ type Auth interface {
|
|
|
RoleDelete(ctx context.Context, role string) (*AuthRoleDeleteResponse, error)
|
|
RoleDelete(ctx context.Context, role string) (*AuthRoleDeleteResponse, error)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-type auth struct {
|
|
|
|
|
|
|
+type authClient struct {
|
|
|
remote pb.AuthClient
|
|
remote pb.AuthClient
|
|
|
callOpts []grpc.CallOption
|
|
callOpts []grpc.CallOption
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func NewAuth(c *Client) Auth {
|
|
func NewAuth(c *Client) Auth {
|
|
|
- api := &auth{remote: RetryAuthClient(c)}
|
|
|
|
|
|
|
+ api := &authClient{remote: RetryAuthClient(c)}
|
|
|
if c != nil {
|
|
if c != nil {
|
|
|
api.callOpts = c.callOpts
|
|
api.callOpts = c.callOpts
|
|
|
}
|
|
}
|
|
|
return api
|
|
return api
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-func (auth *auth) AuthEnable(ctx context.Context) (*AuthEnableResponse, error) {
|
|
|
|
|
|
|
+func (auth *authClient) AuthEnable(ctx context.Context) (*AuthEnableResponse, error) {
|
|
|
resp, err := auth.remote.AuthEnable(ctx, &pb.AuthEnableRequest{}, auth.callOpts...)
|
|
resp, err := auth.remote.AuthEnable(ctx, &pb.AuthEnableRequest{}, auth.callOpts...)
|
|
|
return (*AuthEnableResponse)(resp), toErr(ctx, err)
|
|
return (*AuthEnableResponse)(resp), toErr(ctx, err)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-func (auth *auth) AuthDisable(ctx context.Context) (*AuthDisableResponse, error) {
|
|
|
|
|
|
|
+func (auth *authClient) AuthDisable(ctx context.Context) (*AuthDisableResponse, error) {
|
|
|
resp, err := auth.remote.AuthDisable(ctx, &pb.AuthDisableRequest{}, auth.callOpts...)
|
|
resp, err := auth.remote.AuthDisable(ctx, &pb.AuthDisableRequest{}, auth.callOpts...)
|
|
|
return (*AuthDisableResponse)(resp), toErr(ctx, err)
|
|
return (*AuthDisableResponse)(resp), toErr(ctx, err)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-func (auth *auth) UserAdd(ctx context.Context, name string, password string) (*AuthUserAddResponse, error) {
|
|
|
|
|
|
|
+func (auth *authClient) UserAdd(ctx context.Context, name string, password string) (*AuthUserAddResponse, error) {
|
|
|
resp, err := auth.remote.UserAdd(ctx, &pb.AuthUserAddRequest{Name: name, Password: password}, auth.callOpts...)
|
|
resp, err := auth.remote.UserAdd(ctx, &pb.AuthUserAddRequest{Name: name, Password: password}, auth.callOpts...)
|
|
|
return (*AuthUserAddResponse)(resp), toErr(ctx, err)
|
|
return (*AuthUserAddResponse)(resp), toErr(ctx, err)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-func (auth *auth) UserDelete(ctx context.Context, name string) (*AuthUserDeleteResponse, error) {
|
|
|
|
|
|
|
+func (auth *authClient) UserDelete(ctx context.Context, name string) (*AuthUserDeleteResponse, error) {
|
|
|
resp, err := auth.remote.UserDelete(ctx, &pb.AuthUserDeleteRequest{Name: name}, auth.callOpts...)
|
|
resp, err := auth.remote.UserDelete(ctx, &pb.AuthUserDeleteRequest{Name: name}, auth.callOpts...)
|
|
|
return (*AuthUserDeleteResponse)(resp), toErr(ctx, err)
|
|
return (*AuthUserDeleteResponse)(resp), toErr(ctx, err)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-func (auth *auth) UserChangePassword(ctx context.Context, name string, password string) (*AuthUserChangePasswordResponse, error) {
|
|
|
|
|
|
|
+func (auth *authClient) UserChangePassword(ctx context.Context, name string, password string) (*AuthUserChangePasswordResponse, error) {
|
|
|
resp, err := auth.remote.UserChangePassword(ctx, &pb.AuthUserChangePasswordRequest{Name: name, Password: password}, auth.callOpts...)
|
|
resp, err := auth.remote.UserChangePassword(ctx, &pb.AuthUserChangePasswordRequest{Name: name, Password: password}, auth.callOpts...)
|
|
|
return (*AuthUserChangePasswordResponse)(resp), toErr(ctx, err)
|
|
return (*AuthUserChangePasswordResponse)(resp), toErr(ctx, err)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-func (auth *auth) UserGrantRole(ctx context.Context, user string, role string) (*AuthUserGrantRoleResponse, error) {
|
|
|
|
|
|
|
+func (auth *authClient) UserGrantRole(ctx context.Context, user string, role string) (*AuthUserGrantRoleResponse, error) {
|
|
|
resp, err := auth.remote.UserGrantRole(ctx, &pb.AuthUserGrantRoleRequest{User: user, Role: role}, auth.callOpts...)
|
|
resp, err := auth.remote.UserGrantRole(ctx, &pb.AuthUserGrantRoleRequest{User: user, Role: role}, auth.callOpts...)
|
|
|
return (*AuthUserGrantRoleResponse)(resp), toErr(ctx, err)
|
|
return (*AuthUserGrantRoleResponse)(resp), toErr(ctx, err)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-func (auth *auth) UserGet(ctx context.Context, name string) (*AuthUserGetResponse, error) {
|
|
|
|
|
|
|
+func (auth *authClient) UserGet(ctx context.Context, name string) (*AuthUserGetResponse, error) {
|
|
|
resp, err := auth.remote.UserGet(ctx, &pb.AuthUserGetRequest{Name: name}, auth.callOpts...)
|
|
resp, err := auth.remote.UserGet(ctx, &pb.AuthUserGetRequest{Name: name}, auth.callOpts...)
|
|
|
return (*AuthUserGetResponse)(resp), toErr(ctx, err)
|
|
return (*AuthUserGetResponse)(resp), toErr(ctx, err)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-func (auth *auth) UserList(ctx context.Context) (*AuthUserListResponse, error) {
|
|
|
|
|
|
|
+func (auth *authClient) UserList(ctx context.Context) (*AuthUserListResponse, error) {
|
|
|
resp, err := auth.remote.UserList(ctx, &pb.AuthUserListRequest{}, auth.callOpts...)
|
|
resp, err := auth.remote.UserList(ctx, &pb.AuthUserListRequest{}, auth.callOpts...)
|
|
|
return (*AuthUserListResponse)(resp), toErr(ctx, err)
|
|
return (*AuthUserListResponse)(resp), toErr(ctx, err)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-func (auth *auth) UserRevokeRole(ctx context.Context, name string, role string) (*AuthUserRevokeRoleResponse, error) {
|
|
|
|
|
|
|
+func (auth *authClient) UserRevokeRole(ctx context.Context, name string, role string) (*AuthUserRevokeRoleResponse, error) {
|
|
|
resp, err := auth.remote.UserRevokeRole(ctx, &pb.AuthUserRevokeRoleRequest{Name: name, Role: role}, auth.callOpts...)
|
|
resp, err := auth.remote.UserRevokeRole(ctx, &pb.AuthUserRevokeRoleRequest{Name: name, Role: role}, auth.callOpts...)
|
|
|
return (*AuthUserRevokeRoleResponse)(resp), toErr(ctx, err)
|
|
return (*AuthUserRevokeRoleResponse)(resp), toErr(ctx, err)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-func (auth *auth) RoleAdd(ctx context.Context, name string) (*AuthRoleAddResponse, error) {
|
|
|
|
|
|
|
+func (auth *authClient) RoleAdd(ctx context.Context, name string) (*AuthRoleAddResponse, error) {
|
|
|
resp, err := auth.remote.RoleAdd(ctx, &pb.AuthRoleAddRequest{Name: name}, auth.callOpts...)
|
|
resp, err := auth.remote.RoleAdd(ctx, &pb.AuthRoleAddRequest{Name: name}, auth.callOpts...)
|
|
|
return (*AuthRoleAddResponse)(resp), toErr(ctx, err)
|
|
return (*AuthRoleAddResponse)(resp), toErr(ctx, err)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-func (auth *auth) RoleGrantPermission(ctx context.Context, name string, key, rangeEnd string, permType PermissionType) (*AuthRoleGrantPermissionResponse, error) {
|
|
|
|
|
|
|
+func (auth *authClient) RoleGrantPermission(ctx context.Context, name string, key, rangeEnd string, permType PermissionType) (*AuthRoleGrantPermissionResponse, error) {
|
|
|
perm := &authpb.Permission{
|
|
perm := &authpb.Permission{
|
|
|
Key: []byte(key),
|
|
Key: []byte(key),
|
|
|
RangeEnd: []byte(rangeEnd),
|
|
RangeEnd: []byte(rangeEnd),
|
|
@@ -173,22 +173,22 @@ func (auth *auth) RoleGrantPermission(ctx context.Context, name string, key, ran
|
|
|
return (*AuthRoleGrantPermissionResponse)(resp), toErr(ctx, err)
|
|
return (*AuthRoleGrantPermissionResponse)(resp), toErr(ctx, err)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-func (auth *auth) RoleGet(ctx context.Context, role string) (*AuthRoleGetResponse, error) {
|
|
|
|
|
|
|
+func (auth *authClient) RoleGet(ctx context.Context, role string) (*AuthRoleGetResponse, error) {
|
|
|
resp, err := auth.remote.RoleGet(ctx, &pb.AuthRoleGetRequest{Role: role}, auth.callOpts...)
|
|
resp, err := auth.remote.RoleGet(ctx, &pb.AuthRoleGetRequest{Role: role}, auth.callOpts...)
|
|
|
return (*AuthRoleGetResponse)(resp), toErr(ctx, err)
|
|
return (*AuthRoleGetResponse)(resp), toErr(ctx, err)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-func (auth *auth) RoleList(ctx context.Context) (*AuthRoleListResponse, error) {
|
|
|
|
|
|
|
+func (auth *authClient) RoleList(ctx context.Context) (*AuthRoleListResponse, error) {
|
|
|
resp, err := auth.remote.RoleList(ctx, &pb.AuthRoleListRequest{}, auth.callOpts...)
|
|
resp, err := auth.remote.RoleList(ctx, &pb.AuthRoleListRequest{}, auth.callOpts...)
|
|
|
return (*AuthRoleListResponse)(resp), toErr(ctx, err)
|
|
return (*AuthRoleListResponse)(resp), toErr(ctx, err)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-func (auth *auth) RoleRevokePermission(ctx context.Context, role string, key, rangeEnd string) (*AuthRoleRevokePermissionResponse, error) {
|
|
|
|
|
|
|
+func (auth *authClient) RoleRevokePermission(ctx context.Context, role string, key, rangeEnd string) (*AuthRoleRevokePermissionResponse, error) {
|
|
|
resp, err := auth.remote.RoleRevokePermission(ctx, &pb.AuthRoleRevokePermissionRequest{Role: role, Key: []byte(key), RangeEnd: []byte(rangeEnd)}, auth.callOpts...)
|
|
resp, err := auth.remote.RoleRevokePermission(ctx, &pb.AuthRoleRevokePermissionRequest{Role: role, Key: []byte(key), RangeEnd: []byte(rangeEnd)}, auth.callOpts...)
|
|
|
return (*AuthRoleRevokePermissionResponse)(resp), toErr(ctx, err)
|
|
return (*AuthRoleRevokePermissionResponse)(resp), toErr(ctx, err)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-func (auth *auth) RoleDelete(ctx context.Context, role string) (*AuthRoleDeleteResponse, error) {
|
|
|
|
|
|
|
+func (auth *authClient) RoleDelete(ctx context.Context, role string) (*AuthRoleDeleteResponse, error) {
|
|
|
resp, err := auth.remote.RoleDelete(ctx, &pb.AuthRoleDeleteRequest{Role: role}, auth.callOpts...)
|
|
resp, err := auth.remote.RoleDelete(ctx, &pb.AuthRoleDeleteRequest{Role: role}, auth.callOpts...)
|
|
|
return (*AuthRoleDeleteResponse)(resp), toErr(ctx, err)
|
|
return (*AuthRoleDeleteResponse)(resp), toErr(ctx, err)
|
|
|
}
|
|
}
|