Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ type ProjectStore interface {
type Config[T any] map[string]map[string]T

// Get returns the config value for the given request.
func (c Config[T]) Get(path string) (v T, err error) {
func (c Config[T]) Get(_ context.Context, path string) (v T, err error) {
if c == nil {
return v, fmt.Errorf("config is nil")
}
Expand Down
5 changes: 3 additions & 2 deletions middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,14 @@ func AccessControl(acl Config[ACL], cfg Options) func(next http.Handler) http.Ha

return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
acl, err := acl.Get(r.URL.Path)
ctx := r.Context()
acl, err := acl.Get(ctx, r.URL.Path)
if err != nil {
cfg.ErrHandler(r, w, proto.ErrUnauthorized.WithCausef("get acl: %w", err))
return
}

if session, _ := GetSessionType(r.Context()); !acl.Includes(session) {
if session, _ := GetSessionType(ctx); !acl.Includes(session) {
err := proto.ErrPermissionDenied
if session == proto.SessionType_Public {
err = proto.ErrUnauthorized
Expand Down