Documentation ¶
Index ¶
- Constants
- Variables
- func New(config *config.Config, processor processing.Processor) api.FederationModule
- type Module
- func (m *Module) FollowersGETHandler(c *gin.Context)
- func (m *Module) FollowingGETHandler(c *gin.Context)
- func (m *Module) InboxPOSTHandler(c *gin.Context)
- func (m *Module) OutboxGETHandler(c *gin.Context)
- func (m *Module) PublicKeyGETHandler(c *gin.Context)
- func (m *Module) Route(s router.Router) error
- func (m *Module) StatusGETHandler(c *gin.Context)
- func (m *Module) StatusRepliesGETHandler(c *gin.Context)
- func (m *Module) UsersGETHandler(c *gin.Context)
- type SwaggerCollection
- type SwaggerCollectionPage
Constants ¶
const ( // UsernameKey is for account usernames. UsernameKey = "username" // StatusIDKey is for status IDs StatusIDKey = "status" // OnlyOtherAccountsKey is for filtering status responses. OnlyOtherAccountsKey = "only_other_accounts" // MinIDKey is for filtering status responses. MinIDKey = "min_id" // MaxIDKey is for filtering status responses. MaxIDKey = "max_id" // PageKey is for filtering status responses. PageKey = "page" // UsersBasePath is the base path for serving information about Users eg https://example.org/users UsersBasePath = "/" + util.UsersPath // UsersBasePathWithUsername is just the users base path with the Username key in it. // Use this anywhere you need to know the username of the user being queried. // Eg https://example.org/users/:username UsersBasePathWithUsername = UsersBasePath + "/:" + UsernameKey // UsersPublicKeyPath is a path to a user's public key, for serving bare minimum AP representations. UsersPublicKeyPath = UsersBasePathWithUsername + "/" + util.PublicKeyPath // UsersInboxPath is for serving POST requests to a user's inbox with the given username key. UsersInboxPath = UsersBasePathWithUsername + "/" + util.InboxPath // UsersOutboxPath is for serving GET requests to a user's outbox with the given username key. UsersOutboxPath = UsersBasePathWithUsername + "/" + util.OutboxPath // UsersFollowersPath is for serving GET request's to a user's followers list, with the given username key. UsersFollowersPath = UsersBasePathWithUsername + "/" + util.FollowersPath // UsersFollowingPath is for serving GET request's to a user's following list, with the given username key. UsersFollowingPath = UsersBasePathWithUsername + "/" + util.FollowingPath // UsersStatusPath is for serving GET requests to a particular status by a user, with the given username key and status ID UsersStatusPath = UsersBasePathWithUsername + "/" + util.StatusesPath + "/:" + StatusIDKey // UsersStatusRepliesPath is for serving the replies collection of a status. UsersStatusRepliesPath = UsersStatusPath + "/replies" )
Variables ¶
var ActivityPubAcceptHeaders = []string{
`application/activity+json`,
`application/ld+json; profile="https://www.w3.org/ns/activitystreams"`,
}
ActivityPubAcceptHeaders represents the Accept headers mentioned here: https://www.w3.org/TR/activitypub/#retrieving-objects
Functions ¶
func New ¶
func New(config *config.Config, processor processing.Processor) api.FederationModule
New returns a new auth module
Types ¶
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
Module implements the FederationAPIModule interface
func (*Module) FollowersGETHandler ¶
FollowersGETHandler returns a collection of URIs for followers of the target user, formatted so that other AP servers can understand it.
func (*Module) FollowingGETHandler ¶
FollowingGETHandler returns a collection of URIs for accounts that the target user follows, formatted so that other AP servers can understand it.
func (*Module) InboxPOSTHandler ¶
InboxPOSTHandler deals with incoming POST requests to an actor's inbox. Eg., POST to https://example.org/users/whatever/inbox.
func (*Module) OutboxGETHandler ¶
OutboxGETHandler swagger:operation GET /users/{username}/outbox s2sOutboxGet
Get the public outbox collection for an actor.
Note that the response will be a Collection with a page as `first`, as shown below, if `page` is `false`.
If `page` is `true`, then the response will be a single `CollectionPage` without the wrapping `Collection`.
HTTP signature is required on the request.
--- tags: - s2s/federation
produces: - application/activity+json
parameters:
- name: username type: string description: Username of the account. in: path required: true
- name: page type: boolean description: Return response as a CollectionPage. in: query default: false
- name: min_id type: string description: Minimum ID of the next status, used for paging. in: query
- name: max_id type: string description: Maximum ID of the next status, used for paging. in: query
responses:
'200': in: body schema: "$ref": "#/definitions/swaggerCollection" '400': description: bad request '401': description: unauthorized '403': description: forbidden '404': description: not found
func (*Module) PublicKeyGETHandler ¶
PublicKeyGETHandler should be served at eg https://example.org/users/:username/main-key.
The goal here is to return a MINIMAL activitypub representation of an account in the form of a vocab.ActivityStreamsPerson. The account will only contain the id, public key, username, and type of the account.
func (*Module) StatusGETHandler ¶
StatusGETHandler serves the target status as an activitystreams NOTE so that other AP servers can parse it.
func (*Module) StatusRepliesGETHandler ¶
StatusRepliesGETHandler swagger:operation GET /users/{username}/statuses/{status}/replies s2sRepliesGet
Get the replies collection for a status.
Note that the response will be a Collection with a page as `first`, as shown below, if `page` is `false`.
If `page` is `true`, then the response will be a single `CollectionPage` without the wrapping `Collection`.
HTTP signature is required on the request.
--- tags: - s2s/federation
produces: - application/activity+json
parameters:
- name: username type: string description: Username of the account. in: path required: true
- name: status type: string description: ID of the status. in: path required: true
- name: page type: boolean description: Return response as a CollectionPage. in: query default: false
- name: only_other_accounts type: boolean description: Return replies only from accounts other than the status owner. in: query default: false
- name: min_id type: string description: Minimum ID of the next status, used for paging. in: query
responses:
'200': in: body schema: "$ref": "#/definitions/swaggerCollection" '400': description: bad request '401': description: unauthorized '403': description: forbidden '404': description: not found
func (*Module) UsersGETHandler ¶
UsersGETHandler should be served at https://example.org/users/:username.
The goal here is to return the activitypub representation of an account in the form of a vocab.ActivityStreamsPerson. This should only be served to REMOTE SERVERS that present a valid signature on the GET request, on behalf of a user, otherwise we risk leaking information about users publicly.
And of course, the request should be refused if the account or server making the request is blocked.
type SwaggerCollection ¶
type SwaggerCollection struct { // ActivityStreams context. // example: https://www.w3.org/ns/activitystreams Context string `json:"@context"` // ActivityStreams ID. // example: https://example.org/users/some_user/statuses/106717595988259568/replies ID string `json:"id"` // ActivityStreams type. // example: Collection Type string `json:"type"` // ActivityStreams first property. First SwaggerCollectionPage `json:"first"` // ActivityStreams last property. Last SwaggerCollectionPage `json:"last,omitempty"` }
SwaggerCollection represents an activitypub collection. swagger:model swaggerCollection
type SwaggerCollectionPage ¶
type SwaggerCollectionPage struct { // ActivityStreams ID. // example: https://example.org/users/some_user/statuses/106717595988259568/replies?page=true ID string `json:"id"` // ActivityStreams type. // example: CollectionPage Type string `json:"type"` // Link to the next page. // example: https://example.org/users/some_user/statuses/106717595988259568/replies?only_other_accounts=true&page=true Next string `json:"next"` // Collection this page belongs to. // example: https://example.org/users/some_user/statuses/106717595988259568/replies PartOf string `json:"partOf"` // Items on this page. // example: ["https://example.org/users/some_other_user/statuses/086417595981111564", "https://another.example.com/users/another_user/statuses/01FCN8XDV3YG7B4R42QA6YQZ9R"] Items []string `json:"items"` }
SwaggerCollectionPage represents one page of a collection. swagger:model swaggerCollectionPage