mirror of
https://github.com/paralus/paralus.git
synced 2026-05-25 01:33:12 +00:00
* Upgrade kratos service to v0.10.1 Signed-off-by: Akshay Gaikwad <akgaikwad001@gmail.com> * Upgrade kratos-client-go to v0.10.1 Signed-off-by: Akshay Gaikwad <akgaikwad001@gmail.com> * generate password feature for kratos admin creation Signed-off-by: Akshay Gaikwad <akgaikwad001@gmail.com> * Add forceReset property in user spec Signed-off-by: Akshay Gaikwad <akgaikwad001@gmail.com> * added forcereset in the init script Signed-off-by: mabhi <abhijit.mukherjee@infracloud.io> * Resolve conflicts Signed-off-by: Akshay Gaikwad <akgaikwad001@gmail.com> * Stdout default admin password in initialize script Signed-off-by: Akshay Gaikwad <akgaikwad001@gmail.com> * setting password for new user and sending default password in create user response Signed-off-by: mabhi <abhijit.mukherjee@infracloud.io> * added new endpoint to service force reset flag update after resetting complete outside authz Signed-off-by: mabhi <abhijit.mukherjee@infracloud.io> * removed unnecessary overhead in the forcereset endpoint and updated user type proto to remove unused fields Signed-off-by: mabhi <abhijit.mukherjee@infracloud.io>
88 lines
3.1 KiB
Go
88 lines
3.1 KiB
Go
package service
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
|
|
kr "github.com/paralus/paralus/internal/provider/kratos"
|
|
types "github.com/paralus/paralus/proto/types/authz"
|
|
)
|
|
|
|
type ApUpdate struct {
|
|
id string
|
|
traits map[string]interface{}
|
|
}
|
|
type mockAuthProvider struct {
|
|
c []map[string]interface{}
|
|
u []ApUpdate
|
|
r []string
|
|
d []string
|
|
}
|
|
|
|
func (m *mockAuthProvider) Create(ctx context.Context, pass string, traits map[string]interface{}, fr bool) (string, error) {
|
|
m.c = append(m.c, traits)
|
|
return strings.Split(traits["email"].(string), "user-")[1], nil
|
|
}
|
|
func (m *mockAuthProvider) Update(ctx context.Context, id string, traits map[string]interface{}, fr bool) error {
|
|
m.u = append(m.u, ApUpdate{id: id, traits: traits})
|
|
return nil
|
|
}
|
|
func (m *mockAuthProvider) GetRecoveryLink(ctx context.Context, id string) (string, error) {
|
|
m.r = append(m.r, id)
|
|
return "https://recoverme.testing/" + id, nil
|
|
}
|
|
func (m *mockAuthProvider) Delete(ctx context.Context, id string) error {
|
|
m.d = append(m.d, id)
|
|
return nil
|
|
}
|
|
|
|
func (m *mockAuthProvider) GetPublicMetadata(context.Context, string) (*kr.IdentityPublicMetadata, error) {
|
|
return &kr.IdentityPublicMetadata{}, nil
|
|
}
|
|
|
|
type mockAuthzClient struct {
|
|
cp []*types.Policies
|
|
dp []*types.Policy
|
|
cug []*types.UserGroups
|
|
dug []*types.UserGroup
|
|
crpm []*types.RolePermissionMappingList
|
|
drpm []*types.FilteredRolePermissionMapping
|
|
}
|
|
|
|
func (c *mockAuthzClient) Enforce(ctx context.Context, in *types.EnforceRequest) (*types.BoolReply, error) {
|
|
return &types.BoolReply{Res: true}, nil
|
|
}
|
|
func (c *mockAuthzClient) ListPolicies(ctx context.Context, in *types.Policy) (*types.Policies, error) {
|
|
return &types.Policies{}, nil
|
|
}
|
|
func (c *mockAuthzClient) CreatePolicies(ctx context.Context, in *types.Policies) (*types.BoolReply, error) {
|
|
c.cp = append(c.cp, in)
|
|
return &types.BoolReply{Res: true}, nil
|
|
}
|
|
func (c *mockAuthzClient) DeletePolicies(ctx context.Context, in *types.Policy) (*types.BoolReply, error) {
|
|
c.dp = append(c.dp, in)
|
|
return &types.BoolReply{Res: true}, nil
|
|
}
|
|
func (c *mockAuthzClient) ListUserGroups(ctx context.Context, in *types.UserGroup) (*types.UserGroups, error) {
|
|
return &types.UserGroups{}, nil
|
|
}
|
|
func (c *mockAuthzClient) CreateUserGroups(ctx context.Context, in *types.UserGroups) (*types.BoolReply, error) {
|
|
c.cug = append(c.cug, in)
|
|
return &types.BoolReply{Res: true}, nil
|
|
}
|
|
func (c *mockAuthzClient) DeleteUserGroups(ctx context.Context, in *types.UserGroup) (*types.BoolReply, error) {
|
|
c.dug = append(c.dug, in)
|
|
return &types.BoolReply{Res: true}, nil
|
|
}
|
|
func (c *mockAuthzClient) ListRolePermissionMappings(ctx context.Context, in *types.FilteredRolePermissionMapping) (*types.RolePermissionMappingList, error) {
|
|
return &types.RolePermissionMappingList{}, nil
|
|
}
|
|
func (c *mockAuthzClient) CreateRolePermissionMappings(ctx context.Context, in *types.RolePermissionMappingList) (*types.BoolReply, error) {
|
|
c.crpm = append(c.crpm, in)
|
|
return &types.BoolReply{Res: true}, nil
|
|
}
|
|
func (c *mockAuthzClient) DeleteRolePermissionMappings(ctx context.Context, in *types.FilteredRolePermissionMapping) (*types.BoolReply, error) {
|
|
c.drpm = append(c.drpm, in)
|
|
return &types.BoolReply{Res: true}, nil
|
|
}
|