Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 5d94bed

Browse files
committed
Update authentication to use updated spdystream interface
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
1 parent 1380fea commit 5d94bed

4 files changed

Lines changed: 11 additions & 9 deletions

File tree

http2/listener.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"github.com/docker/libchan"
55
"github.com/docker/spdystream"
66
"net"
7+
"net/http"
78
"sync"
89
)
910

@@ -32,6 +33,8 @@ func NewListenSession(listener net.Listener, auth Authenticator) (*ListenSession
3233
}
3334

3435
func (l *ListenSession) streamHandler(stream *spdystream.Stream) {
36+
// TODO authorize stream
37+
stream.SendReply(http.Header{}, false)
3538
streamChan := l.getStreamChan(stream.Parent())
3639
streamChan <- stream
3740
}
@@ -67,7 +70,7 @@ func (l *ListenSession) Serve() {
6770
}
6871

6972
go func() {
70-
authHandler, authErr := l.auth(conn)
73+
authErr := l.auth(conn)
7174
if authErr != nil {
7275
// TODO log
7376
conn.Close()
@@ -81,7 +84,7 @@ func (l *ListenSession) Serve() {
8184
return
8285
}
8386

84-
go spdyConn.Serve(l.streamHandler, authHandler)
87+
go spdyConn.Serve(l.streamHandler)
8588
}()
8689
}
8790
}

http2/listener_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func exerciseServer(t *testing.T, server string, endChan chan bool) {
7474
t.Fatalf("Error sending message: %s", sendErr)
7575
}
7676

77-
msg, receiveErr := receiver.Receive(0) //libchan.Ret
77+
msg, receiveErr := receiver.Receive(0)
7878
if receiveErr != nil {
7979
t.Fatalf("Error receiving message")
8080
}

http2/spdy.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,14 @@ import (
2020
// a new connection. Authenticator allows tls handshakes to
2121
// occur or any desired authentication of a network connection
2222
// before passing off the connection to session management.
23-
type Authenticator func(conn net.Conn) (spdystream.AuthHandler, error)
23+
type Authenticator func(conn net.Conn) error
2424

2525
// NoAuthenticator is an implementation of authenticator which
2626
// does no security. This should only be used for testing or with
2727
// caution when network connections are already guarenteed to
2828
// be secure.
29-
func NoAuthenticator(conn net.Conn) (spdystream.AuthHandler, error) {
30-
return func(header http.Header, slot uint8, parent uint32) bool {
31-
return true
32-
}, nil
29+
func NoAuthenticator(conn net.Conn) error {
30+
return nil
3331
}
3432

3533
type streamChanProvider interface {

http2/stream.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ func (s *StreamSession) getStreamChan(stream *spdystream.Stream) chan *spdystrea
3737
}
3838

3939
func (s *StreamSession) newStreamHandler(stream *spdystream.Stream) {
40+
stream.SendReply(http.Header{}, false)
4041
streamChan := s.getStreamChan(stream.Parent())
4142
streamChan <- stream
4243
}
@@ -54,7 +55,7 @@ func NewStreamSession(conn net.Conn) (*StreamSession, error) {
5455
if spdyErr != nil {
5556
return nil, spdyErr
5657
}
57-
go spdyConn.Serve(session.newStreamHandler, spdystream.NoAuthHandler)
58+
go spdyConn.Serve(session.newStreamHandler)
5859

5960
session.conn = spdyConn
6061

0 commit comments

Comments
 (0)