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

Fix federation with GoToSocial and inconsistent KeyId in headers #2812

Merged
merged 16 commits into from
May 30, 2023

Commits on Apr 10, 2023

  1. Don't assume user id is key id minus fragment

    Fixes bookwyrm-social#2801
    Related to bookwyrm-social#2794
    
    It is legitimate to use any url for the user's key id. We have been assuming this id is the user id plus a fragment (#key-id) but this is not always the case, notably in the case of GoToSocial it is at /key-id. This commit instead checks the remote user's information to see if the key id listed matches the key id of the message allegedly received from them.
    
    Whilst troubleshooting this it also became apparent that there is a mismatch between Bookwyrm users' keyId and the KeyId we claim to be using in signed requests (there is a forward slash missing). Since everything after the slash is a fragment, this usually slips through but we should be consistent so I updated that.
    hughrun committed Apr 10, 2023
    Configuration menu
    Copy the full SHA
    632e384 View commit details
    Browse the repository at this point in the history
  2. formatting fixes

    hughrun committed Apr 10, 2023
    Configuration menu
    Copy the full SHA
    49758f2 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    e112718 View commit details
    Browse the repository at this point in the history
  4. Allow for tag value to be object

    Previously the 'tag' value in an activitypub object was assumed to be a List (array).
    Some AP software sends 'tag' as a Dict (object) if there is only a single tag value.
    It's somewhat debatable whether this is spec compliant but we should aim to be robust.
    This commit puts an individual mention tag inside a list if necessary.
    hughrun committed Apr 10, 2023
    Configuration menu
    Copy the full SHA
    ef85394 View commit details
    Browse the repository at this point in the history
  5. Include initial '@' in mention tag name

    GoToSocial expects the 'name' value of a mention tag to have an initial '@' symbol. Mastodon doesn't seem to mind either way.
    hughrun committed Apr 10, 2023
    Configuration menu
    Copy the full SHA
    c9dcd4f View commit details
    Browse the repository at this point in the history

Commits on Apr 11, 2023

  1. Use correct keyId with legacy fallback

    Bookwyrm keyIds are at `userpath/#main-key`, however when signing AP objects we have claimed in the headers that the keyId is at `userpath#main-key`.
    This is incorrect, and makes GoToSocial's strict checking break.
    Simply updating the signatures to use the correct KeyId breaks legacy Bookwyrm's signature checks, becuase it assumes that the keyId path is the same as the user path plus a fragment.
    This commit allows for either option, by sending the request a second time with the incorrect keyId if sending with the correct one causes an error.
    hughrun committed Apr 11, 2023
    Configuration menu
    Copy the full SHA
    03f21b0 View commit details
    Browse the repository at this point in the history
  2. add comment

    hughrun committed Apr 11, 2023
    Configuration menu
    Copy the full SHA
    279fa38 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    c450947 View commit details
    Browse the repository at this point in the history

Commits on Apr 13, 2023

  1. fix incoming GTS mentions and DMs

    GoToSocial sends 'tag' values as a single object if there is only one
    user mentioned, rather than an array with an object inside it.
    
    This causes Bookwyrm to reject the tag since it comes through as a
    dict rather than a list.
    
    This commit fixes this at the point the incoming AP object is transformed
    so that "mention" tags are turned into a mention_user.
    hughrun committed Apr 13, 2023
    Configuration menu
    Copy the full SHA
    e3261c6 View commit details
    Browse the repository at this point in the history
  2. formatting

    hughrun committed Apr 13, 2023
    Configuration menu
    Copy the full SHA
    a667671 View commit details
    Browse the repository at this point in the history
  3. make get_legacy_key more DRY

    hughrun committed Apr 13, 2023
    Configuration menu
    Copy the full SHA
    c7adb62 View commit details
    Browse the repository at this point in the history
  4. pylint fixes

    hughrun committed Apr 13, 2023
    Configuration menu
    Copy the full SHA
    56a062d View commit details
    Browse the repository at this point in the history
  5. fix tests and formatting

    hughrun committed Apr 13, 2023
    Configuration menu
    Copy the full SHA
    123628c View commit details
    Browse the repository at this point in the history

Commits on Apr 14, 2023

  1. Configuration menu
    Copy the full SHA
    8a8af4e View commit details
    Browse the repository at this point in the history
  2. oops black

    hughrun committed Apr 14, 2023
    Configuration menu
    Copy the full SHA
    9872658 View commit details
    Browse the repository at this point in the history
  3. Merge branch 'main' into gts

    hughrun authored Apr 14, 2023
    Configuration menu
    Copy the full SHA
    a0b7112 View commit details
    Browse the repository at this point in the history