Skip to content

Commit 7e1d672

Browse files
authored
fix(allowlist): run in most of the routes (#992)
Signed-off-by: Miguel Martinez Trivino <[email protected]>
1 parent 1bf91d8 commit 7e1d672

File tree

1 file changed

+11
-0
lines changed
  • app/controlplane/internal/server

1 file changed

+11
-0
lines changed

app/controlplane/internal/server/grpc.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ func craftMiddleware(opts *Opts) []middleware.Middleware {
190190
// 4 - Make sure the account is fully functional
191191
selector.Server(
192192
usercontext.CheckUserInAllowList(opts.AuthConfig.AllowList),
193+
).Match(allowListEnabled()).Build(),
194+
selector.Server(
193195
usercontext.CheckOrgRequirements(opts.CASBackendUseCase),
194196
).Match(requireFullyConfiguredOrgMatcher()).Build(),
195197
).Match(requireCurrentUserMatcher()).Build(),
@@ -235,6 +237,15 @@ func requireFullyConfiguredOrgMatcher() selector.MatchFunc {
235237
}
236238
}
237239

240+
func allowListEnabled() selector.MatchFunc {
241+
// the allow list should not affect the ability to know who you are and delete your account
242+
const skipRegexp = "controlplane.v1.ContextService/Current|/controlplane.v1.AuthService/DeleteAccount"
243+
return func(ctx context.Context, operation string) bool {
244+
r := regexp.MustCompile(skipRegexp)
245+
return !r.MatchString(operation)
246+
}
247+
}
248+
238249
func requireRobotAccountMatcher() selector.MatchFunc {
239250
const requireMatcher = "controlplane.v1.AttestationService/.*|controlplane.v1.AttestationStateService/.*|controlplane.v1.SigningService/.*"
240251
return func(ctx context.Context, operation string) bool {

0 commit comments

Comments
 (0)