Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Activity Pub + Webfinger] user/community name collision #2037

Closed
realaravinth opened this issue Jan 14, 2022 · 14 comments
Closed

[Activity Pub + Webfinger] user/community name collision #2037

realaravinth opened this issue Jan 14, 2022 · 14 comments
Labels
area: federation support federation via activitypub enhancement New feature or request

Comments

@realaravinth
Copy link

realaravinth commented Jan 14, 2022

Issue Summary

When a user and a community share the same name, webfinger query groups both resources together, producing a single response:

{
  "subject": "acct:cuzimbatman@lemmy.ml",
  "links": [
    {
      "rel": "http://webfinger.net/rel/profile-page",
      "type": "text/html",
      "href": "https://lemmy.ml/c/cuzimbatman"
    },
    {
      "rel": "self",
      "type": "application/activity+json",
      "href": "https://lemmy.ml/c/cuzimbatman"
    },
    {
      "rel": "http://webfinger.net/rel/profile-page",
      "type": "text/html",
      "href": "https://lemmy.ml/u/cuzimbatman"
    },
    {
      "rel": "self",
      "type": "application/activity+json",
      "href": "https://lemmy.ml/u/cuzimbatman"
    }
  ]
}

Please note that there is a community and a user named cuzimbatman so there are four items in links. Webfinger query.

I'm not sure how other activity pub servers choose which actor to contact but it looks like Mastodon is traversing in the reverse order(per the above linked webfinger response) and choosing the user actor.

Steps to Reproduce

  1. create new user and create a community with same name
  2. query webfinger for that user/community name
  3. try to access both using other activity pub servers
@realaravinth realaravinth added the bug Something isn't working label Jan 14, 2022
@Nutomic
Copy link
Member

Nutomic commented Jan 15, 2022

Good find! In fact i intentionally put the community first so that it would be prioritize. You can make a PR to change the order here.

@realaravinth
Copy link
Author

This is a deficiency in Activity Pub, collisions are bound to haolen if various types of actors share the same namespace.

The GNU Social folks have proposed FEP-2bca
(socialhub discussion) to address some of these issues, would the Lemmy team care to participate?

@Nutomic
Copy link
Member

Nutomic commented Jan 16, 2022

Webfinger works fine in Lemmy with identically named users/groups, as it goes through all of them and uses the one that has the expected type. Even Pleroma handles it fine, its just Mastodon thats causing trouble.

The FEP looks pretty complex, so i dont think we would implement it anytime soon.

@realaravinth
Copy link
Author

I'm from ForgeFlux, a project that's involved in implementing Activity Pub based federation for software forges. A micro-blogging program like Mastodon has no real use for Group actors but projects like ours do. I feel, being stakeholders we should represent our requirements and I'd be grateful for any inputs the Lemmy devs could provide.

As for implementing the spec, if the maintainers feel Lemmy could benefit from it, I'll gladly assist in it's implementation :)

@dessalines
Copy link
Member

There are 5 different actor types in activitystreams, yet they all share the same namespace 😦

@realaravinth
Copy link
Author

I've been loosing sleep over this. For all it's flexibility, activity pub is not flexible enough to make Groups first class citizens.

@Nutomic
Copy link
Member

Nutomic commented Jan 19, 2022

@realaravinth I suggest you open a new issue for discussing about groups compatibility. Alternatively we can chat on Matrix (@Nutomic:matrix.org).

@Nutomic
Copy link
Member

Nutomic commented Jan 19, 2022

Actually our dev chat room would be better: #lemmydev:matrix.org

@silverpill
Copy link

@Nutomic

Webfinger works fine in Lemmy with identically named users/groups, as it goes through all of them and uses the one that has the expected type.

How Lemmy selects the actor? Webfinger query response doesn't contain any information about the actor type. It seems that the only way to find the specific actor is to fetch all objects with rel=self and then choose one with the requested type

@Nutomic
Copy link
Member

Nutomic commented Dec 2, 2022

How Lemmy selects the actor? Webfinger query response doesn't contain any information about the actor type. It seems that the only way to find the specific actor is to fetch all objects with rel=self and then choose one with the requested type

That is exactly what we are doing. Its like this, Lemmy has one database table for communities and one for users. So the names are completely independent and cant collide. I had originally represented this as https://lemmy.ml/.well-known/webfinger?resource=group:news@lemmy.ml but other software wasnt compatible. Is there a better way to do this in webfinger?

@Nutomic Nutomic reopened this Dec 2, 2022
@silverpill
Copy link

You can add some metadata to a link relation object. Webfinger spec says that members of the links array can have properties: https://datatracker.ietf.org/doc/html/rfc7033#section-4.4.4.5

The "properties" object within the link relation object comprises zero or more name/value pairs whose names are URIs (referred to as "property identifiers") and whose values are strings or null. Properties are used to convey additional information about the link relation.

But I'm not sure what property identifier should be used in this case. Perhaps we can refer to ActivityStreams namespace:

{
  "subject": "acct:activitypub@lemmy.ml",
  "links": [
    {
      "rel": "self",
      "type": "application/activity+json",
      "href": "https://lemmy.ml/u/activitypub",
      "properties": {
        "https://www.w3.org/ns/activitystreams#type": "Person"
      }
    },
    {
      "rel": "self",
      "type": "application/activity+json",
      "href": "https://lemmy.ml/c/activitypub",
      "properties": {
        "https://www.w3.org/ns/activitystreams#type": "Group"
      }
    }
  ]
}

@Nutomic
Copy link
Member

Nutomic commented Dec 5, 2022

Thanks, I will try that when i have time. It would at least make parsing easier for Lemmy, though it wouldnt help with Mastodon compatibility.

@Nutomic Nutomic added enhancement New feature or request area: federation support federation via activitypub and removed bug Something isn't working labels Jan 15, 2023
Nutomic added a commit that referenced this issue Feb 20, 2023
So that it is easier to parse for other software
Nutomic added a commit that referenced this issue Feb 22, 2023
So that it is easier to parse for other software
Nutomic added a commit that referenced this issue Feb 22, 2023
So that it is easier to parse for other software
dessalines pushed a commit that referenced this issue Feb 22, 2023
So that it is easier to parse for other software
@silverpill
Copy link

It's working. Now a client can easily select actor depending on query prefix: Person if user asks for @name@domain.tld and Group if user asks for !name@domain.tld

@Nutomic
Copy link
Member

Nutomic commented Feb 25, 2023

@silverpill Thank you for suggesting this solution :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: federation support federation via activitypub enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants