mirror of
https://github.com/paralus/paralus.git
synced 2026-08-24 15:47:19 +00:00
Merge pull request #125 from RafayLabs/no-restart
Fix casbin caching issues
This commit is contained in:
@@ -233,16 +233,9 @@ func prepareConfig(config *Config) error {
|
||||
return fmt.Errorf("invalid scheme %s", config.Scheme)
|
||||
}
|
||||
|
||||
if config.Scheme == "" && strings.HasPrefix(config.Addr, "localhost") {
|
||||
config.Scheme = schemeHTTP
|
||||
}
|
||||
|
||||
if config.Scheme == "" && strings.Index(config.Addr, "rafay.local") > 0 {
|
||||
config.Scheme = schemeHTTP
|
||||
}
|
||||
|
||||
if config.Scheme == "" {
|
||||
return fmt.Errorf("empty Schema not allowed")
|
||||
_log.Debug("scheme not defined, defaulting to http")
|
||||
config.Scheme = schemeHTTP
|
||||
}
|
||||
|
||||
switch config.Mode {
|
||||
|
||||
@@ -33,6 +33,7 @@ type authzService struct {
|
||||
}
|
||||
|
||||
func NewAuthzService(db *bun.DB, en *casbin.CachedEnforcer) AuthzService {
|
||||
// en.EnableCache(false) // disables caching in casbin
|
||||
return &authzService{
|
||||
db: db,
|
||||
enforcer: en,
|
||||
@@ -257,6 +258,7 @@ func (s *authzService) CreatePolicies(ctx context.Context, p *authzpbv1.Policies
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, err.Error())
|
||||
}
|
||||
s.enforcer.InvalidateCache()
|
||||
return &authzpbv1.BoolReply{Res: res}, nil
|
||||
}
|
||||
|
||||
@@ -266,6 +268,7 @@ func (s *authzService) DeletePolicies(ctx context.Context, p *authzpbv1.Policy)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, err.Error())
|
||||
}
|
||||
s.enforcer.InvalidateCache()
|
||||
return &authzpbv1.BoolReply{Res: res}, nil
|
||||
}
|
||||
|
||||
@@ -289,6 +292,7 @@ func (s *authzService) CreateUserGroups(ctx context.Context, p *authzpbv1.UserGr
|
||||
return nil, status.Errorf(codes.Internal, err.Error())
|
||||
}
|
||||
|
||||
s.enforcer.InvalidateCache()
|
||||
return &authzpbv1.BoolReply{Res: res}, nil
|
||||
}
|
||||
|
||||
@@ -299,6 +303,7 @@ func (s *authzService) DeleteUserGroups(ctx context.Context, p *authzpbv1.UserGr
|
||||
return nil, status.Errorf(codes.Internal, err.Error())
|
||||
}
|
||||
|
||||
s.enforcer.InvalidateCache()
|
||||
return &authzpbv1.BoolReply{Res: res}, nil
|
||||
}
|
||||
|
||||
@@ -323,6 +328,7 @@ func (s *authzService) CreateRolePermissionMappings(ctx context.Context, p *auth
|
||||
return nil, status.Errorf(codes.Internal, err.Error())
|
||||
}
|
||||
|
||||
s.enforcer.InvalidateCache()
|
||||
return &authzpbv1.BoolReply{Res: res}, nil
|
||||
}
|
||||
|
||||
@@ -332,5 +338,6 @@ func (s *authzService) DeleteRolePermissionMappings(ctx context.Context, p *auth
|
||||
return nil, status.Errorf(codes.Internal, err.Error())
|
||||
}
|
||||
|
||||
s.enforcer.InvalidateCache()
|
||||
return &authzpbv1.BoolReply{Res: res}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user