diff --git a/AuthNotes.md b/AuthNotes.md new file mode 100644 index 0000000..371c049 --- /dev/null +++ b/AuthNotes.md @@ -0,0 +1,80 @@ +References related to Authentication + +With Svelte + SQLite: +https://medium.com/@mateuszpiorowski/oauth2-is-so-complicated-or-90-lines-of-code-with-svelte-ab0f5d80d659 + +With Auth.js + Node.js + Mastodon!: +https://medium.com/@jibla/auth-js-exploration-1b6c27cf076f +code: https://github.com/jibla/authjs-node-example + +## Example Auth Flow for Mastodon: +ref: https://docs.joinmastodon.org/client/token/#app + +### Step 1 - Get Client info + +sent: +`curl -X POST -F 'client_name=Mastodon Map' -F 'redirect_uris=urn:ietf:wg:oauth:2.0:oob' -F 'scopes=read write push' -F 'website=https://mastomap.magnificent.nz' https://mastodon.nzoss.nz/api/v1/apps` + +response (json): +``` +{ + "id":"6929", + "name":"Mastodon Map", + "website":"https://mastomap.magnificent.nz", + "redirect_uri":"urn:ietf:wg:oauth:2.0:oob", + "client_id":"RzTkGQY5MXuvRpMjhG6QuW3NADRjTn14e_JqywgX0IA", + "client_secret":"Sm6hUzIyvnAjYh6j1vXITJqObqCCwK-es33PAoRuhmI", + "vapid_key":"BDyHmBqMmcoCZQPQoSBAlRG06AuOMsJ64hQyTLUxoB8gP-uaACHJyAGRBj0JjtMtbl7WuQxRNuHh2fFQqSfmQMs=" +} +``` +### Step 2 - Get Auth Token + +sent: +``` +curl -X POST \ + -F 'client_id=RzTkGQY5MXuvRpMjhG6QuW3NADRjTn14e_JqywgX0IA' \ + -F 'client_secret=Sm6hUzIyvnAjYh6j1vXITJqObqCCwK-es33PAoRuhmI' \ + -F 'redirect_uri=urn:ietf:wg:oauth:2.0:oob' \ + -F 'grant_type=client_credentials' \ + https://mastodon.nzoss.nz/oauth/token +``` + +response (json): +``` +{ + "access_token":"l3rutZOWZ_LTkku-kjdeZ6F2tv7mucBid5AIgpLEjbg", + "token_type":"Bearer", + "scope":"read", + "created_at":1702891488 +} +``` + +### Step 3 - Verify Auth Token + +sent: +``` +curl \ + -H 'Authorization: Bearer l3rutZOWZ_LTkku-kjdeZ6F2tv7mucBid5AIgpLEjbg' \ + https://mastodon.nzoss.nz/api/v1/apps/verify_credentials +``` + +response (json): +``` +{ + "name":"Mastodon Map", + "website":"https://mastomap.magnificent.nz", + "vapid_key":"BDyHmBqMmcoCZQPQoSBAlRG06AuOMsJ64hQyTLUxoB8gP-uaACHJyAGRBj0JjtMtbl7WuQxRNuHh2fFQqSfmQMs=" +} +``` + +### Step 4 - actual request (for user 1, i.e. lightweight): + +sent: +``` +curl \ + -H 'Authorization: Bearer l3rutZOWZ_LTkku-kjdeZ6F2tv7mucBid5AIgpLEjbg' \ + https://mastodon.nzoss.nz/api/v1/accounts/1/followers?limit=6 | jq > MastoFollowers.json +``` + +and see MastoFollowers.json for the first 6 results (see limit=6 above). + diff --git a/MastoFollowers.json b/MastoFollowers.json new file mode 100644 index 0000000..10f9aa0 --- /dev/null +++ b/MastoFollowers.json @@ -0,0 +1,184 @@ +[ + { + "id": "111595856736442672", + "username": "Catt", + "acct": "Catt@universeodon.com", + "display_name": "Kat", + "locked": false, + "bot": false, + "discoverable": true, + "group": false, + "created_at": "2023-12-07T00:00:00.000Z", + "note": "

I love communism and anarchism, and hate capitalism and the state.

