Difference between revisions of "Sudoroom Door Shortcut for iPhone"

Jump to navigation Jump to search
 
(28 intermediate revisions by one other user not shown)
Line 1: Line 1:
'''Recreate the iPhone shortcut that opens the sudoroom door with a widget on your phone.'''''Italic text''


'''==== Keep your credentials private! ===='''
 
== Recreate the iPhone shortcut that opens the sudoroom door with a widget on your phone. ==
 
== Keep your credentials private! ==
The door username and password are not in this guide, and the screenshots are redacted. Please don’t post them on the wiki, in chat, or anywhere public.
The door username and password are not in this guide, and the screenshots are redacted. Please don’t post them on the wiki, in chat, or anywhere public.
Once you’ve built the shortcut, the password is stored in it in readable form. Don’t share the shortcut file (the Share button exports the password along with it). Point people to this guide instead.
Once you’ve built the shortcut, the password is stored in it in readable form. Don’t share the shortcut file (the Share button exports the password along with it). Point people to this guide instead.


This guide walks you through building an Apple Shortcut that asks the sudoroom server to open the door. You don’t need any technical background: follow the numbered steps and you’ll be done in about five minutes. If you’re curious about what’s actually happening, the blue Under the hood boxes explain each piece. Skip them if you just want it working.
This guide walks you through building an Apple Shortcut that asks the sudoroom server to open the door. You don’t need any technical background: follow the numbered steps and you’ll be done in about five minutes. If you’re curious about what’s actually happening, the "Under the hood" section at the end explains each step.  


===== How it Works: =====
== How it Works: ==
When you tap this shortcut, your iPhone sends a short message over the internet to a computer at sudoroom. That message includes your username and password, so the computer knows you’re allowed in. If they check out, the computer then runs the door-opening program with your credentials.
When you tap this shortcut, your iPhone sends a short message over the internet to a computer at sudoroom. That message includes your username and password, so the computer knows you’re allowed in. If they check out, the computer then runs the door-opening program with your credentials.


Tap shortcut  →  phone sends request + login  →  room.sudoroom.org checks login  →  door program runs


===== Before you start, you need: =====
'''Tap shortcut  →  phone sends request + login  →  room.sudoroom.org checks login  →  door program runs'''


1. An iPhone or iPad with Apple’s Shortcuts app (it comes preinstalled; re-download it free from the App Store if you deleted it)
== Before you start, you need: ==
2. Your current door username and password (you should have received when you became a member)
3. An internet connection (Wi-Fi or cellular). You don’t need to be on the sudoroom network.


==== Build the Shortcut: ====
# An iPhone or iPad with Apple’s Shortcuts app (it comes preinstalled; re-download it free from the App Store if you deleted it)
# Your current door username and password (you should have received when you became a member)
# An internet connection (Wi-Fi or cellular). You don’t need to be on the sudoroom network.
 
== Build the Shortcut: ==


Open Shortcuts, tap + to create a new shortcut, and name it something like “sudoroom Door.” You’ll add four actions, in order. To add an action, tap the search bar at the bottom of the screen and type its name.
Open Shortcuts, tap + to create a new shortcut, and name it something like “sudoroom Door.” You’ll add four actions, in order. To add an action, tap the search bar at the bottom of the screen and type its name.


===== Step 1: =====  
=== Step 1: ===  


Add a Text action. Type the username, a colon, and the password, all on one line with no spaces:
Add a Text action. Type the username, a colon, and the password, all on one line with no spaces:
USERNAME:PASSWORD
USERNAME:PASSWORD


===== Step 2: =====
[[File:1 text action.png|frame|left]]
 
=== Step 2: ===
 
Add an "Encode" action directly below the Text action. Make sure it says Encode Text with base64, then tap to expand it and set Line Breaks to None.
 
[[File:2 encode base64.png|frame|left]]


Encode: convert it to Base64
=== Step 3: ===
Add an Encode action directly below the Text action. Make sure it says Encode Text with base64, then tap to expand it and set Line Breaks to None.


===== Step 3: =====
Add a "Set Variable" action. Name the variable b64creds. It should automatically show Base64 Encoded as its value; if not, tap the value and choose the Base64 Encoded result from Step 2.


