This adds our short device ID to the basic auth realm. This has at least two consequences: - It is different from what's presented by another device on the same address (e.g., if I use SSH forwards to different dives on the same local address), preventing credentials for one from being sent to another. - It is different from what we did previously, meaning we avoid cached credentials from old versions interfering with the new login flow. I don't *think* there should be things that depend on our precise realm string, so this shouldn't break any existing setups... Sneakily this also changes the session cookie and CSRF name, because I think `id.Short().String()` is nicer than `id.String()[:5]` and the short ID is two characters longer. That's also not a problem...
This commit is contained in:
@@ -13,10 +13,15 @@ import (
|
||||
"github.com/syncthing/syncthing/lib/sha256"
|
||||
)
|
||||
|
||||
const DeviceIDLength = 32
|
||||
const (
|
||||
DeviceIDLength = 32
|
||||
ShortIDStringLength = 7
|
||||
)
|
||||
|
||||
type DeviceID [DeviceIDLength]byte
|
||||
type ShortID uint64
|
||||
type (
|
||||
DeviceID [DeviceIDLength]byte
|
||||
ShortID uint64
|
||||
)
|
||||
|
||||
var (
|
||||
LocalDeviceID = repeatedDeviceID(0xff)
|
||||
@@ -94,7 +99,7 @@ func (s ShortID) String() string {
|
||||
}
|
||||
var bs [8]byte
|
||||
binary.BigEndian.PutUint64(bs[:], uint64(s))
|
||||
return base32.StdEncoding.EncodeToString(bs[:])[:7]
|
||||
return base32.StdEncoding.EncodeToString(bs[:])[:ShortIDStringLength]
|
||||
}
|
||||
|
||||
func (n *DeviceID) UnmarshalText(bs []byte) error {
|
||||
|
||||
Reference in New Issue
Block a user