Skip to content

Commit

Permalink
Merge pull request #1472 from stgraber/main
Browse files Browse the repository at this point in the history
incusd/auth/openfga: refresh model before applying patches
  • Loading branch information
hallyn authored Dec 7, 2024
2 parents 06d46f8 + 70e99b2 commit f6628ea
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions internal/server/auth/driver_openfga.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@ func (f *fga) StopService(ctx context.Context) error {

// ApplyPatch is called when an applicable server patch is run, this triggers a model re-upload.
func (f *fga) ApplyPatch(ctx context.Context, name string) error {
// Always refresh the model.
logger.Info("Refreshing the OpenFGA model")
err := f.refreshModel(ctx)
if err != nil {
return err
}

if name == "auth_openfga_viewer" {
// Add the public access permission if not set.
resp, err := f.client.Check(ctx).Body(client.ClientCheckRequest{
Expand All @@ -172,9 +179,7 @@ func (f *fga) ApplyPatch(ctx context.Context, name string) error {
}
}

// Always refresh the model.
logger.Info("Refreshing the OpenFGA model")
return f.refreshModel(ctx)
return nil
}

func (f *fga) refreshModel(ctx context.Context) error {
Expand Down

0 comments on commit f6628ea

Please sign in to comment.