Skip to content

Commit 725f726

Browse files
committed
session_rpcserver: create readonly session
In this commit, we add the ability to create a read only session type.
1 parent 9cc9740 commit 725f726

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

session_rpcserver.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,12 @@ func (s *sessionRpcServer) AddSession(_ context.Context,
5252
return nil, err
5353
}
5454

55-
if typ != session.TypeUIPassword && typ != session.TypeMacaroonAdmin {
55+
if typ != session.TypeUIPassword && typ != session.TypeMacaroonAdmin &&
56+
typ != session.TypeMacaroonReadonly {
57+
5658
return nil, fmt.Errorf("invalid session type, only UI " +
57-
"password and macaroon admin types supported in LiT")
59+
"password, admin and readonly macaroon types " +
60+
"supported in LiT")
5861
}
5962

6063
sess, err := session.NewSession(
@@ -116,11 +119,12 @@ func (s *sessionRpcServer) resumeSession(sess *session.Session) error {
116119
case session.TypeUIPassword:
117120
authData = []byte("Authorization: Basic " + s.basicAuth)
118121

119-
case session.TypeMacaroonAdmin:
122+
case session.TypeMacaroonAdmin, session.TypeMacaroonReadonly:
120123
ctx := context.Background()
124+
readOnly := sess.Type == session.TypeMacaroonReadonly
121125
mac, err := s.superMacBaker(
122126
ctx, sess.MacaroonRootKey, &session.MacaroonRecipe{
123-
Permissions: getAllPermissions(false),
127+
Permissions: getAllPermissions(readOnly),
124128
},
125129
)
126130
if err != nil {

0 commit comments

Comments
 (0)