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

Add Webfinger endpoint #19462

Merged
merged 17 commits into from May 9, 2022
Merged

Add Webfinger endpoint #19462

merged 17 commits into from May 9, 2022

Conversation

KN4CK3R
Copy link
Member

@KN4CK3R KN4CK3R commented Apr 21, 2022

This PR adds the Webfinger endpoint for federation.

Supported schemes are acct and mailto. The profile and avatar url are returned as metadata.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Apr 22, 2022
@Ta180m
Copy link
Contributor

Ta180m commented Apr 22, 2022

This is a great start, but I think there are still a few additions to make to match what Mastodon and PeerTube currently do. We'll need to add another item to links containing the ActivityPub actor IRI (in this case something like https://git.example.com/api/v1/activitypub/user/USERNAME), a remote interaction link (this hasn't been implemented yet for Gitea), and an aliases field.

@realaravinth
Copy link
Contributor

realaravinth commented Apr 22, 2022

Towards federation! 🚀

I'm interested in how you/the Gitea devs are planning to deal with Issues and Pull Requests. Gitea and all GitHub-like forges support subscribing to issues and pull requests, which will send notifications to the user about issue/PR activity. This is different from watching the repository for all activities.

Modelling this in ActivityPub: Issues, Pull Requests and Repositories when modelled as ActivityPub group actors, can allow actors(users) to follow and receive notifications on activity, very much like how subscribe works. If this approach is correct, then we would have to deal with namespace collisions, how can an issue/PR/repositoriy share the same namespace as usernames?

I'm part of ForgeFlux, a software project involved in implementing federation for popular forges using APIs. Our implementation deals with namespace collisions using special characters. For more information, kindly see our webfinger implementation docs.

@6543
Copy link
Member

6543 commented Apr 22, 2022

@realaravinth if you are interested in this, a summary can be found at #18240 and the focabulary is in work by ForgeFed (#14186)

@Ta180m
Copy link
Contributor

Ta180m commented Apr 22, 2022

Towards federation! 🚀

I'm interested in how you/the Gitea devs are planning to deal with Issues and Pull Requests. Gitea and all GitHub-like forges support subscribing to issues and pull requests, which will send notifications to the user about issue/PR activity. This is different from watching the repository for all activities.

Modelling this in ActivityPub: Issues, Pull Requests and Repositories when modelled as ActivityPub group actors, can allow actors(users) to follow and receive notifications on activity, very much like how subscribe works. If this approach is correct, then we would have to deal with namespace collisions, how can an issue/PR/repositoriy share the same namespace as usernames?

I'm part of ForgeFlux, a software project involved in implementing federation for popular forges using APIs. Our implementation deals with namespace collisions using special characters. For more information, kindly see our webfinger implementation docs.

ForgeFed models issues, PRs, and repositories using the Ticket and Repository types, instead of Group. I don't think namespace collisions will be a problem, because these different actors/objects will have different IRIs.

@realaravinth Is there a specific reason for using ! as the deliminator instead of / in the ForgeFlux implementation?

@KN4CK3R
Copy link
Member Author

KN4CK3R commented Apr 22, 2022

This is a great start, but I think there are still a few additions to make to match what Mastodon and PeerTube currently do. We'll need to add another item to links containing the ActivityPub actor IRI (in this case something like https://git.example.com/api/v1/activitypub/user/USERNAME), a remote interaction link (this hasn't been implemented yet for Gitea), and an aliases field.

I did not add them because they are not there at the moment. The ActivityPub PR should add that.
This PR only provides the basic endpoint for users. If we want/need more actors than users this should be added afterwards.

@Ta180m
Copy link
Contributor

Ta180m commented Apr 22, 2022

Sounds good, I'll add those fields to my PR #19133.

Edit: Done in 43d82e1c582262d15222f8f3370ef95d9c65ac6c

@6543 6543 added this to the 1.17.0 milestone Apr 22, 2022
routers/web/webfinger.go Outdated Show resolved Hide resolved
@KN4CK3R
Copy link
Member Author

KN4CK3R commented Apr 23, 2022

Is it intended that private users now can not participate in federation?

@codecov-commenter
Copy link

Codecov Report

Merging #19462 (8a3403d) into main (d242511) will decrease coverage by 0.15%.
The diff coverage is 41.37%.

@@            Coverage Diff             @@
##             main   #19462      +/-   ##
==========================================
- Coverage   47.51%   47.35%   -0.16%     
==========================================
  Files         944      952       +8     
  Lines      131549   132433     +884     
