Here is what I did. @skopf
1 Create profile profile key pair
Create a new key pair and store it in mwiesen_keypair.json:
$ ./SpxpCryptoTool genprofilekeypair > mwiesen_keypair.json
$ cat mwiesen_keypair.json
Output:
{
"kty": "OKP",
"d": "...",
"crv": "Ed25519",
"kid": "nsgPGGSTKrnjoUWZ",
"x": "NptsYvJ9GByZEt7E5CqD2qS5W7c7hlOLEVN8dLfDUUU"
}
Make a copy without the private key:
$ ./SpxpCryptoTool extractprofilepublic mwiesen_keypair.json > mwiesen_publickey.json
cat mwiesen_publickey.json
Output:
{
"kty": "OKP",
"crv": "Ed25519",
"kid": "nsgPGGSTKrnjoUWZ",
"x": "NptsYvJ9GByZEt7E5CqD2qS5W7c7hlOLEVN8dLfDUUU"
}
2 Register new profile
Use the public key as the value for the publickey key in the following JSON template:
{
"slug" : "mwiesen",
"publicKey" :
}
Post the resulting JSON object to the profile registration endpoint, profiles/v01/register in our case:
$ curl -i -H 'Content-Type: application/json' \
-d '{
"slug" : "mwiesen",
"publicKey" : {
"kid": "nsgPGGSTKrnjoUWZ",
"kty": "OKP",
"crv": "Ed25519",
"x": "NptsYvJ9GByZEt7E5CqD2qS5W7c7hlOLEVN8dLfDUUU"
}
}' \
http://profiles.xaldon.com/profiles/v01/register
Response:
{"message":"Profile 'mwiesen' created","status":"200"}%
NOTES:
- Shouldn't the profile registration return the exact URI under which the profile can now be reached? Like
http://profiles.xaldon.com/mwiesen. This could also be used in the device registration step for profile_uri.
3 Register device
Generate a random device_id. In our case, we're going to use my-fancy-phone.
Take the following template, insert the profile_uri, device_id and timestamp and store it in a file, e.g. device_registration_request.json.
$ echo '{
"profile_uri" : "http://profiles.xaldon.com/mwiesen",
"device_id" : "my-fancy-phone",
"timestamp" : "2020-09-20T09:36:54.514+00:00",
}' \
> device_registration_request.json
NOTES:
- It would be nice to know a bit more about potential
device_id constraints, e.g. what's the recommended / maximum length? Are there any forbidden characters?
- Does the server check
device_id uniqueness? Does the user have to ensure that? What happens if two devices use the same device_id?
- Does it make sense to add a method to the cryptotools that generates a suitable random
device_id?
- It would be nice to know what the timestamp is used for, e.g. so the server can "expire" device tokens after a certain period of time. But I wasn't sure if e.g. the device registration wouldn't work anymore after a timeout of, IDK 10 minutes or something.
Sign the device registration JSON object using the key pair:
$ ./SpxpCryptoTool sign device_registration_request.json mwiesen_keypair.json
Output:
{
"device_id": "my-fancy-phone",
"signature": {
"sig": "v_yV2PsIFacArurlR-DuM1xq4gEYSoNlQAyvUmjO7UGmRQvRw5l3jcvFy-_Rtx6tIXpbUioQa7j3xVdOV3VjDw",
"key": "nsgPGGSTKrnjoUWZ"
},
"profile_uri": "http://profiles.xaldon.com/mwiesen",
"timestamp": "2020-09-20T09:36:54.514+00:00"
}
POST this JSON object to the manage/v01/auth/device endpoint:
$ curl -i -H 'Content-Type: application/json' \
-d '{
"device_id": "my-fancy-phone",
"signature": {
"sig": "v_yV2PsIFacArurlR-DuM1xq4gEYSoNlQAyvUmjO7UGmRQvRw5l3jcvFy-_Rtx6tIXpbUioQa7j3xVdOV3VjDw",
"key": "nsgPGGSTKrnjoUWZ"
},
"profile_uri": "http://profiles.xaldon.com/mwiesen",
"timestamp": "2020-09-20T09:36:54.514+00:00"
}' \
http://profiles.xaldon.com/manage/v01/auth/device
Output:
{"timestamp":"2020-09-20T09:43:28.936+00:00","status":500,"error":"Internal Server Error","message":"Incorrect result size: expected 1, actual 0","path":"/manage/v01/auth/device"}%
Automation
$ echo '{
"device_id": "my-fancy-phone",
"profile_uri": "http://profiles.xaldon.com/mwiesen",
"timestamp": "'$(date -u +%Y-%m-%dT%T.000)'"
}' \
| ./SpxpCryptoTool sign /dev/stdin ./mwiesen_keypair.json \
| curl -i -H 'Content-Type: application/json' -d @- \
http://profiles.xaldon.com/manage/v01/auth/device
NOTES:
- Tried
http://profiles.xaldon.com/mwiesen, http://profiles.xaldon.com/profiles/mwiesen and http://profiles.xaldon.com/profiles/v01/mwiesen URIs with no success
- Again, not sure if the timestamp plays a role, but I don't think so. Didn't have a look at the source code yet.
Here is what I did. @skopf
1 Create profile profile key pair
Create a new key pair and store it in
mwiesen_keypair.json:$ ./SpxpCryptoTool genprofilekeypair > mwiesen_keypair.json $ cat mwiesen_keypair.jsonOutput:
{ "kty": "OKP", "d": "...", "crv": "Ed25519", "kid": "nsgPGGSTKrnjoUWZ", "x": "NptsYvJ9GByZEt7E5CqD2qS5W7c7hlOLEVN8dLfDUUU" }Make a copy without the private key:
$ ./SpxpCryptoTool extractprofilepublic mwiesen_keypair.json > mwiesen_publickey.json cat mwiesen_publickey.jsonOutput:
{ "kty": "OKP", "crv": "Ed25519", "kid": "nsgPGGSTKrnjoUWZ", "x": "NptsYvJ9GByZEt7E5CqD2qS5W7c7hlOLEVN8dLfDUUU" }2 Register new profile
Use the public key as the value for the
publickeykey in the following JSON template:{ "slug" : "mwiesen", "publicKey" : }Post the resulting JSON object to the profile registration endpoint,
profiles/v01/registerin our case:Response:
{"message":"Profile 'mwiesen' created","status":"200"}%NOTES:
http://profiles.xaldon.com/mwiesen. This could also be used in the device registration step forprofile_uri.3 Register device
Generate a random
device_id. In our case, we're going to usemy-fancy-phone.Take the following template, insert the
profile_uri,device_idandtimestampand store it in a file, e.g.device_registration_request.json.NOTES:
device_idconstraints, e.g. what's the recommended / maximum length? Are there any forbidden characters?device_iduniqueness? Does the user have to ensure that? What happens if two devices use the samedevice_id?device_id?Sign the device registration JSON object using the key pair:
Output:
{ "device_id": "my-fancy-phone", "signature": { "sig": "v_yV2PsIFacArurlR-DuM1xq4gEYSoNlQAyvUmjO7UGmRQvRw5l3jcvFy-_Rtx6tIXpbUioQa7j3xVdOV3VjDw", "key": "nsgPGGSTKrnjoUWZ" }, "profile_uri": "http://profiles.xaldon.com/mwiesen", "timestamp": "2020-09-20T09:36:54.514+00:00" }POST this JSON object to the
manage/v01/auth/deviceendpoint:Output:
{"timestamp":"2020-09-20T09:43:28.936+00:00","status":500,"error":"Internal Server Error","message":"Incorrect result size: expected 1, actual 0","path":"/manage/v01/auth/device"}%Automation
NOTES:
http://profiles.xaldon.com/mwiesen,http://profiles.xaldon.com/profiles/mwiesenandhttp://profiles.xaldon.com/profiles/v01/mwiesenURIs with no success