@blaine@mastodon.social avatar

blaine

@blaine@mastodon.social

This profile is from a federated server and may be incomplete. Browse more on the original instance.

blog, (edited ) to fediverse
@blog@shkspr.mobi avatar

A (tiny, incomplete, single user, write-only) ActivityPub server in PHP
https://shkspr.mobi/blog/2024/02/a-tiny-incomplete-single-user-write-only-activitypub-server-in-php/

I've written an ActivityPub server which . That's all it does. It won't record favourites or reposts. There's no support for following other accounts or receiving replies. It cannot delete or update posts nor can it verify signatures. It doesn't have a database or any storage beyond flat files.

But it will happily send messages and allow itself to be followed.

This shows that it is totally possible to broadcast fully-featured ActivityPub messages to the Fediverse with minimal coding skills and modest resources.

Why

I wanted to create a service a bit like FourSquare. For this, I needed an ActivityPub server which allows posting geotagged locations to the Fediverse.

I didn't want to install a fully-featured server with lots of complex parts. So I (foolishly) decided to write my own. I had a lot of trouble with HTTP Signatures. Because they are cursed and I cannot read documentation. But mostly the cursed thing.

How

Creating a minimum viable Mastodon instance can be done with half a dozen static files. That gets you an account that people can see. They can't follow it or receive any posts though.

I wanted to use PHP to build an interactive server. PHP is supported everywhere and is simple to deploy. Luckily, Robb Knight has written an excellent tutorial, so I ripped off his code and rewrote it for Symfony.

The structure is relatively straightforward.

  • /.well-known/webfinger is a static file which gives information about where to find details of the account.
  • /[username] is a static file which has the user's metadata, public key, and links to avatar images.
  • /following and /followers are also static files which say how many users are being followed / are following.
  • /posts/[GUID] a directory with JSON files saved to disk - each ones contains the published ActivityPub note.
  • /photos/ is a directory with any uploaded media in it.
  • /outbox is a list of all the posts which have been published.
  • /inbox is an external API endpoint. An ActivityPub server sends it a follow request, the endpoint then POSTs a cryptographically signed Accept message to the follower's inbox. The follower's inbox address is saved to disk.
  • /logs is a listing of all the messages received by the inbox.
  • /new is a password protected page which lets you write a message. This is then sent to...
  • /send is an internal API endpoint. It constructs an ActivityPub note, with attached location metadata, and POSTs it to each follower's inbox with a cryptographic signature.

That's it.

The front-end grabs my phone's geolocation and shows the 25 nearest places within 100 metres. One click and the page posts to the /send endpoint which then publishes a message saying I'm checked in. It is also possible to attach to the post a short message and a single photo with alt text.

There's no database. Posts are saved as JSON documents. Images are uploaded to a directory. It is single-user, so there is no account management.

What Works

  • Users can find the account.
  • Users can follow the account and receive updates.
  • Posts contain geotag metadata.
  • Posts contain a description of the place.
  • Posts contain an OSM link to the place.
  • Posts contain a custom message.
  • Posts autolink (sort of).
  • Posts can have an image attached to them.
  • Messages to the inbox are recorded (but not yet integrated).

ToDo

  • My account only has a few dozen followers, some of whom share the same sever. Even with cURL multi handle, it takes time to post to several servers.
  • It posts plain text. It doesn't autolink websites
  • Hashtags are linked when viewed remotely, but they don't go anywhere locally.
  • There's no language selection - it is hard-coded to English.
  • The outbox isn't paginated.
  • The UI looks crap - but it is only me using it.
  • There's only a basic front-page showing a map of all my check-ins.
  • Replies are logged, but there's no easy way to see them.
  • Doesn't show any metadata about the place being checked-in to. It could use the item's website (if any) or hashtags for the type of amenity it is.
  • No way to handle being unfollowed.
  • No way to remove servers which have died.
  • Probably lots more.

Other Resources

I found these resources helpful while creating this project:

What's Next?

I've raised an issue on Mastodon to see if they can support showing locations in posts. Hopefully, one day, they'll allow adding locations and then I can shut this down.

The code needs tidying up - it is very much a scratch-my-own-itch development. Probably riddled with bugs and security holes.

World domination?

Where

You can laugh at my code on GitHub.

You can look at my check-ins on a map.

You can follow my location on the Fediverse at @edent_location@location.edent.tel

https://shkspr.mobi/blog/2024/02/a-tiny-incomplete-single-user-write-only-activitypub-server-in-php/

blaine,
@blaine@mastodon.social avatar

@blog this is great!! Nice work. 🤘

While I appreciate that you don't want to run a server forever, I hope that Mastodon doesn't implement a similar location service; not because I don't think it's a good or fun idea, but because I think the fediverse would be better off with a diversity of tools.

ActivityPub is an extensible format, designed to be adapted and used in ways the authors never imagined, let alone intended. I think what you've built is a powerful example of that! Embrace it! ❤️

lzg, to random
@lzg@mastodon.social avatar