==========================================
+ Hits        62500    62715     +215     
- Misses      61541    62159     +618     
- Partials     7508     7559      +51     
Impacted Files Coverage Δ
cmd/dump.go 0.71% <0.00%> (-0.01%) ⬇️
cmd/serv.go 2.33% <0.00%> (-0.06%) ⬇️
models/action.go 48.61% <0.00%> (ø)
models/error.go 36.46% <ø> (-0.03%) ⬇️
models/issue_label.go 68.02% <0.00%> (ø)
models/issue_lock.go 0.00% <0.00%> (ø)
models/issue_project.go 31.70% <0.00%> (ø)
models/organization/team_repo.go 76.19% <0.00%> (ø)
models/pull.go 56.62% <0.00%> (+0.80%) ⬆️
models/statistic.go 0.00% <0.00%> (ø)
... and 153 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3ec1b6c...8a3403d. Read the comment docs.

@Ta180m
Copy link
Contributor

Ta180m commented Apr 23, 2022

Is it intended that private users now can not participate in federation?

By "private", do you mean their email is private? If so, I think they should still participate in federation.

Edit: I misunderstood the question. I agree that private users should not participate in federation.

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Apr 23, 2022
@6543
Copy link
Member

6543 commented Apr 23, 2022

hmm event. add 1 or 2 calls from an integration test - just to make sure it stays working

@realaravinth
Copy link
Contributor

@realaravinth if you are interested in this, a summary can be found at #18240 and the focabulary is in work by ForgeFed (#14186)

@6543: thank you, subscribed to both issues :)

ForgeFed models issues, PRs, and repositories using the Ticket and Repository types, instead of Group. I don't think namespace collisions will be a problem, because these different actors/objects will have different IRIs.

@Ta180m: ForgeFed Ticket inherits from object but has a followers attribute to accommodate subscribers. The followers attribute in the forgefed document links to AP followers collection, which says:

5.3 Followers Collection

Every actor SHOULD have a followers collection

IMHO inheriting from actor is more semantically accurate, thoughts?

Is there a specific reason for using ! as the deliminator instead of / in the ForgeFlux implementation?

Nothing in particular. I needed delimiting character that wasn't a part of the PRECIS framework(RFC8264) IdenfifierClass so that a valid username entered by a user won't contain the delimiting character and I saw lemmy using it for representing communities :D

routers/web/webfinger.go Outdated Show resolved Hide resolved
routers/web/webfinger.go Outdated Show resolved Hide resolved
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels May 3, 2022
Copy link
Contributor

@wxiaoguang wxiaoguang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments and questions.

routers/web/webfinger.go Show resolved Hide resolved
routers/web/webfinger.go Show resolved Hide resolved
routers/web/webfinger.go Show resolved Hide resolved
routers/web/webfinger.go Show resolved Hide resolved
routers/web/webfinger.go Show resolved Hide resolved
@wxiaoguang wxiaoguang dismissed their stale review May 7, 2022 19:16

Still have the question why not use url.Prase directly.

@6543 6543 self-assigned this May 9, 2022
Copy link
Member

@6543 6543 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still lgtm

@6543 6543 added the type/feature Completely new functionality. Can only be merged if feature freeze is not active. label May 9, 2022
@6543 6543 removed their assignment May 9, 2022
@6543 6543 merged commit 3da9daf into go-gitea:main May 9, 2022
@KN4CK3R KN4CK3R deleted the feature-webfinger branch May 9, 2022 20:51
zjjhot added a commit to zjjhot/gitea that referenced this pull request May 10, 2022
* giteaofficial/main:
  Use better message for consistency check (go-gitea#19672)
  Fix new release from tags list UI (go-gitea#19670)
  Update go deps (go-gitea#19665)
  [doctor] Add check/fix for bogus action rows (go-gitea#19656)
  [skip ci] Updated translations via Crowdin
  Add tooltip to pending PR comments (go-gitea#19662)
  Add Webfinger endpoint (go-gitea#19462)
  Update documentation to disable duration settings with -1 instead of 0 (go-gitea#19647)
  Set the LastModified header for raw files (go-gitea#18356)
  Don't select join table's columns (go-gitea#19660)
AbdulrhmnGhanem pushed a commit to kitspace/gitea that referenced this pull request Aug 24, 2022
This adds the [Webfinger](https://webfinger.net/) endpoint for federation.

Supported schemes are `acct` and `mailto`. The profile and avatar url are returned as metadata.
@go-gitea go-gitea locked and limited conversation to collaborators May 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. topic/federation type/feature Completely new functionality. Can only be merged if feature freeze is not active.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet