feat: change the separator between user-id & device-id in a client-id. Use '!' instead of ':'

pull/1671/head
beltram 9 months ago committed by Herman Slatman
parent 90b5347887
commit 84e9682476
No known key found for this signature in database
GPG Key ID: F4D8A44EA0A75A4F

@ -199,7 +199,7 @@ func TestIMIntegration(t *testing.T) {
Identifiers: []acme.Identifier{
{
Type: "wireapp-id",
Value: `{"name": "Smith, Alice M (QA)", "domain": "example.com", "client-id": "wireapp://lJGYPz0ZRq2kvc_XpdaDlA:ed416ce8ecdd9fad@example.com", "handle": "wireapp://%40alice.smith.qa@example.com"}`,
Value: `{"name": "Smith, Alice M (QA)", "domain": "example.com", "client-id": "wireapp://lJGYPz0ZRq2kvc_XpdaDlA!ed416ce8ecdd9fad@example.com", "handle": "wireapp://%40alice.smith.qa@example.com"}`,
},
},
}
@ -377,7 +377,7 @@ func TestIMIntegration(t *testing.T) {
},
})
qUserID, err := url.Parse("wireapp://lJGYPz0ZRq2kvc_XpdaDlA:ed416ce8ecdd9fad@example.com")
qUserID, err := url.Parse("wireapp://lJGYPz0ZRq2kvc_XpdaDlA!ed416ce8ecdd9fad@example.com")
if err != nil {
t.Fatal("parse user ID URI", err)
}

@ -190,7 +190,7 @@ func TestNewOrderRequest_Validate(t *testing.T) {
return test{
nor: &NewOrderRequest{
Identifiers: []acme.Identifier{
{Type: "wireapp-id", Value: `{"name": "Smith, Alice M (QA)", "domain": "example.com", "client-id": "wireapp://lJGYPz0ZRq2kvc_XpdaDlA:ed416ce8ecdd9fad@example.com", "handle": "wireapp://%40alice.smith.qa@example.com"}`},
{Type: "wireapp-id", Value: `{"name": "Smith, Alice M (QA)", "domain": "example.com", "client-id": "wireapp://lJGYPz0ZRq2kvc_XpdaDlA!ed416ce8ecdd9fad@example.com", "handle": "wireapp://%40alice.smith.qa@example.com"}`},
},
NotAfter: naf,
NotBefore: nbf,

@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"go.step.sm/crypto/kms/uri"
"strings"
)
type WireIDJSON struct {
@ -24,16 +25,21 @@ type ClientID struct {
Domain string
}
// ClientId format is : "wireapp://CzbfFjDOQrenCbDxVmgnFw!594930e9d50bb175@wire.com" where '!' is used as a separator
// between the user id & device id
func ParseClientID(clientID string) (ClientID, error) {
clientIdUri, err := uri.Parse(clientID)
if err != nil {
return ClientID{}, fmt.Errorf("invalid client id URI")
}
username := clientIdUri.User.Username()
deviceId, _ := clientIdUri.User.Password()
fullUsername := clientIdUri.User.Username()
parts := strings.SplitN(fullUsername, "!", 2)
if len(parts) != 2 {
return ClientID{}, fmt.Errorf("invalid client id")
}
return ClientID{
Username: username,
DeviceID: deviceId,
Username: parts[0],
DeviceID: parts[1],
Domain: clientIdUri.Host,
}, nil
}

Loading…
Cancel
Save