Skip to content

Commit 6ebab93

Browse files
committed
multi: deprecate UIPassword session type
1 parent 7a4d84a commit 6ebab93

File tree

3 files changed

+31
-34
lines changed

3 files changed

+31
-34
lines changed

itest/litd_mode_integrated_test.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,8 @@ func testModeIntegrated(net *NetworkHarness, t *harnessTest) {
335335
endpoint := endpoint
336336
tt.Run(endpoint.name+" lit port", func(ttt *testing.T) {
337337
runLNCAuthTest(
338-
ttt, cfg.LitAddr(), cfg.UIPassword,
339-
cfg.TLSCertPath,
340-
endpoint.requestFn,
338+
ttt, cfg.LitAddr(), cfg.TLSCertPath,
339+
cfg.LitMacPath, endpoint.requestFn,
341340
endpoint.successPattern,
342341
endpoint.allowedThroughLNC,
343342
)
@@ -583,7 +582,7 @@ func runRESTAuthTest(t *testing.T, hostPort, uiPassword, macaroonPath, restURI,
583582

584583
// runLNCAuthTest tests authentication of the given interface when connecting
585584
// through Lightning Node Connect.
586-
func runLNCAuthTest(t *testing.T, hostPort, uiPassword, tlsCertPath string,
585+
func runLNCAuthTest(t *testing.T, hostPort, tlsCertPath, macPath string,
587586
makeRequest requestFn, successContent string, callAllowed bool) {
588587

589588
ctxb := context.Background()
@@ -593,9 +592,12 @@ func runLNCAuthTest(t *testing.T, hostPort, uiPassword, tlsCertPath string,
593592
rawConn, err := connectRPC(ctxt, hostPort, tlsCertPath)
594593
require.NoError(t, err)
595594

595+
macBytes, err := ioutil.ReadFile(macPath)
596+
require.NoError(t, err)
597+
ctxm := macaroonContext(ctxt, macBytes)
598+
596599
// We first need to create an LNC session that we can use to connect.
597600
// We use the UI password to create the session.
598-
ctxm := uiPasswordContext(ctxt, uiPassword, true)
599601
litClient := litrpc.NewSessionsClient(rawConn)
600602
sessResp, err := litClient.AddSession(ctxm, &litrpc.AddSessionRequest{
601603
Label: "integration-test",
@@ -618,7 +620,7 @@ func runLNCAuthTest(t *testing.T, hostPort, uiPassword, tlsCertPath string,
618620
// endpoint, unless it is explicitly disallowed (we currently don't want
619621
// to support creating more sessions through LNC until we have all
620622
// macaroon permissions properly set up).
621-
resp, err := makeRequest(ctxm, rawLNCConn)
623+
resp, err := makeRequest(ctxt, rawLNCConn)
622624

623625
// Is this a disallowed call?
624626
if !callAllowed {
@@ -744,6 +746,7 @@ func connectMailbox(ctx context.Context,
744746
grpc.WithContextDialer(transportConn.Dial),
745747
grpc.WithTransportCredentials(noiseConn),
746748
grpc.WithPerRPCCredentials(noiseConn),
749+
grpc.WithBlock(),
747750
}
748751

749752
return grpc.DialContext(ctx, mailboxServerAddr, dialOpts...)

itest/litd_mode_remote_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,8 @@ func testModeRemote(net *NetworkHarness, t *harnessTest) {
137137
endpoint := endpoint
138138
tt.Run(endpoint.name+" lit port", func(ttt *testing.T) {
139139
runLNCAuthTest(
140-
ttt, cfg.LitAddr(), cfg.UIPassword,
141-
cfg.LitTLSCertPath,
142-
endpoint.requestFn,
140+
ttt, cfg.LitAddr(), cfg.LitTLSCertPath,
141+
cfg.LitMacPath, endpoint.requestFn,
143142
endpoint.successPattern,
144143
endpoint.allowedThroughLNC,
145144
)

session_rpcserver.go

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,11 @@ func (s *sessionRpcServer) AddSession(_ context.Context,
119119
return nil, err
120120
}
121121

122-
if typ != session.TypeUIPassword && typ != session.TypeMacaroonAdmin &&
122+
if typ != session.TypeMacaroonAdmin &&
123123
typ != session.TypeMacaroonReadonly {
124124

125-
return nil, fmt.Errorf("invalid session type, only UI " +
126-
"password, admin and readonly macaroon types " +
127-
"supported in LiT")
125+
return nil, fmt.Errorf("invalid session type, only admin " +
126+
"and readonly macaroon types supported in LiT")
128127
}
129128

130129
sess, err := session.NewSession(
@@ -181,33 +180,29 @@ func (s *sessionRpcServer) resumeSession(sess *session.Session) error {
181180
return nil
182181
}
183182

184-
var authData []byte
185-
switch sess.Type {
186-
case session.TypeUIPassword:
187-
authData = []byte("Authorization: Basic " + s.cfg.basicAuth)
188-
189-
case session.TypeMacaroonAdmin, session.TypeMacaroonReadonly:
190-
ctx := context.Background()
191-
readOnly := sess.Type == session.TypeMacaroonReadonly
192-
mac, err := s.cfg.superMacBaker(
193-
ctx, sess.MacaroonRootKey, &session.MacaroonRecipe{
194-
Permissions: GetAllPermissions(readOnly),
195-
},
196-
)
197-
if err != nil {
198-
log.Debugf("Not resuming session %x. Could not bake"+
199-
"the necessary macaroon: %w", pubKeyBytes, err)
200-
return nil
201-
}
183+
if sess.Type != session.TypeMacaroonAdmin &&
184+
sess.Type != session.TypeMacaroonReadonly {
202185

203-
authData = []byte(fmt.Sprintf("%s: %s", HeaderMacaroon, mac))
204-
205-
default:
206186
log.Debugf("Not resuming session %x with type %d", pubKeyBytes,
207187
sess.Type)
208188
return nil
209189
}
210190

191+
readOnly := sess.Type == session.TypeMacaroonReadonly
192+
mac, err := s.cfg.superMacBaker(
193+
context.Background(), sess.MacaroonRootKey,
194+
&session.MacaroonRecipe{
195+
Permissions: GetAllPermissions(readOnly),
196+
},
197+
)
198+
if err != nil {
199+
log.Debugf("Not resuming session %x. Could not bake "+
200+
"the necessary macaroon: %w", pubKeyBytes, err)
201+
return nil
202+
}
203+
204+
authData := []byte(fmt.Sprintf("%s: %s", HeaderMacaroon, mac))
205+
211206
sessionClosedSub, err := s.sessionServer.StartSession(sess, authData)
212207
if err != nil {
213208
return err

0 commit comments

Comments
 (0)