auth
auth/client.go
Require full URLs for Endpoints. The spec says that we SHOULD require full URLs for redirection, but we _can_ offer the ability to set a URL as a "partial URL" if we really must. I see no particular reason to do this, so I've simplified the code by pulling that option out. This means that URLs (as long as they're normalized, which I've filed a bug in the codebase to do) can be checked using simple string comparison, which makes the likelihood of bugs across clientStorage implementations a lot lower.
1.1 --- a/client.go Sun Oct 26 00:53:36 2014 -0400 1.2 +++ b/client.go Sun Oct 26 03:22:41 2014 -0400 1.3 @@ -3,7 +3,6 @@ 1.4 import ( 1.5 "errors" 1.6 "net/url" 1.7 - "strings" 1.8 "time" 1.9 1.10 "code.secondbit.org/uuid" 1.11 @@ -144,7 +143,7 @@ 1.12 1.13 addEndpoint(client uuid.ID, endpoint Endpoint) error 1.14 removeEndpoint(client, endpoint uuid.ID) error 1.15 - checkEndpoint(client uuid.ID, endpoint string, strict bool) (bool, error) 1.16 + checkEndpoint(client uuid.ID, endpoint string) (bool, error) 1.17 listEndpoints(client uuid.ID, num, offset int) ([]Endpoint, error) 1.18 countEndpoints(client uuid.ID) (int64, error) 1.19 } 1.20 @@ -246,13 +245,11 @@ 1.21 return nil 1.22 } 1.23 1.24 -func (m *memstore) checkEndpoint(client uuid.ID, endpoint string, strict bool) (bool, error) { 1.25 +func (m *memstore) checkEndpoint(client uuid.ID, endpoint string) (bool, error) { 1.26 m.endpointLock.RLock() 1.27 defer m.endpointLock.RUnlock() 1.28 for _, candidate := range m.endpoints[client.String()] { 1.29 - if !strict && strings.HasPrefix(endpoint, candidate.URI.String()) { 1.30 - return true, nil 1.31 - } else if strict && endpoint == candidate.URI.String() { 1.32 + if endpoint == candidate.URI.String() { 1.33 return true, nil 1.34 } 1.35 }