Fix multiline function call style violations
Expand mixed inline/multiline function calls so each argument is on its own line, matching the one-argument-per-line rule. Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
@@ -250,7 +250,8 @@ func (s *OrganizationService) UpdateMempership(
|
||||
scope := coredata.NewScopeFromObjectID(organizationID)
|
||||
|
||||
membership := coredata.Membership{}
|
||||
if err := s.pg.WithTx(ctx,
|
||||
if err := s.pg.WithTx(
|
||||
ctx,
|
||||
func(tx pg.Conn) error {
|
||||
|
||||
if err := membership.LoadByID(ctx, tx, scope, membershipID); err != nil {
|
||||
|
||||
@@ -21,7 +21,9 @@ import (
|
||||
func TestEvaluator_Evaluate_AllowDecision(t *testing.T) {
|
||||
evaluator := NewEvaluator()
|
||||
|
||||
policy := NewPolicy("test", "Test Policy",
|
||||
policy := NewPolicy(
|
||||
"test",
|
||||
"Test Policy",
|
||||
Allow("iam:identity:get", "iam:identity:update"),
|
||||
)
|
||||
|
||||
@@ -68,7 +70,9 @@ func TestEvaluator_Evaluate_AllowDecision(t *testing.T) {
|
||||
func TestEvaluator_Evaluate_DenyDecision(t *testing.T) {
|
||||
evaluator := NewEvaluator()
|
||||
|
||||
policy := NewPolicy("test", "Test Policy",
|
||||
policy := NewPolicy(
|
||||
"test",
|
||||
"Test Policy",
|
||||
Allow("iam:*:*"),
|
||||
Deny("iam:organization:delete").WithSID("deny-org-delete"),
|
||||
)
|
||||
@@ -112,10 +116,14 @@ func TestEvaluator_Evaluate_DenyWinsOverAllow(t *testing.T) {
|
||||
evaluator := NewEvaluator()
|
||||
|
||||
// Two policies: one allows, one denies the same action
|
||||
allowPolicy := NewPolicy("allow", "Allow Policy",
|
||||
allowPolicy := NewPolicy(
|
||||
"allow",
|
||||
"Allow Policy",
|
||||
Allow("iam:organization:delete"),
|
||||
)
|
||||
denyPolicy := NewPolicy("deny", "Deny Policy",
|
||||
denyPolicy := NewPolicy(
|
||||
"deny",
|
||||
"Deny Policy",
|
||||
Deny("iam:organization:delete"),
|
||||
)
|
||||
|
||||
@@ -147,7 +155,9 @@ func TestEvaluator_Evaluate_WithConditions(t *testing.T) {
|
||||
evaluator := NewEvaluator()
|
||||
|
||||
// Policy that only allows users to update their own identity
|
||||
selfManagePolicy := NewPolicy("self-manage", "Self Manage",
|
||||
selfManagePolicy := NewPolicy(
|
||||
"self-manage",
|
||||
"Self Manage",
|
||||
Allow("iam:identity:update").
|
||||
When(Equals("principal.id", "resource.id")),
|
||||
)
|
||||
@@ -194,7 +204,9 @@ func TestEvaluator_Evaluate_MultipleConditions(t *testing.T) {
|
||||
evaluator := NewEvaluator()
|
||||
|
||||
// Policy that requires both conditions to be met
|
||||
policy := NewPolicy("test", "Test",
|
||||
policy := NewPolicy(
|
||||
"test",
|
||||
"Test",
|
||||
Allow("documents:document:update").
|
||||
When(
|
||||
Equals("principal.id", "resource.owner_id"),
|
||||
@@ -358,7 +370,9 @@ func TestEvaluator_Evaluate_NilPolicies(t *testing.T) {
|
||||
func TestEvaluator_Evaluate_MatchedStatementAndPolicy(t *testing.T) {
|
||||
evaluator := NewEvaluator()
|
||||
|
||||
policy := NewPolicy("test-policy", "Test Policy",
|
||||
policy := NewPolicy(
|
||||
"test-policy",
|
||||
"Test Policy",
|
||||
Allow("iam:identity:get").WithSID("allow-get"),
|
||||
Deny("iam:identity:delete").WithSID("deny-delete"),
|
||||
)
|
||||
|
||||
@@ -22,24 +22,32 @@ import (
|
||||
|
||||
func Example_definingPolicies() {
|
||||
// Define a viewer policy - can read everything
|
||||
viewerPolicy := policy.NewPolicy("viewer", "Viewer Policy",
|
||||
viewerPolicy := policy.NewPolicy(
|
||||
"viewer",
|
||||
"Viewer Policy",
|
||||
policy.Allow("*:*:read", "*:*:list"),
|
||||
).WithDescription("Read-only access to all resources")
|
||||
|
||||
// Define an admin policy - can do everything except delete organization
|
||||
adminPolicy := policy.NewPolicy("admin", "Admin Policy",
|
||||
adminPolicy := policy.NewPolicy(
|
||||
"admin",
|
||||
"Admin Policy",
|
||||
policy.Allow("*"),
|
||||
policy.Deny("iam:organization:delete"),
|
||||
).WithDescription("Full access except organization deletion")
|
||||
|
||||
// Define a self-manage policy - users can manage their own identity
|
||||
selfManagePolicy := policy.NewPolicy("self-manage", "Self Management Policy",
|
||||
selfManagePolicy := policy.NewPolicy(
|
||||
"self-manage",
|
||||
"Self Management Policy",
|
||||
policy.Allow("iam:identity:get", "iam:identity:update").
|
||||
When(policy.Equals("principal.id", "resource.id")),
|
||||
).WithDescription("Users can view and update their own identity")
|
||||
|
||||
// Define a document owner policy - owners can do anything to their documents
|
||||
documentOwnerPolicy := policy.NewPolicy("doc-owner", "Document Owner Policy",
|
||||
documentOwnerPolicy := policy.NewPolicy(
|
||||
"doc-owner",
|
||||
"Document Owner Policy",
|
||||
policy.Allow("documents:document:*").
|
||||
When(policy.Equals("principal.id", "resource.owner_id")),
|
||||
).WithDescription("Document owners have full control over their documents")
|
||||
@@ -60,11 +68,15 @@ func Example_evaluatingPolicies() {
|
||||
evaluator := policy.NewEvaluator()
|
||||
|
||||
// Define policies
|
||||
viewerPolicy := policy.NewPolicy("viewer", "Viewer",
|
||||
viewerPolicy := policy.NewPolicy(
|
||||
"viewer",
|
||||
"Viewer",
|
||||
policy.Allow("*:*:read", "*:*:list"),
|
||||
)
|
||||
|
||||
adminPolicy := policy.NewPolicy("admin", "Admin",
|
||||
adminPolicy := policy.NewPolicy(
|
||||
"admin",
|
||||
"Admin",
|
||||
policy.Allow("*"),
|
||||
policy.Deny("iam:organization:delete").WithSID("prevent-org-deletion"),
|
||||
)
|
||||
@@ -119,7 +131,9 @@ func Example_conditionBasedAccess() {
|
||||
evaluator := policy.NewEvaluator()
|
||||
|
||||
// Policy: users can only update their own profile
|
||||
selfManagePolicy := policy.NewPolicy("self-manage", "Self Management",
|
||||
selfManagePolicy := policy.NewPolicy(
|
||||
"self-manage",
|
||||
"Self Management",
|
||||
policy.Allow("iam:identity:update").
|
||||
When(policy.Equals("principal.id", "resource.id")),
|
||||
)
|
||||
|
||||
@@ -115,12 +115,16 @@ func (v *SAMLDomainVerifier) checkUnverifiedDomains(ctx context.Context) error {
|
||||
|
||||
if err := v.tryVerifyDomain(ctx, config.ID); err != nil {
|
||||
if errors.Is(err, errDomainTXTRecordNotFound) || errors.Is(err, errDomainTXTRecordMismatch) {
|
||||
v.logger.InfoCtx(ctx, "domain verification pending",
|
||||
v.logger.InfoCtx(
|
||||
ctx,
|
||||
"domain verification pending",
|
||||
log.String("config_id", config.ID.String()),
|
||||
log.Error(err),
|
||||
)
|
||||
} else {
|
||||
v.logger.ErrorCtx(ctx, "cannot verify domain",
|
||||
v.logger.ErrorCtx(
|
||||
ctx,
|
||||
"cannot verify domain",
|
||||
log.String("config_id", config.ID.String()),
|
||||
log.Error(err),
|
||||
)
|
||||
@@ -160,7 +164,9 @@ func (v *SAMLDomainVerifier) tryVerifyDomain(ctx context.Context, configID gid.G
|
||||
return err
|
||||
}
|
||||
|
||||
v.logger.InfoCtx(ctx, "domain verified",
|
||||
v.logger.InfoCtx(
|
||||
ctx,
|
||||
"domain verified",
|
||||
log.String("config_id", config.ID.String()),
|
||||
)
|
||||
|
||||
|
||||
@@ -107,7 +107,9 @@ func NewBridgeRunner(
|
||||
|
||||
// Run starts the runner loop that processes SCIM bridges.
|
||||
func (r *BridgeRunner) Run(ctx context.Context) error {
|
||||
r.logger.InfoCtx(ctx, "starting SCIM bridge runner",
|
||||
r.logger.InfoCtx(
|
||||
ctx,
|
||||
"starting SCIM bridge runner",
|
||||
log.Duration("poll_interval", r.cfg.PollInterval),
|
||||
log.Duration("sync_interval", r.cfg.Interval),
|
||||
log.Duration("sync_timeout", r.cfg.SyncTimeout),
|
||||
|
||||
@@ -85,7 +85,9 @@ func (r *BridgeRunner) transitionToSuccess(
|
||||
bridge.UpdatedAt = now
|
||||
|
||||
if err := bridge.Update(ctx, conn, scope); err != nil {
|
||||
logger.ErrorCtx(ctx, "cannot update bridge after successful sync",
|
||||
logger.ErrorCtx(
|
||||
ctx,
|
||||
"cannot update bridge after successful sync",
|
||||
log.Error(err),
|
||||
)
|
||||
return err
|
||||
@@ -94,14 +96,18 @@ func (r *BridgeRunner) transitionToSuccess(
|
||||
if connector != nil {
|
||||
connector.UpdatedAt = now
|
||||
if err := connector.Update(ctx, conn, scope, r.encryptionKey); err != nil {
|
||||
logger.WarnCtx(ctx, "cannot persist refreshed OAuth2 token",
|
||||
logger.WarnCtx(
|
||||
ctx,
|
||||
"cannot persist refreshed OAuth2 token",
|
||||
log.String("connector_id", connector.ID.String()),
|
||||
log.Error(err),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
logger.InfoCtx(ctx, "sync completed successfully",
|
||||
logger.InfoCtx(
|
||||
ctx,
|
||||
"sync completed successfully",
|
||||
log.Duration("sync_duration", duration),
|
||||
log.Int("users_created", stats.Created),
|
||||
log.Int("users_updated", stats.Updated),
|
||||
@@ -141,7 +147,9 @@ func (r *BridgeRunner) transitionToFailed(
|
||||
bridge.State = coredata.SCIMBridgeStateDisabled
|
||||
bridge.NextSyncAt = nil
|
||||
|
||||
logger.ErrorCtx(ctx, "bridge disabled due to max consecutive failures",
|
||||
logger.ErrorCtx(
|
||||
ctx,
|
||||
"bridge disabled due to max consecutive failures",
|
||||
log.Duration("sync_duration", duration),
|
||||
log.Int("consecutive_failures", bridge.ConsecutiveFailures),
|
||||
log.Int("max_consecutive_failures", r.cfg.MaxConsecutiveFailures),
|
||||
@@ -153,7 +161,9 @@ func (r *BridgeRunner) transitionToFailed(
|
||||
nextSync := now.Add(backoff)
|
||||
bridge.NextSyncAt = &nextSync
|
||||
|
||||
logger.ErrorCtx(ctx, "sync failed, will retry with backoff",
|
||||
logger.ErrorCtx(
|
||||
ctx,
|
||||
"sync failed, will retry with backoff",
|
||||
log.Duration("sync_duration", duration),
|
||||
log.Int("consecutive_failures", bridge.ConsecutiveFailures),
|
||||
log.Duration("next_retry_in", backoff),
|
||||
@@ -162,7 +172,9 @@ func (r *BridgeRunner) transitionToFailed(
|
||||
}
|
||||
|
||||
if err := bridge.Update(ctx, conn, scope); err != nil {
|
||||
logger.ErrorCtx(ctx, "cannot update bridge after failed sync",
|
||||
logger.ErrorCtx(
|
||||
ctx,
|
||||
"cannot update bridge after failed sync",
|
||||
log.String("new_state", string(bridge.State)),
|
||||
log.Error(err),
|
||||
)
|
||||
|
||||
@@ -156,7 +156,9 @@ func (r *BridgeRunner) createGoogleWorkspaceProvider(
|
||||
providerName := dbConnector.Provider.String()
|
||||
refreshCfg := r.connectorRegistry.GetOAuth2RefreshConfig(providerName)
|
||||
if refreshCfg == nil {
|
||||
logger.WarnCtx(ctx, "no OAuth2 refresh config found, using static token",
|
||||
logger.WarnCtx(
|
||||
ctx,
|
||||
"no OAuth2 refresh config found, using static token",
|
||||
log.String("connector_id", dbConnector.ID.String()),
|
||||
log.String("connector_provider", providerName),
|
||||
)
|
||||
|
||||
@@ -132,17 +132,21 @@ func NewService(
|
||||
}
|
||||
svc.SAMLService = samlService
|
||||
|
||||
svc.SCIMService = scim.NewService(svc.pg, cfg.Logger.Named("scim"), scim.ServiceConfig{
|
||||
TracerProvider: cfg.TracerProvider,
|
||||
Registerer: cfg.Registerer,
|
||||
EncryptionKey: cfg.EncryptionKey,
|
||||
ConnectorRegistry: cfg.ConnectorRegistry,
|
||||
BridgeRunner: scim.BridgeRunnerConfig{
|
||||
Interval: cfg.SCIMBridgeSyncInterval,
|
||||
PollInterval: cfg.SCIMBridgePollInterval,
|
||||
BaseURL: cfg.BaseURL,
|
||||
svc.SCIMService = scim.NewService(
|
||||
svc.pg,
|
||||
cfg.Logger.Named("scim"),
|
||||
scim.ServiceConfig{
|
||||
TracerProvider: cfg.TracerProvider,
|
||||
Registerer: cfg.Registerer,
|
||||
EncryptionKey: cfg.EncryptionKey,
|
||||
ConnectorRegistry: cfg.ConnectorRegistry,
|
||||
BridgeRunner: scim.BridgeRunnerConfig{
|
||||
Interval: cfg.SCIMBridgeSyncInterval,
|
||||
PollInterval: cfg.SCIMBridgePollInterval,
|
||||
BaseURL: cfg.BaseURL,
|
||||
},
|
||||
},
|
||||
})
|
||||
)
|
||||
|
||||
svc.samlDomainVerifier = NewSAMLDomainVerifier(
|
||||
pgClient,
|
||||
|
||||
Reference in New Issue
Block a user