Set Variable: name the result b64creds
[[File:3 set variable.png|frame|left]]
Add a Set Variable action. Name the variable b64creds. It should automatically show Base64 Encoded as its value; if not, tap the value and choose the Base64 Encoded result from Step 2.


===== Step 4: =====
=== Step 4: ===


Get Contents of URL: send the request
Add a "Get Contents of URL" action. This is the step that actually contacts sudoroom.
Add a Get Contents of URL action. This is the step that actually contacts sudoroom.


'''Configure it like this:'''
===== Configure it like this: =====


• URL: https://room.sudoroom.org/cgi-bin/omninidoor-wait-and-lock.sh
* URL: https://room.sudoroom.org/cgi-bin/omninidoor-wait-and-lock.sh
• Method: GET
* Method: GET
• Header name: Authorization
* Header name: Authorization
• Header value: Basic followed by the b64creds variable
* Header value: Basic followed by the b64creds variable


To add the header, tap Headers, then Add new header. In the value field type Basic and a space, then tap the variable bar above the keyboard and pick b64creds. It should appear as an orange variable bubble, as in the screenshot.
To add the header, tap Headers, then Add new header. In the value field type Basic and a space, then tap the variable bar above the keyboard and pick b64creds. It should appear as an orange variable bubble, as in the screenshot.


'''Common mistake:'''
[[File:4 get contents of url.png|frame|left]]
 
===== Common mistake: =====
If you type the letters “b64creds” instead of picking the variable, the shortcut sends that literal word as your password and the door won’t open. Look for the orange bubble.
If you type the letters “b64creds” instead of picking the variable, the shortcut sends that literal word as your password and the door won’t open. Look for the orange bubble.


==== Check Your Work ====
== Check Your Work ==


Your shortcut should have exactly four actions, in this order:
'''Your shortcut should have exactly four actions, in this order:'''


1. Text: USERNAME:PASSWORD
# Text: USERNAME:PASSWORD
2. Encode: Text with base64, Line Breaks = None
# Encode: Text with base64, Line Breaks = None
3. Set Variable: b64creds = Base64 Encoded
# Set Variable: b64creds = Base64 Encoded
4. Get Contents of URL: the door URL, Method GET, header Authorization = Basic + b64creds
# Get Contents of URL: the door URL, Method GET, header Authorization = Basic + b64creds


Tap the ▶ play button to test it. If the door responds, you’re done.
Tap the ▶ play button to test it. If the door responds, you’re done.
Optional: add a Show Result action at the end. It will pop up whatever the server sends back, which is very handy when something isn’t working.


==== Make it one tap ====
Once it works, put it somewhere quick to reach:
- Home Screen: long-press the shortcut in the Shortcuts app → Share → Add to Home Screen. (Here “Share” only adds an icon; it doesn’t send the shortcut to anyone.)
- Siri: say “Hey Siri,” followed by the shortcut’s name.
- Lock Screen, Control Center, or Action button: add it as a Shortcut control in your iPhone settings for those features.


====  
===== Optional: =====
Troubleshooting: ====
Add a Show Result action at the end. It will pop up whatever the server sends back, which is very handy when something isn’t working.
If it does not work, verify the following:
 
- the URL
 
- that the credentials are entered as USERNAME:PASSWORD
[[File:5 full shortcut.png|frame|left]]
- that Base64 uses no line breaks
 
- and that the Authorization header contains the word Basic followed by a space and the b64creds variable
== Make it one tap ==
 
'''Once it works, put it somewhere quick to reach:'''
 
* Home Screen: long-press the shortcut in the Shortcuts app → Share → Add to Home Screen. (Here “Share” only adds an icon; it doesn’t send the shortcut to anyone.)
* Siri: say “Hey Siri,” followed by the shortcut’s name.
* Lock Screen, Control Center, or Widget pull-down menu
 
== Troubleshooting: ==
 
'''If it does not work, verify the following:'''


==== If the door password changes, just edit the Text action in Step 1. Nothing else needs to change. ====
* the URL
* that the credentials are entered as username:password (all lowercase!)
* that Base64 uses no line breaks
* and that the Authorization header contains the word Basic followed by a space and the b64creds variable


