File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ import (
1212 "github.com/lightninglabs/lightning-terminal/litrpc"
1313 "github.com/lightninglabs/lightning-terminal/session"
1414 "google.golang.org/grpc"
15+ "gopkg.in/macaroon-bakery.v2/bakery/checkers"
16+ "gopkg.in/macaroon.v2"
1517)
1618
1719// sessionRpcServer is the gRPC server for the Session RPC interface.
@@ -188,11 +190,22 @@ func (s *sessionRpcServer) resumeSession(sess *session.Session) error {
188190 return nil
189191 }
190192
191- readOnly := sess .Type == session .TypeMacaroonReadonly
193+ var (
194+ caveats []macaroon.Caveat
195+ readOnly = sess .Type == session .TypeMacaroonReadonly
196+ )
197+
198+ // Add the session expiry as a macaroon caveat.
199+ macExpiry := checkers .TimeBeforeCaveat (sess .Expiry )
200+ caveats = append (caveats , macaroon.Caveat {
201+ Id : []byte (macExpiry .Condition ),
202+ })
203+
192204 mac , err := s .cfg .superMacBaker (
193205 context .Background (), sess .MacaroonRootKey ,
194206 & session.MacaroonRecipe {
195207 Permissions : GetAllPermissions (readOnly ),
208+ Caveats : caveats ,
196209 },
197210 )
198211 if err != nil {
You can’t perform that action at this time.
0 commit comments