{
	"info": {
		"_postman_id": "84b12b57-18da-4f0f-a1fa-fd01e00a8114",
		"name": "auth_api_samples_futurae",
		"description": "This collection contains a series of API call samples of the Futurae backend Auth API. In order to be able to use the calls defined in this collection, please set the Variables defined for this collection.\n\nFor further information on the Auth API, please visit the [Auth API Documentation](https://futurae.com/docs/api/auth/).",
		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
	},
	"item": [
		{
			"name": "/srv/auth/v1/server/ping",
			"event": [
				{
					"listen": "prerequest",
					"script": {
						"id": "2299a947-daa9-44ce-a2a1-bf65b7c440f0",
						"exec": [
							""
						],
						"type": "text/javascript"
					}
				}
			],
			"protocolProfileBehavior": {
				"disableBodyPruning": true
			},
			"request": {
				"method": "GET",
				"header": [],
				"body": {
					"mode": "raw",
					"raw": ""
				},
				"url": {
					"raw": "https://{{hostname}}/srv/auth/v1/server/ping",
					"protocol": "https",
					"host": [
						"{{hostname}}"
					],
					"path": [
						"srv",
						"auth",
						"v1",
						"server",
						"ping"
					]
				},
				"description": "[Docs](https://futurae.com/docs/api/auth/#ping-server)"
			},
			"response": []
		},
		{
			"name": "/srv/auth/v1/server/test",
			"event": [
				{
					"listen": "prerequest",
					"script": {
						"id": "2299a947-daa9-44ce-a2a1-bf65b7c440f0",
						"exec": [
							""
						],
						"type": "text/javascript"
					}
				}
			],
			"protocolProfileBehavior": {
				"disableBodyPruning": true
			},
			"request": {
				"method": "GET",
				"header": [
					{
						"key": "FT-Date",
						"value": "{{dateHeader}}"
					},
					{
						"key": "Authorization",
						"value": "{{authorizationHeader}}"
					},
					{
						"key": "Content-Type",
						"value": "application/json"
					}
				],
				"body": {
					"mode": "raw",
					"raw": ""
				},
				"url": {
					"raw": "https://{{hostname}}/srv/auth/v1/server/test?dummyparam=dummyvalue",
					"protocol": "https",
					"host": [
						"{{hostname}}"
					],
					"path": [
						"srv",
						"auth",
						"v1",
						"server",
						"test"
					],
					"query": [
						{
							"key": "dummyparam",
							"value": "dummyvalue"
						}
					]
				},
				"description": "[Docs](https://futurae.com/docs/api/auth/#test-get-authorization)"
			},
			"response": []
		},
		{
			"name": "/srv/auth/v1/server/test",
			"event": [
				{
					"listen": "prerequest",
					"script": {
						"id": "2299a947-daa9-44ce-a2a1-bf65b7c440f0",
						"exec": [
							""
						],
						"type": "text/javascript"
					}
				}
			],
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "FT-Date",
						"value": "{{dateHeader}}"
					},
					{
						"key": "Authorization",
						"value": "{{authorizationHeader}}"
					},
					{
						"key": "Content-Type",
						"value": "application/json"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n\t\"dummy_param\": \"dummy_value\"\n}"
				},
				"url": {
					"raw": "https://{{hostname}}/srv/auth/v1/server/test",
					"protocol": "https",
					"host": [
						"{{hostname}}"
					],
					"path": [
						"srv",
						"auth",
						"v1",
						"server",
						"test"
					]
				},
				"description": "[Docs](https://futurae.com/docs/api/auth/#test-post-authorization)"
			},
			"response": []
		},
		{
			"name": "/srv/auth/v1/user/enroll",
			"event": [
				{
					"listen": "prerequest",
					"script": {
						"id": "5a0723f9-fd19-4d34-9d5e-b0532d38d0b9",
						"exec": [
							""
						],
						"type": "text/javascript"
					}
				}
			],
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "FT-Date",
						"value": "{{dateHeader}}"
					},
					{
						"key": "Authorization",
						"value": "{{authorizationHeader}}"
					},
					{
						"key": "Content-Type",
						"value": "application/json"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n\t\"username\": \"customer_supplied_username\",\n\t\"display_name\": \"Test User\"\n}"
				},
				"url": {
					"raw": "https://{{hostname}}/srv/auth/v1/user/enroll",
					"protocol": "https",
					"host": [
						"{{hostname}}"
					],
					"path": [
						"srv",
						"auth",
						"v1",
						"user",
						"enroll"
					]
				},
				"description": "[Docs](https://futurae.com/docs/api/auth/#enroll-users-and-devices)"
			},
			"response": []
		},
		{
			"name": "/srv/auth/v1/user/enroll_status",
			"event": [
				{
					"listen": "prerequest",
					"script": {
						"id": "bb29dfa5-9908-4c9f-bf92-4555d029284f",
						"exec": [
							""
						],
						"type": "text/javascript"
					}
				}
			],
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "FT-Date",
						"value": "{{dateHeader}}"
					},
					{
						"key": "Authorization",
						"value": "{{authorizationHeader}}"
					},
					{
						"key": "Content-Type",
						"value": "application/json"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n\t\"user_id\": \"UUID_futurae_supplied_user_id\",\n\t\"activation_code\": \"xxxxxxxxxxxxxxxx\"\n}"
				},
				"url": {
					"raw": "https://{{hostname}}/srv/auth/v1/user/enroll_status",
					"protocol": "https",
					"host": [
						"{{hostname}}"
					],
					"path": [
						"srv",
						"auth",
						"v1",
						"user",
						"enroll_status"
					]
				},
				"description": "[Docs](https://futurae.com/docs/api/auth/#enroll-status)"
			},
			"response": []
		},
		{
			"name": "/srv/auth/v1/user/preauth",
			"event": [
				{
					"listen": "prerequest",
					"script": {
						"id": "92026bb1-dca4-4545-a25a-41cf4c297150",
						"exec": [
							""
						],
						"type": "text/javascript"
					}
				}
			],
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "FT-Date",
						"value": "{{dateHeader}}"
					},
					{
						"key": "Authorization",
						"value": "{{authorizationHeader}}"
					},
					{
						"key": "Content-Type",
						"value": "application/json"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n\t\"user_id\": \"UUID_futurae_supplied_user_id\"\n}"
				},
				"url": {
					"raw": "https://{{hostname}}/srv/auth/v1/user/preauth",
					"protocol": "https",
					"host": [
						"{{hostname}}"
					],
					"path": [
						"srv",
						"auth",
						"v1",
						"user",
						"preauth"
					]
				},
				"description": "[Docs](https://futurae.com/docs/api/auth/#query-authentication-options)"
			},
			"response": []
		},
		{
			"name": "/srv/auth/v1/user/auth",
			"event": [
				{
					"listen": "prerequest",
					"script": {
						"id": "f9a63711-08cf-4dde-ad77-ed6dfd9becb5",
						"exec": [
							""
						],
						"type": "text/javascript"
					}
				}
			],
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "FT-Date",
						"value": "{{dateHeader}}"
					},
					{
						"key": "Authorization",
						"value": "{{authorizationHeader}}"
					},
					{
						"key": "Content-Type",
						"value": "application/json"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n\t\"user_id\": \"UUID_futurae_supplied_user_id\",\n\t\"factor\": \"soundproof\",\n\t\"device_id\": \"auto\"\n}"
				},
				"url": {
					"raw": "https://{{hostname}}/srv/auth/v1/user/auth",
					"protocol": "https",
					"host": [
						"{{hostname}}"
					],
					"path": [
						"srv",
						"auth",
						"v1",
						"user",
						"auth"
					]
				},
				"description": "[Docs](https://futurae.com/docs/api/auth/#authenticate-user)"
			},
			"response": []
		},
		{
			"name": "/srv/auth/v1/user/auth_status",
			"event": [
				{
					"listen": "prerequest",
					"script": {
						"id": "eb6a3448-4734-4ad7-9a0c-2ae3770eca58",
						"exec": [
							""
						],
						"type": "text/javascript"
					}
				}
			],
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "FT-Date",
						"value": "{{dateHeader}}"
					},
					{
						"key": "Authorization",
						"value": "{{authorizationHeader}}"
					},
					{
						"key": "Content-Type",
						"value": "application/json"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n\t\"user_id\": \"UUID_futurae_supplied_user_id\",\n\t\"session_id\": \"xxxxxxxxxxxxxxxxxx\"\n}"
				},
				"url": {
					"raw": "https://{{hostname}}/srv/auth/v1/user/auth_status",
					"protocol": "https",
					"host": [
						"{{hostname}}"
					],
					"path": [
						"srv",
						"auth",
						"v1",
						"user",
						"auth_status"
					]
				},
				"description": "[Docs](https://futurae.com/docs/api/auth/#query-authentication-status)"
			},
			"response": []
		},
		{
			"name": "/srv/auth/v1/users",
			"event": [
				{
					"listen": "prerequest",
					"script": {
						"id": "2299a947-daa9-44ce-a2a1-bf65b7c440f0",
						"exec": [
							""
						],
						"type": "text/javascript"
					}
				}
			],
			"protocolProfileBehavior": {
				"disableBodyPruning": true
			},
			"request": {
				"method": "GET",
				"header": [
					{
						"key": "FT-Date",
						"value": "{{dateHeader}}"
					},
					{
						"key": "Authorization",
						"value": "{{authorizationHeader}}"
					},
					{
						"key": "Content-Type",
						"value": "application/json"
					}
				],
				"body": {
					"mode": "raw",
					"raw": ""
				},
				"url": {
					"raw": "https://{{hostname}}/srv/auth/v1/users?username=customer_supplied_username",
					"protocol": "https",
					"host": [
						"{{hostname}}"
					],
					"path": [
						"srv",
						"auth",
						"v1",
						"users"
					],
					"query": [
						{
							"key": "username",
							"value": "customer_supplied_username"
						}
					]
				},
				"description": "[Docs](https://futurae.com/docs/api/auth/#lookup-users)"
			},
			"response": []
		}
	],
	"event": [
		{
			"listen": "prerequest",
			"script": {
				"id": "a62fb7a5-0f48-468c-b935-517bf4b4781b",
				"type": "text/javascript",
				"exec": [
					"var hostname = pm.variables.get(\"hostname\");",
					"var service_id = pm.variables.get(\"service_id\");",
					"var secret_key = pm.variables.get(\"auth_api_key\");",
					"",
					"var date = new Date().toUTCString().slice(0,26) + \"-0000\";",
					"var method = request.method;",
					"var url = request.url.split(\"://\")[1];",
					"var sepIdx = url.indexOf(\"/\");",
					"var path = url.slice(sepIdx);",
					"var body = '';",
					"if (request.data.length > 0) body = request.data;",
					"",
					"var toSign = date + '\\n' + method + '\\n' + hostname + '\\n' + path + '\\n' + body + '\\n';",
					"",
					"// Generate HMAC SHA256 signature",
					"var hash = CryptoJS.HmacSHA256(toSign, secret_key);",
					"var signature = CryptoJS.enc.Hex.stringify(hash)",
					"var wordArray = CryptoJS.enc.Utf8.parse(service_id + \":\" + signature);",
					"var base64 = CryptoJS.enc.Base64.stringify(wordArray);",
					"",
					"postman.setEnvironmentVariable('authorizationHeader', 'Basic ' + base64);",
					"postman.setEnvironmentVariable('dateHeader', date);"
				]
			}
		},
		{
			"listen": "test",
			"script": {
				"id": "fcb8718f-1a77-4b7b-9158-b2d298273a5b",
				"type": "text/javascript",
				"exec": [
					""
				]
			}
		}
	],
	"variable": [
		{
			"id": "60133d36-31ac-4de6-be7b-4fe96c02c859",
			"key": "hostname",
			"value": "YOUR_FUTURAE_SERVICE_HOSTNAME",
			"type": "string"
		},
		{
			"id": "22655ab3-fb07-4508-ae93-37f4bbb66e48",
			"key": "service_id",
			"value": "YOUR_FUTURAE_SERVICE_ID",
			"type": "string"
		},
		{
			"id": "3301bee4-6fe1-4d7a-a43b-1530141ea313",
			"key": "auth_api_key",
			"value": "YOUR_FUTURAE_AUTH_API_KEY",
			"type": "string"
		}
	]
}