", + "url": "https://universeodon.com/@Catt", + "uri": "https://universeodon.com/users/Catt", + "avatar": "https://mastodon.nzoss.nz/system/cache/accounts/avatars/111/595/856/736/442/672/original/e13193aa3ff24f74.jpg", + "avatar_static": "https://mastodon.nzoss.nz/system/cache/accounts/avatars/111/595/856/736/442/672/original/e13193aa3ff24f74.jpg", + "header": "https://mastodon.nzoss.nz/system/cache/accounts/headers/111/595/856/736/442/672/original/5748b78234377f3f.png", + "header_static": "https://mastodon.nzoss.nz/system/cache/accounts/headers/111/595/856/736/442/672/original/5748b78234377f3f.png", + "followers_count": 525, + "following_count": 3191, + "statuses_count": 42, + "last_status_at": null, + "emojis": [], + "fields": [] + }, + { + "id": "111594947763130191", + "username": "ArtemisMkV", + "acct": "ArtemisMkV@defcon.social", + "display_name": "ArtemisMkV", + "locked": false, + "bot": false, + "discoverable": false, + "group": false, + "created_at": "2023-11-11T00:00:00.000Z", + "note": "", + "url": "https://defcon.social/@ArtemisMkV", + "uri": "https://defcon.social/users/ArtemisMkV", + "avatar": "https://mastodon.nzoss.nz/avatars/original/missing.png", + "avatar_static": "https://mastodon.nzoss.nz/avatars/original/missing.png", + "header": "https://mastodon.nzoss.nz/headers/original/missing.png", + "header_static": "https://mastodon.nzoss.nz/headers/original/missing.png", + "followers_count": 2, + "following_count": 219, + "statuses_count": 0, + "last_status_at": null, + "emojis": [], + "fields": [] + }, + { + "id": "111585911731826986", + "username": "randulo", + "acct": "randulo@mozilla.social", + "display_name": "Bluesbreaker Randy", + "locked": false, + "bot": false, + "discoverable": false, + "group": false, + "created_at": "2023-12-15T00:00:00.000Z", + "note": "

Longtime in music, first vinyl in 1972, but also a lot of tech, communications and many other lives.
I've been living in France for 42 years.

", + "url": "https://mozilla.social/@randulo", + "uri": "https://mozilla.social/users/randulo", + "avatar": "https://mastodon.nzoss.nz/system/cache/accounts/avatars/111/585/911/731/826/986/original/87fa8c405af5a5ff.png", + "avatar_static": "https://mastodon.nzoss.nz/system/cache/accounts/avatars/111/585/911/731/826/986/original/87fa8c405af5a5ff.png", + "header": "https://mastodon.nzoss.nz/system/cache/accounts/headers/111/585/911/731/826/986/original/1ce51e1cc21cf93d.jpg", + "header_static": "https://mastodon.nzoss.nz/system/cache/accounts/headers/111/585/911/731/826/986/original/1ce51e1cc21cf93d.jpg", + "followers_count": 292, + "following_count": 2797, + "statuses_count": 42, + "last_status_at": "2023-12-17", + "emojis": [], + "fields": [ + { + "name": "Wikipedia", + "value": "https://en.wikipedia.org/wiki/Randy_Resnick", + "verified_at": null + }, + { + "name": "Music", + "value": "https://randulo.com", + "verified_at": null + }, + { + "name": "Writing", + "value": "https://StrictlyBeta.com", + "verified_at": null + }, + { + "name": "Streaming platforms", + "value": "https://ffm.bio/randulo", + "verified_at": null + } + ] + }, + { + "id": "110669092986119925", + "username": "hall", + "acct": "hall@mastodonapp.uk", + "display_name": "David Hall", + "locked": false, + "bot": false, + "discoverable": false, + "group": false, + "created_at": "2022-11-21T00:00:00.000Z", + "note": "

FRGS

", + "url": "https://mastodonapp.uk/@hall", + "uri": "https://mastodonapp.uk/users/hall", + "avatar": "https://mastodon.nzoss.nz/system/cache/accounts/avatars/110/669/092/986/119/925/original/9b232f8dbabb1869.png", + "avatar_static": "https://mastodon.nzoss.nz/system/cache/accounts/avatars/110/669/092/986/119/925/original/9b232f8dbabb1869.png", + "header": "https://mastodon.nzoss.nz/system/cache/accounts/headers/110/669/092/986/119/925/original/db36bc922661d241.jpg", + "header_static": "https://mastodon.nzoss.nz/system/cache/accounts/headers/110/669/092/986/119/925/original/db36bc922661d241.jpg", + "followers_count": 3, + "following_count": 23, + "statuses_count": 19, + "last_status_at": "2023-12-14", + "emojis": [], + "fields": [ + { + "name": "Geo", + "value": "Teesdale", + "verified_at": null + } + ] + }, + { + "id": "109392198659255923", + "username": "SrRochardBunson", + "acct": "SrRochardBunson@universeodon.com", + "display_name": "Sir Rochard 'Dock' Bunson", + "locked": true, + "bot": false, + "discoverable": true, + "group": false, + "created_at": "2022-11-20T00:00:00.000Z", + "note": "