===== If it still doesn’t work: =====  
If the door password changes, just edit the Text action in Step 1. Nothing else needs to change.
 
=== If it still doesn’t work: ===  
Add a Show Result action at the end (see above) and run the shortcut again, then match what you see:
Add a Show Result action at the end (see above) and run the shortcut again, then match what you see:


{| class="wikitable"
{| class="wikitable"
|+ Caption text
|+  
|-
|-
! What you See !! Likely Cause !! Fix
! What you See !! Likely Cause !! Fix
Line 102: Line 119:
To rule out your phone entirely, run the curl command from the “How it works” section. Adding -i shows the HTTP status code (200 means success, 401 means bad credentials). If curl works and the shortcut doesn’t, the problem is in the shortcut setup.
To rule out your phone entirely, run the curl command from the “How it works” section. Adding -i shows the HTTP status code (200 means success, 401 means bad credentials). If curl works and the shortcut doesn’t, the problem is in the shortcut setup.


 
== Under the hood ==
==== Under the hood ====


The shortcut makes a single HTTPS GET request to a CGI shell script on room.sudoroom.org, authenticated with HTTP Basic Authentication. Basic auth means the client sends a header of the form Authorization: Basic \<base64(user:pass)\> and the web server checks it before running the script.
The shortcut makes a single HTTPS GET request to a CGI shell script on room.sudoroom.org, authenticated with HTTP Basic Authentication. Basic auth means the client sends a header of the form Authorization: Basic \<base64(user:pass)\> and the web server checks it before running the script.
Line 110: Line 126:
The shortcut just rebuilds that request by hand, because Shortcuts has no built-in “username/password” option for web requests.
The shortcut just rebuilds that request by hand, because Shortcuts has no built-in “username/password” option for web requests.


Step 1:
===== Step 1: =====
Basic auth always joins the username and password with a single colon before encoding. Any stray space or trailing line break becomes part of the password, and the server will reject it. (This is also why the username itself can’t contain a colon.)
Basic auth always joins the username and password with a single colon before encoding. Any stray space or trailing line break becomes part of the password, and the server will reject it. (This is also why the username itself can’t contain a colon.)


Step 2:  
===== Step 2: =====
Base64 is a way of rewriting any text using only letters, digits, +, / and =, so it can travel safely inside a web request. It is encoding, not encryption: anyone can decode it instantly. The thing actually protecting your password in transit is HTTPS.
Base64 is a way of rewriting any text using only letters, digits, +, / and =, so it can travel safely inside a web request. It is encoding, not encryption: anyone can decode it instantly. The thing actually protecting your password in transit is HTTPS.
Line Breaks must be None because Shortcuts can otherwise wrap long Base64 output every 64 or 76 characters, and a line break inside an HTTP header breaks the request.
Line Breaks must be None because Shortcuts can otherwise wrap long Base64 output every 64 or 76 characters, and a line break inside an HTTP header breaks the request.


Step 3:
===== Step 3: =====
A variable is just a labeled box for a value so you can use it later. This step is technically optional (you could insert Step 2’s output straight into the header), but a named variable makes the shortcut easier to read and to fix.
A variable is just a labeled box for a value so you can use it later. This step is technically optional (you could insert Step 2’s output straight into the header), but a named variable makes the shortcut easier to read and to fix.


Step 4:
===== Step 4: =====
The URL points to a CGI shell script, a small program on the SudoRoom server that the web server runs when the address is requested. The Authorization header is extra information attached to the request; the word Basic tells the server which login scheme you’re using. Header names and the word “basic” aren’t case-sensitive, so the lowercase version in the screenshot works fine.
The URL points to a CGI shell script, a small program on the SudoRoom server that the web server runs when the address is requested. The Authorization header is extra information attached to the request; the word Basic tells the server which login scheme you’re using. Header names and the word “basic” aren’t case-sensitive, so the lowercase version in the screenshot works fine.
The finished header looks like: Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ= (that example decodes to username:password).
The finished header looks like: Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ= (that example decodes to username:password).

Navigation menu