-
Notifications
You must be signed in to change notification settings - Fork 7
User RFID how to
Thomas LaFreniere edited this page Jun 14, 2021
·
3 revisions
Using the nomos sdk cli:
install the CLI (this will add the nomos
command to your path)
npm install -g @vhs/nomos-sdk
login
nomos login [username]
see the current logged in user
nomos users current
get user full details
nomos users get [userid]
find a user
nomos users find {term}
create a RFID key (add --userid {id} for different user rather than current)
nomos keys generate --type rfid --key 0f:0f:0f:0f:0f:0f --notes "my special key card"
add privileges to the newly created key
nomos keys privileges {keyid} --privileges inherit
see help for more info
nomos help
Bash script:
nomos-create-rfid.sh
#!/bin/bash
NOMOS_BASE_URL="https://membership.vanhack.ca"
SERVICES="${NOMOS_BASE_URL}/services/web"
read -p "Nomos Username: " USERNAME
echo "Logging in as ${USERNAME}..."
COOKIE_JAR="${USERNAME}.cookies"
USER_ID=$(curl -u ${USERNAME} --basic -b ${COOKIE_JAR} -c ${COOKIE_JAR} "${SERVICES}/AuthService1.svc/CurrentUser" | jq -r '.id')
echo "User id ${USER_ID}"
read -p "RFID Key:" RFID
read -p "RFID Key Description [optional]: " DESCRIPTION
echo "Generating key..."
KEY=$(curl -b ${COOKIE_JAR} "${SERVICES}/KeyService1.svc/GenerateUserKey" -H "Content-Type: application/json; charset=utf-8" -d \
"{ \
\"userid\": ${USER_ID}, \
\"type\": \"rfid\", \
\"value\": \"${RFID}\", \
\"notes\": \"${DESCRIPTION}\" \
}")
echo "$KEY"
KEY_ID=$(echo "$KEY" | jq -r '.id')
echo "Key ID ${KEY_ID}"
echo "Adding privileges to key..."
curl -b ${COOKIE_JAR} "${SERVICES}/KeyService1.svc/PutKeyPrivileges" -H "Content-Type: application/json; charset=utf-8" -d \
"{ \
\"keyid\": ${KEY_ID}, \
\"privileges\": [\"inherit\"] \
}"
curl -b ${COOKIE_JAR} "${SERVICES}/KeyService1.svc/GetKey?keyid=${KEY_ID}" | jq
echo "Done!"
Add key to your user:
POST https://membership.vanhack.ca/services/web/KeyService1.svc/GenerateUserKey
{
"userid": ###,
"type": "rfid",
"value": "##:##:##:##:##:##:##"
"notes": "mah crud"
}
OR
GET https://membership.vanhack.ca/services/web/KeyService1.svc/GenerateUserKey?userid=###&type=rfid&value=##:##:##:##:##:##¬es=mah%20crud
response:
{
"id":###,
"userid":###,
"type":"rfid",
"key":"0f:0f:0f:0f:0f:0f",
"created":"2020-12-02 14:29:02",
"notes":"mah crud",
"expires":null,
"privileges":[]
}
Update key privileges:
POST https://membership.vanhack.ca/services/web/KeyService1.svc/PutKeyPrivileges
{
"keyid": ###,
"privileges": ["inherit"]
}
OR
GET https://membership.vanhack.ca/services/web/KeyService1.svc/PutKeyPrivileges?keyid=###&privileges=inherit
response
null
Get key details:
GET https://membership.vanhack.ca/services/web/KeyService1.svc/GetKey?keyid=###