#Antifascist #Generalist

Be excellent to each other.

Except for #Fascists. They can get fucked.

If you aren't a #Nazi but I annoy you, you can mute my #Boosts

\"Help grow your #local #bee & #Butterflies polulation\"

Make Punching Nazis Cool Again
#MPNCA

#ArtFED #TVAC

\"The Resistance Will Be Federated\"

🙏 Take my Stuff (Original posts CC-BY-SA 4.0)

#TheResistanceWillBeFederated
🐝
Also at @SrRochardBunson & with Resistance International

No TERFs or astroturf

", + "url": "https://universeodon.com/@SrRochardBunson", + "uri": "https://universeodon.com/users/SrRochardBunson", + "avatar": "https://mastodon.nzoss.nz/system/cache/accounts/avatars/109/392/198/659/255/923/original/9719bf36bbbd0248.jpg", + "avatar_static": "https://mastodon.nzoss.nz/system/cache/accounts/avatars/109/392/198/659/255/923/original/9719bf36bbbd0248.jpg", + "header": "https://mastodon.nzoss.nz/system/cache/accounts/headers/109/392/198/659/255/923/original/2c26be9f48246cf1.jpg", + "header_static": "https://mastodon.nzoss.nz/system/cache/accounts/headers/109/392/198/659/255/923/original/2c26be9f48246cf1.jpg", + "followers_count": 3811, + "following_count": 7191, + "statuses_count": 7935, + "last_status_at": "2023-12-18", + "emojis": [], + "fields": [ + { + "name": "ArtFED Audio Collage", + "value": "https://on.soundcloud.com/h8N1q", + "verified_at": null + }, + { + "name": "Resistance International", + "value": "https://ko-fi.com/resistanceinternational/shop", + "verified_at": null + } + ] + }, + { + "id": "110891195218520061", + "username": "hamsbsijsvbsj", + "acct": "hamsbsijsvbsj@toot.io", + "display_name": "FAZ3🔵", + "locked": false, + "bot": false, + "discoverable": false, + "group": false, + "created_at": "2023-08-15T00:00:00.000Z", + "note": "

“If people are doubting how far you can go, go so far that you can’t hear them anymore🌹🌹🌹

", + "url": "https://toot.io/@hamsbsijsvbsj", + "uri": "https://toot.io/users/hamsbsijsvbsj", + "avatar": "https://mastodon.nzoss.nz/system/cache/accounts/avatars/110/891/195/218/520/061/original/19d9534fbf232860.jpg", + "avatar_static": "https://mastodon.nzoss.nz/system/cache/accounts/avatars/110/891/195/218/520/061/original/19d9534fbf232860.jpg", + "header": "https://mastodon.nzoss.nz/system/cache/accounts/headers/110/891/195/218/520/061/original/b79545bd525136c6.jpg", + "header_static": "https://mastodon.nzoss.nz/system/cache/accounts/headers/110/891/195/218/520/061/original/b79545bd525136c6.jpg", + "followers_count": 49, + "following_count": 381, + "statuses_count": 390, + "last_status_at": "2023-12-07", + "emojis": [], + "fields": [] + } +] diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 2667cbf..46d2783 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -11,5 +11,5 @@ services: ports: - "127.0.0.1:8085:8080" environment: - - API_URL=http://localhost:3000/ + - API_URL=http://localhost:3500/ restart: unless-stopped diff --git a/docker-compose.yml b/docker-compose.yml index 26bd96c..8145734 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -44,7 +44,7 @@ services: container_name: postgrest image: postgrest/postgrest:latest ports: - - "127.0.0.1:3000:3000" + - "127.0.0.1:3500:3000" # Available environment variables documented here: # https://postgrest.org/en/latest/configuration.html#environment-variables environment: