Skip to content

Commit ac0695f

Browse files
authored
feat: dynamic allow-list (#2048)
Signed-off-by: Miguel Martinez <[email protected]>
1 parent 8885880 commit ac0695f

File tree

15 files changed

+339
-232
lines changed

15 files changed

+339
-232
lines changed

app/controlplane/cmd/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ func main() {
162162

163163
// Sync user access
164164
go func() {
165-
if err := app.userAccessSyncer.StartSyncingUserAccess(ctx); err != nil {
165+
if err := app.userAccessSyncer.SyncUserAccess(ctx); err != nil {
166166
_ = logger.Log(log.LevelError, "msg", "syncing user access", "error", err)
167167
}
168168
}()

app/controlplane/cmd/wire_gen.go

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/controlplane/configs/config.devel.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ auth:
8383
# rules: ["@chainloop.local"]
8484
# selected_routes: ["/controlplane.v1.WorkflowRunService/List"]
8585
# custom_message: "you need to require access here http://foo.com"
86-
86+
# allow_db_overrides: true # if false, the user access flag in the DB will mirror the allowlist, otherwise it will be respected
8787

8888
# referrer_shared_index:
8989
# enabled: true

app/controlplane/internal/conf/controlplane/config/v1/conf.pb.go

Lines changed: 78 additions & 64 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/controlplane/internal/conf/controlplane/config/v1/conf.proto

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@ message Auth {
204204
string custom_message = 2;
205205
// The list of routes that will be affected by this middleware, by default all of them
206206
repeated string selected_routes = 3;
207+
// Whether to treat the information stored in the user table as the source of truth
208+
// if false, the allowList rules will be used as source of truth
209+
// if true, the allowList rules will be used as a starting point to populate the property in the DB
210+
bool allow_db_overrides = 4;
207211
}
208212
}
209213

app/controlplane/internal/server/grpc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ func craftMiddleware(opts *Opts) []middleware.Middleware {
194194
).Match(requireAllButOrganizationOperationsMatcher()).Build(),
195195
// 4 - Make sure the account is fully functional
196196
selector.Server(
197-
usercontext.CheckUserInAllowList(opts.AuthConfig.AllowList),
197+
usercontext.CheckUserHasAccess(opts.AuthConfig.AllowList, opts.UserUseCase),
198198
).Match(allowListEnabled()).Build(),
199199
selector.Server(
200200
usercontext.CheckOrgRequirements(opts.CASBackendUseCase),

0 commit comments

Comments
 (0)