Skip to content

Commit ca501a8

Browse files
committed
session_rpcserver: allow custom session with all read-only perms
In this commit, a special case is added to the creation of a custom session to allow the user to specify custom URIs as well as the permissions for all read-only endpoints.
1 parent 22b891b commit ca501a8

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

session_rpcserver.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,19 @@ func (s *sessionRpcServer) AddSession(_ context.Context,
152152
continue
153153
}
154154

155+
// If the action specified was the 'readonly' keyword,
156+
// then this is taken to mean that the permissions for
157+
// all read-only URIs should be granted.
158+
if op.Action == "readonly" {
159+
readPerms := s.cfg.permMgr.ActivePermissions(
160+
true,
161+
)
162+
163+
permissions = append(permissions, readPerms...)
164+
165+
continue
166+
}
167+
155168
// First check if this is a regex URI.
156169
uris, isRegex := s.cfg.permMgr.MatchRegexURI(op.Action)
157170
if isRegex {

0 commit comments

Comments
 (0)