mirror of
https://github.com/smallstep/certificates.git
synced 2024-11-11 07:11:00 +00:00
feat: change the separator between user-id & device-id in a client-id. Use '!' instead of ':'
This commit is contained in:
parent
90b5347887
commit
84e9682476
@ -199,7 +199,7 @@ func TestIMIntegration(t *testing.T) {
|
|||||||
Identifiers: []acme.Identifier{
|
Identifiers: []acme.Identifier{
|
||||||
{
|
{
|
||||||
Type: "wireapp-id",
|
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 {
|
if err != nil {
|
||||||
t.Fatal("parse user ID URI", err)
|
t.Fatal("parse user ID URI", err)
|
||||||
}
|
}
|
||||||
|
@ -190,7 +190,7 @@ func TestNewOrderRequest_Validate(t *testing.T) {
|
|||||||
return test{
|
return test{
|
||||||
nor: &NewOrderRequest{
|
nor: &NewOrderRequest{
|
||||||
Identifiers: []acme.Identifier{
|
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,
|
NotAfter: naf,
|
||||||
NotBefore: nbf,
|
NotBefore: nbf,
|
||||||
|
14
wire/id.go
14
wire/id.go
@ -4,6 +4,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"go.step.sm/crypto/kms/uri"
|
"go.step.sm/crypto/kms/uri"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type WireIDJSON struct {
|
type WireIDJSON struct {
|
||||||
@ -24,16 +25,21 @@ type ClientID struct {
|
|||||||
Domain string
|
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) {
|
func ParseClientID(clientID string) (ClientID, error) {
|
||||||
clientIdUri, err := uri.Parse(clientID)
|
clientIdUri, err := uri.Parse(clientID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ClientID{}, fmt.Errorf("invalid client id URI")
|
return ClientID{}, fmt.Errorf("invalid client id URI")
|
||||||
}
|
}
|
||||||
username := clientIdUri.User.Username()
|
fullUsername := clientIdUri.User.Username()
|
||||||
deviceId, _ := clientIdUri.User.Password()
|
parts := strings.SplitN(fullUsername, "!", 2)
|
||||||
|
if len(parts) != 2 {
|
||||||
|
return ClientID{}, fmt.Errorf("invalid client id")
|
||||||
|
}
|
||||||
return ClientID{
|
return ClientID{
|
||||||
Username: username,
|
Username: parts[0],
|
||||||
DeviceID: deviceId,
|
DeviceID: parts[1],
|
||||||
Domain: clientIdUri.Host,
|
Domain: clientIdUri.Host,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user