deleted_by_author

  • Loading...
  • blaine,
    @blaine@mastodon.social avatar

    @lzg ok let me try: prove you don't make the rules.

    Am I doing it right?

    lzg, to random
    @lzg@mastodon.social avatar

    deleted_by_author

  • Loading...
  • blaine,
    @blaine@mastodon.social avatar

    @lzg @jwz critically, the "you" in @lzg's post is addressed to somewhere between 500 and 10000 people, all of whom are at most a couple of steps away from her. I know many of these people personally and at least half of them need her specific advice and I hope many of them take it. ❤️

    (I would be seriously considering applying for the/a subtooted job on the basis of said advice, but I don't live in the correct country)

    pluralistic, to random
    @pluralistic@mamot.fr avatar

    Etiquette proposal: if you invite someone from another to a teleconference, the onus is on you to present all times in their local timezone, rather than your own - that is, the person asking should bear the labor of timezone conversions, not the person being asked.

    blaine,
    @blaine@mastodon.social avatar

    @pluralistic *as someone who has spent immense amounts of time reminding people that 9 ET is 6 PT, strong agree with a slight tweak: if developers are building a tool where timezones are likely to be discussed, they should build affordances to make the translation easy for everyone. Email clients could easily support something like this, but product manager laziness precludes it.

    blaine, to random
    @blaine@mastodon.social avatar

    I've been banging the "usable security or bust" drum for over a decade, but I'd never properly considered the implications of security-after-death. This thread is so critical for anyone building security systems to read: https://hachyderm.io/@shortridge/111772444831050395

    I've built production systems for people under direct threat from state-level actors. Your system probably isn't one of those, and if it is, you really know. Building "really secure" systems is a fun technical challenge, but usually Not Our Actual Job.

    blaine,
    @blaine@mastodon.social avatar

    The vast majority of sign-in systems boil down to verifying control of an email address. "Control" is a key word here, especially in the context of bereavement. Do that, do it well, don't build back doors accidentally or otherwise, don't add 2FA (including site-specific passwords) unless you're REALLY SURE you need it (ps you probably don't); gaining control of the email address should already require 2FA, and if not, your password/2fa reset flows are as weak as the user's email account.

    blaine,
    @blaine@mastodon.social avatar

    @voxpelli most passkeys are actually e-mail-backed, so in that sense, they're great. It's a bit of a sneaky move by google/apple, since now your identity is tied to your browser/device AND your e-mail account. They've also made an absolute hash of the UX. Promising in that it decouples id verification from a central service, so your email provider doesn't know where you're signing in, but I think the implementation needs some iteration before it's ready for wide adoption.

    blaine,
    @blaine@mastodon.social avatar

    @realn2s there are very few services, even with 2fa, where a compromise of the email account doesn't mean a takeover of other associated accounts. There are a few exceptions, e.g. banking, where government-issued identity controls are used instead of email as a back-stop, but for the overwhelming majority of web services it's just email at the end of the day.

    My argument is that unless a service is prepared to actually invest in getting all the hard things right, they should lean into email.

    blaine,
    @blaine@mastodon.social avatar

    @realn2s the flip-side is that it does mean that our email accounts need to be really secure (this is already true!); I think conceptually leaning into this model makes it much simpler to communicate that to users, though. E.g., "never ever use the same or even similar password as your email anywhere else", "enable 2fa on your email"

    blaine,
    @blaine@mastodon.social avatar

    @voxpelli to be fair, I haven't used 1password's passkey impl. You're right though that email will always be a backup ("help! I lost my 1passwd db, can't sign in to my account!" / "What's your account identifier?" / Err... / "It should be a 128-bit public key", said no-one ever 😅)

    blaine, to random
    @blaine@mastodon.social avatar

    This is the way forward for Canadian media. Eat Local, Buy Local, Connect Local. Really glad to see @thetyee (which I had a very small hand in launching 20 years ago!) taking open, federated media seriously. I wish more Canadian journalists would make the move, because it's the only way that I can see that we re-build strong Canadian journalism.

    https://mstdn.ca/@thetyee/111761456894193854

    blaine,
    @blaine@mastodon.social avatar
    blaine, to random
    @blaine@mastodon.social avatar

    I'm taking orders

    blaine, to random
    @blaine@mastodon.social avatar

    My world for a single, reliable, contact-oriented messaging interface.

    blaine,
    @blaine@mastodon.social avatar

    I want one place where I can see all my messages, organized by contact. I want to put my contacts into lists, not messages (or both), and I want to be able to see all the messages I've exchanged with that person/bot, regardless of platform. The mental overhead and overwhelm these days is just too high, even with tools like Beeper.

    mcc, to random
    @mcc@mastodon.social avatar

    The utter terror of submitting to a "Contact Us" form that says "you will receive an email to confirm your submission" and then not getting the email.

    blaine,
    @blaine@mastodon.social avatar

    @mcc bad luck! 😢 So far I've had really good luck with AliExpress (shipping to Nelson, even), but sometimes the packages take well over a month to arrive. Definitely a "leave it to the gods" level of zen around shipping times.

    ErikUden, to FediPact
    @ErikUden@mastodon.de avatar

    Hey Fedi Admins, y'all federating with this? :Threads_Burning:

    blaine,
    @blaine@mastodon.social avatar

    @maelduin13 @ErikUden @skobkin @themeowcate @erosalie @trumpet I'm probably wading in with not enough social context, so apologies, but the point of federation for me was never to enable server-level blocks. In a sentence, it was to enable, at scale, new ways of operating that don't depend on monopolistic control.

    Moderation itself could be federated (and imho should be), making it possible for instance operators to meaningfully delegate moderation to trusted organization(s).

    blaine,
    @blaine@mastodon.social avatar

    @maelduin13 @ErikUden @skobkin @themeowcate @erosalie @trumpet Mastodon's a latecomer to the game. 😅 I honestly thought we'd missed our chance back in ~2009, but it's still so very early — lots can and will change yet. ❤️

    I don't think we'll end up in a centralized control situation, because instance admins (and users & their communities!) will still have choice and control. It's obviously a risk, but the important thing is to build alternatives with intention.

    blaine,
    @blaine@mastodon.social avatar

    @maelduin13 @ErikUden @skobkin @themeowcate @erosalie @trumpet probably important to say that I do believe (and hope!) that "non-globally-federating communities" will be an important part of the fediverse. My hope is that the scope and complexity of the fediverse becomes synonymous with the web & the internet so that everyone can benefit, not just people who are comfortable in alt spaces.

    blaine,
    @blaine@mastodon.social avatar

    @maelduin13 @ErikUden @skobkin @themeowcate @erosalie @trumpet I'd put it this way: right now, Musk & Zuck are the default, and have no incentive to change. Many people would like alternatives, but have a higher affinity to their community (on Meta/X) than they do protocol politics. I don't think anything gets better without a federated social model as default. Nb, I think it's a necessary but not nearly sufficient condition. 😅

    blaine,
    @blaine@mastodon.social avatar

    @maelduin13 @ErikUden @skobkin @themeowcate @erosalie @trumpet (https://mastodon.social/@blaine/109327688462036016 for more context; I used to think that one person or organization could make or break this "stuff", not as a matter of morality or achievement, but happenstance. I now realize that this work is humanity. It literally takes and will continue to take a cast of billions; being closed to scale is important sometimes, but at this moment/context I think it means letting the usurers win 😢)

    kissane, to random
    @kissane@mas.to avatar

    I needed to understand the angles on Threads federation in a more rigorous way, so I took a few days to think through and write up my sense of the benefits, risks, and available risk mitigations, along with loopholes that need closing and questions to discuss with fediverse administrators.

    This is a blisteringly hot subject for me, so it's hard to keep my head cool enough to understand other people's trade-offs, but I'm trying.

    https://erinkissane.com/untangling-threads

    blaine,
    @blaine@mastodon.social avatar

    But here's the thing: culture and community matters. They can't "just" leave their homes and their communities and move to Canada because a law commits women to forced births, or their identity is banned. Many have, and speaking as someone who's been an immigrant times over, it sucks and is harder than anyone who hasn't found themselves uprooted can imagine.

    So for me to cut off America when I didn't know any Americans: that was the easy part. And moral.

    blaine,
    @blaine@mastodon.social avatar

    But to cut off my amazing American friends who choose not to leave America? Honestly, I would be the baddie.

    I'll never be as eloquent as Erin, but for me this experience transfers directly to the Fedi debate. I understand wanting safe space, and strongly believe in communities' rights to build and protect those spaces. From my perspective, though, online safe spaces have always been relatively easy to build, like an off-grid homestead.

    blaine,
    @blaine@mastodon.social avatar

    Creating a global space with porous borders? That's much harder. And it's not going to be easy. But Erin said all this and I'm just affirming her words.

    The only thing I'd add is that the short term goal of federation is to break Instagram, Facebook, and WhatsApp's monopolies, too. My community is totally dependent on Meta for basic operation, and when we talk about "safe spaces", my entire community is occupied, so I'm going to act from that point of view.

    blaine,
    @blaine@mastodon.social avatar

    @haubles @kissane 💯

    That's how I see it, too.

    The debate around blocking Threads hinges on the question of "is it possible to have both?"; @evan wrote up a great summary of the trade offs: https://evanp.me/2023/12/26/big-fedi-small-fedi/

    From my perspective, we don't have a choice. We have to be part of the world, connecting with everyone AND build safe spaces. We all lose if we fail to do both.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • JUstTest
  • GTA5RPClips
  • thenastyranch
  • tacticalgear
  • ethstaker
  • InstantRegret
  • DreamBathrooms
  • ngwrru68w68
  • magazineikmin
  • Youngstown
  • mdbf
  • khanakhh
  • slotface
  • rosin
  • provamag3
  • kavyap
  • everett
  • cisconetworking
  • Durango
  • modclub
  • osvaldo12
  • tester
  • Leos
  • cubers
  • normalnudes
  • megavids
  • anitta
  • lostlight
  • All magazines