Adding security / Auth definitions.

This commit is contained in:
Dessalines 2025-01-22 17:10:52 -05:00
parent 2b7ef3dc1c
commit 3e7d777082
2 changed files with 123 additions and 4 deletions

View file

@ -195,6 +195,7 @@ import {
Inject, Inject,
UploadedFile, UploadedFile,
Delete, Delete,
Security,
} from "tsoa"; } from "tsoa";
enum HttpType { enum HttpType {
@ -209,7 +210,7 @@ type RequestOptions = Pick<RequestInit, "signal">;
/** /**
* Helps build lemmy HTTP requests. * Helps build lemmy HTTP requests.
*/ */
@Route("/") @Route("api/v4")
export class LemmyHttp extends Controller { export class LemmyHttp extends Controller {
#apiUrl: string; #apiUrl: string;
#headers: { [key: string]: string } = {}; #headers: { [key: string]: string } = {};
@ -254,6 +255,7 @@ export class LemmyHttp extends Controller {
/** /**
* Create your site. * Create your site.
*/ */
@Security("bearerAuth")
@Post("/site") @Post("/site")
createSite(@Body() form: CreateSite, @Inject() options?: RequestOptions) { createSite(@Body() form: CreateSite, @Inject() options?: RequestOptions) {
return this.#wrapper<CreateSite, SiteResponse>( return this.#wrapper<CreateSite, SiteResponse>(
@ -267,6 +269,7 @@ export class LemmyHttp extends Controller {
/** /**
* Edit your site. * Edit your site.
*/ */
@Security("bearerAuth")
@Put("/site") @Put("/site")
editSite(@Body() form: EditSite, @Inject() options?: RequestOptions) { editSite(@Body() form: EditSite, @Inject() options?: RequestOptions) {
return this.#wrapper<EditSite, SiteResponse>( return this.#wrapper<EditSite, SiteResponse>(
@ -280,6 +283,7 @@ export class LemmyHttp extends Controller {
/** /**
* Leave the Site admins. * Leave the Site admins.
*/ */
@Security("bearerAuth")
@Post("/admin/leave") @Post("/admin/leave")
leaveAdmin(@Inject() options?: RequestOptions) { leaveAdmin(@Inject() options?: RequestOptions) {
return this.#wrapper<object, GetSiteResponse>( return this.#wrapper<object, GetSiteResponse>(
@ -295,6 +299,7 @@ export class LemmyHttp extends Controller {
* *
* Afterwards you need to call `/account/auth/totp/update` with a valid token to enable it. * Afterwards you need to call `/account/auth/totp/update` with a valid token to enable it.
*/ */
@Security("bearerAuth")
@Post("/account/auth/totp/generate") @Post("/account/auth/totp/generate")
generateTotpSecret(@Inject() options?: RequestOptions) { generateTotpSecret(@Inject() options?: RequestOptions) {
return this.#wrapper<object, GenerateTotpSecretResponse>( return this.#wrapper<object, GenerateTotpSecretResponse>(
@ -308,6 +313,7 @@ export class LemmyHttp extends Controller {
/** /**
* Get data of current user. * Get data of current user.
*/ */
@Security("bearerAuth")
@Get("/account") @Get("/account")
getMyUser(@Inject() options?: RequestOptions) { getMyUser(@Inject() options?: RequestOptions) {
return this.#wrapper<object, MyUserInfo>( return this.#wrapper<object, MyUserInfo>(
@ -322,6 +328,7 @@ export class LemmyHttp extends Controller {
* Export a backup of your user settings, including your saved content, * Export a backup of your user settings, including your saved content,
* followed communities, and blocks. * followed communities, and blocks.
*/ */
@Security("bearerAuth")
@Get("/account/settings/export") @Get("/account/settings/export")
exportSettings(@Inject() options?: RequestOptions) { exportSettings(@Inject() options?: RequestOptions) {
return this.#wrapper<object, string>( return this.#wrapper<object, string>(
@ -335,6 +342,7 @@ export class LemmyHttp extends Controller {
/** /**
* Import a backup of your user settings. * Import a backup of your user settings.
*/ */
@Security("bearerAuth")
@Post("/account/settings/import") @Post("/account/settings/import")
importSettings(@Body() form: any, @Inject() options?: RequestOptions) { importSettings(@Body() form: any, @Inject() options?: RequestOptions) {
return this.#wrapper<object, SuccessResponse>( return this.#wrapper<object, SuccessResponse>(
@ -348,6 +356,7 @@ export class LemmyHttp extends Controller {
/** /**
* List login tokens for your user * List login tokens for your user
*/ */
@Security("bearerAuth")
@Get("/account/list_logins") @Get("/account/list_logins")
listLogins(@Inject() options?: RequestOptions) { listLogins(@Inject() options?: RequestOptions) {
return this.#wrapper<object, LoginToken[]>( return this.#wrapper<object, LoginToken[]>(
@ -361,6 +370,7 @@ export class LemmyHttp extends Controller {
/** /**
* Returns an error message if your auth token is invalid * Returns an error message if your auth token is invalid
*/ */
@Security("bearerAuth")
@Get("/account/validate_auth") @Get("/account/validate_auth")
validateAuth(@Inject() options?: RequestOptions) { validateAuth(@Inject() options?: RequestOptions) {
return this.#wrapper<object, SuccessResponse>( return this.#wrapper<object, SuccessResponse>(
@ -374,6 +384,7 @@ export class LemmyHttp extends Controller {
/** /**
* List all the media for your user * List all the media for your user
*/ */
@Security("bearerAuth")
@Get("/account/list_media") @Get("/account/list_media")
listMedia( listMedia(
@Queries() form: ListMediaI = {}, @Queries() form: ListMediaI = {},
@ -390,6 +401,7 @@ export class LemmyHttp extends Controller {
/** /**
* List all the media known to your instance. * List all the media known to your instance.
*/ */
@Security("bearerAuth")
@Get("/admin/list_all_media") @Get("/admin/list_all_media")
listAllMedia( listAllMedia(
@Queries() form: ListMediaI = {}, @Queries() form: ListMediaI = {},
@ -411,6 +423,7 @@ export class LemmyHttp extends Controller {
* Disabling is only possible if 2FA was previously enabled. Again it is necessary to pass a valid token. * Disabling is only possible if 2FA was previously enabled. Again it is necessary to pass a valid token.
*/ */
@Security("bearerAuth")
@Post("/account/auth/totp/update") @Post("/account/auth/totp/update")
updateTotp(@Body() form: UpdateTotp, @Inject() options?: RequestOptions) { updateTotp(@Body() form: UpdateTotp, @Inject() options?: RequestOptions) {
return this.#wrapper<UpdateTotp, UpdateTotpResponse>( return this.#wrapper<UpdateTotp, UpdateTotpResponse>(
@ -469,6 +482,7 @@ export class LemmyHttp extends Controller {
/** /**
* Create a new community. * Create a new community.
*/ */
@Security("bearerAuth")
@Post("/community") @Post("/community")
createCommunity( createCommunity(
@Body() form: CreateCommunity, @Body() form: CreateCommunity,
@ -501,6 +515,7 @@ export class LemmyHttp extends Controller {
/** /**
* Edit a community. * Edit a community.
*/ */
@Security("bearerAuth")
@Put("/community") @Put("/community")
editCommunity( editCommunity(
@Body() form: EditCommunity, @Body() form: EditCommunity,
@ -533,6 +548,7 @@ export class LemmyHttp extends Controller {
/** /**
* Follow / subscribe to a community. * Follow / subscribe to a community.
*/ */
@Security("bearerAuth")
@Post("/community/follow") @Post("/community/follow")
followCommunity( followCommunity(
@Body() form: FollowCommunity, @Body() form: FollowCommunity,
@ -549,6 +565,7 @@ export class LemmyHttp extends Controller {
/** /**
* Get a community's pending follows count. * Get a community's pending follows count.
*/ */
@Security("bearerAuth")
@Get("/community/pending_follows/count") @Get("/community/pending_follows/count")
getCommunityPendingFollowsCount( getCommunityPendingFollowsCount(
@Queries() form: GetCommunityPendingFollowsCountI, @Queries() form: GetCommunityPendingFollowsCountI,
@ -563,6 +580,7 @@ export class LemmyHttp extends Controller {
/** /**
* Get a community's pending followers. * Get a community's pending followers.
*/ */
@Security("bearerAuth")
@Get("/community/pending_follows/list") @Get("/community/pending_follows/list")
listCommunityPendingFollows( listCommunityPendingFollows(
@Queries() form: ListCommunityPendingFollowsI, @Queries() form: ListCommunityPendingFollowsI,
@ -577,6 +595,7 @@ export class LemmyHttp extends Controller {
/** /**
* Approve a community pending follow request. * Approve a community pending follow request.
*/ */
@Security("bearerAuth")
@Post("/community/pending_follows/approve") @Post("/community/pending_follows/approve")
approveCommunityPendingFollow( approveCommunityPendingFollow(
@Body() form: ApproveCommunityPendingFollower, @Body() form: ApproveCommunityPendingFollower,
@ -593,6 +612,7 @@ export class LemmyHttp extends Controller {
/** /**
* Block a community. * Block a community.
*/ */
@Security("bearerAuth")
@Post("/account/block/community") @Post("/account/block/community")
blockCommunity( blockCommunity(
@Body() form: BlockCommunity, @Body() form: BlockCommunity,
@ -609,6 +629,7 @@ export class LemmyHttp extends Controller {
/** /**
* Delete a community. * Delete a community.
*/ */
@Security("bearerAuth")
@Post("/community/delete") @Post("/community/delete")
deleteCommunity( deleteCommunity(
@Body() form: DeleteCommunity, @Body() form: DeleteCommunity,
@ -625,6 +646,7 @@ export class LemmyHttp extends Controller {
/** /**
* Hide a community from public / "All" view. Admins only. * Hide a community from public / "All" view. Admins only.
*/ */
@Security("bearerAuth")
@Put("/community/hide") @Put("/community/hide")
hideCommunity( hideCommunity(
@Body() form: HideCommunity, @Body() form: HideCommunity,
@ -641,6 +663,7 @@ export class LemmyHttp extends Controller {
/** /**
* A moderator remove for a community. * A moderator remove for a community.
*/ */
@Security("bearerAuth")
@Post("/community/remove") @Post("/community/remove")
removeCommunity( removeCommunity(
@Body() form: RemoveCommunity, @Body() form: RemoveCommunity,
@ -657,6 +680,7 @@ export class LemmyHttp extends Controller {
/** /**
* Transfer your community to an existing moderator. * Transfer your community to an existing moderator.
*/ */
@Security("bearerAuth")
@Post("/community/transfer") @Post("/community/transfer")
transferCommunity( transferCommunity(
@Body() form: TransferCommunity, @Body() form: TransferCommunity,
@ -673,6 +697,7 @@ export class LemmyHttp extends Controller {
/** /**
* Ban a user from a community. * Ban a user from a community.
*/ */
@Security("bearerAuth")
@Post("/community/ban_user") @Post("/community/ban_user")
banFromCommunity( banFromCommunity(
@Body() form: BanFromCommunity, @Body() form: BanFromCommunity,
@ -689,6 +714,7 @@ export class LemmyHttp extends Controller {
/** /**
* Add a moderator to your community. * Add a moderator to your community.
*/ */
@Security("bearerAuth")
@Post("/community/mod") @Post("/community/mod")
addModToCommunity( addModToCommunity(
@Body() form: AddModToCommunity, @Body() form: AddModToCommunity,
@ -721,6 +747,7 @@ export class LemmyHttp extends Controller {
/** /**
* Create a post. * Create a post.
*/ */
@Security("bearerAuth")
@Post("/post") @Post("/post")
createPost(@Body() form: CreatePost, @Inject() options?: RequestOptions) { createPost(@Body() form: CreatePost, @Inject() options?: RequestOptions) {
return this.#wrapper<CreatePost, PostResponse>( return this.#wrapper<CreatePost, PostResponse>(
@ -747,6 +774,7 @@ export class LemmyHttp extends Controller {
/** /**
* Edit a post. * Edit a post.
*/ */
@Security("bearerAuth")
@Put("/post") @Put("/post")
editPost(@Body() form: EditPost, @Inject() options?: RequestOptions) { editPost(@Body() form: EditPost, @Inject() options?: RequestOptions) {
return this.#wrapper<EditPost, PostResponse>( return this.#wrapper<EditPost, PostResponse>(
@ -760,6 +788,7 @@ export class LemmyHttp extends Controller {
/** /**
* Delete a post. * Delete a post.
*/ */
@Security("bearerAuth")
@Post("/post/delete") @Post("/post/delete")
deletePost(@Body() form: DeletePost, @Inject() options?: RequestOptions) { deletePost(@Body() form: DeletePost, @Inject() options?: RequestOptions) {
return this.#wrapper<DeletePost, PostResponse>( return this.#wrapper<DeletePost, PostResponse>(
@ -773,6 +802,7 @@ export class LemmyHttp extends Controller {
/** /**
* A moderator remove for a post. * A moderator remove for a post.
*/ */
@Security("bearerAuth")
@Post("/post/remove") @Post("/post/remove")
removePost(@Body() form: RemovePost, @Inject() options?: RequestOptions) { removePost(@Body() form: RemovePost, @Inject() options?: RequestOptions) {
return this.#wrapper<RemovePost, PostResponse>( return this.#wrapper<RemovePost, PostResponse>(
@ -786,6 +816,7 @@ export class LemmyHttp extends Controller {
/** /**
* Mark a post as read. * Mark a post as read.
*/ */
@Security("bearerAuth")
@Post("/post/mark_as_read") @Post("/post/mark_as_read")
markPostAsRead( markPostAsRead(
@Body() form: MarkPostAsRead, @Body() form: MarkPostAsRead,
@ -802,6 +833,7 @@ export class LemmyHttp extends Controller {
/** /**
* Mark multiple posts as read. * Mark multiple posts as read.
*/ */
@Security("bearerAuth")
@Post("/post/mark_as_read/many") @Post("/post/mark_as_read/many")
markManyPostAsRead( markManyPostAsRead(
@Body() form: MarkManyPostsAsRead, @Body() form: MarkManyPostsAsRead,
@ -818,6 +850,7 @@ export class LemmyHttp extends Controller {
/** /**
* Hide a post from list views. * Hide a post from list views.
*/ */
@Security("bearerAuth")
@Post("/post/hide") @Post("/post/hide")
hidePost(@Body() form: HidePost, @Inject() options?: RequestOptions) { hidePost(@Body() form: HidePost, @Inject() options?: RequestOptions) {
return this.#wrapper<HidePost, SuccessResponse>( return this.#wrapper<HidePost, SuccessResponse>(
@ -831,6 +864,7 @@ export class LemmyHttp extends Controller {
/** /**
* A moderator can lock a post ( IE disable new comments ). * A moderator can lock a post ( IE disable new comments ).
*/ */
@Security("bearerAuth")
@Post("/post/lock") @Post("/post/lock")
lockPost(@Body() form: LockPost, @Inject() options?: RequestOptions) { lockPost(@Body() form: LockPost, @Inject() options?: RequestOptions) {
return this.#wrapper<LockPost, PostResponse>( return this.#wrapper<LockPost, PostResponse>(
@ -844,6 +878,7 @@ export class LemmyHttp extends Controller {
/** /**
* A moderator can feature a community post ( IE stick it to the top of a community ). * A moderator can feature a community post ( IE stick it to the top of a community ).
*/ */
@Security("bearerAuth")
@Post("/post/feature") @Post("/post/feature")
featurePost(@Body() form: FeaturePost, @Inject() options?: RequestOptions) { featurePost(@Body() form: FeaturePost, @Inject() options?: RequestOptions) {
return this.#wrapper<FeaturePost, PostResponse>( return this.#wrapper<FeaturePost, PostResponse>(
@ -873,6 +908,7 @@ export class LemmyHttp extends Controller {
/** /**
* Like / vote on a post. * Like / vote on a post.
*/ */
@Security("bearerAuth")
@Post("/post/like") @Post("/post/like")
likePost(@Body() form: CreatePostLike, @Inject() options?: RequestOptions) { likePost(@Body() form: CreatePostLike, @Inject() options?: RequestOptions) {
return this.#wrapper<CreatePostLike, PostResponse>( return this.#wrapper<CreatePostLike, PostResponse>(
@ -886,6 +922,7 @@ export class LemmyHttp extends Controller {
/** /**
* List a post's likes. Admin-only. * List a post's likes. Admin-only.
*/ */
@Security("bearerAuth")
@Get("/post/like/list") @Get("/post/like/list")
listPostLikes( listPostLikes(
@Queries() form: ListPostLikesI, @Queries() form: ListPostLikesI,
@ -902,6 +939,7 @@ export class LemmyHttp extends Controller {
/** /**
* Save a post. * Save a post.
*/ */
@Security("bearerAuth")
@Put("/post/save") @Put("/post/save")
savePost(@Body() form: SavePost, @Inject() options?: RequestOptions) { savePost(@Body() form: SavePost, @Inject() options?: RequestOptions) {
return this.#wrapper<SavePost, PostResponse>( return this.#wrapper<SavePost, PostResponse>(
@ -915,6 +953,7 @@ export class LemmyHttp extends Controller {
/** /**
* Report a post. * Report a post.
*/ */
@Security("bearerAuth")
@Post("/post/report") @Post("/post/report")
createPostReport( createPostReport(
@Body() form: CreatePostReport, @Body() form: CreatePostReport,
@ -931,6 +970,7 @@ export class LemmyHttp extends Controller {
/** /**
* Resolve a post report. Only a mod can do this. * Resolve a post report. Only a mod can do this.
*/ */
@Security("bearerAuth")
@Put("/post/report/resolve") @Put("/post/report/resolve")
resolvePostReport( resolvePostReport(
@Body() form: ResolvePostReport, @Body() form: ResolvePostReport,
@ -947,6 +987,7 @@ export class LemmyHttp extends Controller {
/** /**
* Fetch metadata for any given site. * Fetch metadata for any given site.
*/ */
@Security("bearerAuth")
@Get("/post/site_metadata") @Get("/post/site_metadata")
getSiteMetadata( getSiteMetadata(
@Queries() form: GetSiteMetadataI, @Queries() form: GetSiteMetadataI,
@ -963,6 +1004,7 @@ export class LemmyHttp extends Controller {
/** /**
* Create a comment. * Create a comment.
*/ */
@Security("bearerAuth")
@Post("/comment") @Post("/comment")
createComment( createComment(
@Body() form: CreateComment, @Body() form: CreateComment,
@ -979,6 +1021,7 @@ export class LemmyHttp extends Controller {
/** /**
* Edit a comment. * Edit a comment.
*/ */
@Security("bearerAuth")
@Put("/comment") @Put("/comment")
editComment(@Body() form: EditComment, @Inject() options?: RequestOptions) { editComment(@Body() form: EditComment, @Inject() options?: RequestOptions) {
return this.#wrapper<EditComment, CommentResponse>( return this.#wrapper<EditComment, CommentResponse>(
@ -992,6 +1035,7 @@ export class LemmyHttp extends Controller {
/** /**
* Delete a comment. * Delete a comment.
*/ */
@Security("bearerAuth")
@Post("/comment/delete") @Post("/comment/delete")
deleteComment( deleteComment(
@Body() form: DeleteComment, @Body() form: DeleteComment,
@ -1008,6 +1052,7 @@ export class LemmyHttp extends Controller {
/** /**
* A moderator remove for a comment. * A moderator remove for a comment.
*/ */
@Security("bearerAuth")
@Post("/comment/remove") @Post("/comment/remove")
removeComment( removeComment(
@Body() form: RemoveComment, @Body() form: RemoveComment,
@ -1024,6 +1069,7 @@ export class LemmyHttp extends Controller {
/** /**
* Mark a comment as read. * Mark a comment as read.
*/ */
@Security("bearerAuth")
@Post("/comment/mark_as_read") @Post("/comment/mark_as_read")
markCommentReplyAsRead( markCommentReplyAsRead(
@Body() form: MarkCommentReplyAsRead, @Body() form: MarkCommentReplyAsRead,
@ -1040,6 +1086,7 @@ export class LemmyHttp extends Controller {
/** /**
* Like / vote on a comment. * Like / vote on a comment.
*/ */
@Security("bearerAuth")
@Post("/comment/like") @Post("/comment/like")
likeComment( likeComment(
@Body() form: CreateCommentLike, @Body() form: CreateCommentLike,
@ -1056,6 +1103,7 @@ export class LemmyHttp extends Controller {
/** /**
* List a comment's likes. Admin-only. * List a comment's likes. Admin-only.
*/ */
@Security("bearerAuth")
@Get("/comment/like/list") @Get("/comment/like/list")
listCommentLikes( listCommentLikes(
@Queries() form: ListCommentLikesI, @Queries() form: ListCommentLikesI,
@ -1072,6 +1120,7 @@ export class LemmyHttp extends Controller {
/** /**
* Save a comment. * Save a comment.
*/ */
@Security("bearerAuth")
@Put("/comment/save") @Put("/comment/save")
saveComment(@Body() form: SaveComment, @Inject() options?: RequestOptions) { saveComment(@Body() form: SaveComment, @Inject() options?: RequestOptions) {
return this.#wrapper<SaveComment, CommentResponse>( return this.#wrapper<SaveComment, CommentResponse>(
@ -1085,6 +1134,7 @@ export class LemmyHttp extends Controller {
/** /**
* Distinguishes a comment (speak as moderator) * Distinguishes a comment (speak as moderator)
*/ */
@Security("bearerAuth")
@Post("/comment/distinguish") @Post("/comment/distinguish")
distinguishComment( distinguishComment(
@Body() form: DistinguishComment, @Body() form: DistinguishComment,
@ -1130,6 +1180,7 @@ export class LemmyHttp extends Controller {
/** /**
* Report a comment. * Report a comment.
*/ */
@Security("bearerAuth")
@Post("/comment/report") @Post("/comment/report")
createCommentReport( createCommentReport(
@Body() form: CreateCommentReport, @Body() form: CreateCommentReport,
@ -1146,6 +1197,7 @@ export class LemmyHttp extends Controller {
/** /**
* Resolve a comment report. Only a mod can do this. * Resolve a comment report. Only a mod can do this.
*/ */
@Security("bearerAuth")
@Put("/comment/report/resolve") @Put("/comment/report/resolve")
resolveCommentReport( resolveCommentReport(
@Body() form: ResolveCommentReport, @Body() form: ResolveCommentReport,
@ -1162,6 +1214,7 @@ export class LemmyHttp extends Controller {
/** /**
* Create a private message. * Create a private message.
*/ */
@Security("bearerAuth")
@Post("/private_message") @Post("/private_message")
createPrivateMessage( createPrivateMessage(
@Body() form: CreatePrivateMessage, @Body() form: CreatePrivateMessage,
@ -1178,6 +1231,7 @@ export class LemmyHttp extends Controller {
/** /**
* Edit a private message. * Edit a private message.
*/ */
@Security("bearerAuth")
@Put("/private_message") @Put("/private_message")
editPrivateMessage( editPrivateMessage(
@Body() form: EditPrivateMessage, @Body() form: EditPrivateMessage,
@ -1194,6 +1248,7 @@ export class LemmyHttp extends Controller {
/** /**
* Delete a private message. * Delete a private message.
*/ */
@Security("bearerAuth")
@Post("/private_message/delete") @Post("/private_message/delete")
deletePrivateMessage( deletePrivateMessage(
@Body() form: DeletePrivateMessage, @Body() form: DeletePrivateMessage,
@ -1210,6 +1265,7 @@ export class LemmyHttp extends Controller {
/** /**
* Mark a private message as read. * Mark a private message as read.
*/ */
@Security("bearerAuth")
@Post("/private_message/mark_as_read") @Post("/private_message/mark_as_read")
markPrivateMessageAsRead( markPrivateMessageAsRead(
@Body() form: MarkPrivateMessageAsRead, @Body() form: MarkPrivateMessageAsRead,
@ -1226,6 +1282,7 @@ export class LemmyHttp extends Controller {
/** /**
* Create a report for a private message. * Create a report for a private message.
*/ */
@Security("bearerAuth")
@Post("/private_message/report") @Post("/private_message/report")
createPrivateMessageReport( createPrivateMessageReport(
@Body() form: CreatePrivateMessageReport, @Body() form: CreatePrivateMessageReport,
@ -1240,6 +1297,7 @@ export class LemmyHttp extends Controller {
/** /**
* Resolve a report for a private message. * Resolve a report for a private message.
*/ */
@Security("bearerAuth")
@Put("/private_message/report/resolve") @Put("/private_message/report/resolve")
resolvePrivateMessageReport( resolvePrivateMessageReport(
@Body() form: ResolvePrivateMessageReport, @Body() form: ResolvePrivateMessageReport,
@ -1280,6 +1338,7 @@ export class LemmyHttp extends Controller {
/** /**
* Invalidate the currently used auth token. * Invalidate the currently used auth token.
*/ */
@Security("bearerAuth")
@Post("/account/auth/logout") @Post("/account/auth/logout")
logout(@Inject() options?: RequestOptions) { logout(@Inject() options?: RequestOptions) {
return this.#wrapper<object, SuccessResponse>( return this.#wrapper<object, SuccessResponse>(
@ -1325,6 +1384,7 @@ export class LemmyHttp extends Controller {
/** /**
* Mark a person mention as read. * Mark a person mention as read.
*/ */
@Security("bearerAuth")
@Post("/account/mention/comment/mark_as_read") @Post("/account/mention/comment/mark_as_read")
markCommentMentionAsRead( markCommentMentionAsRead(
@Body() form: MarkPersonCommentMentionAsRead, @Body() form: MarkPersonCommentMentionAsRead,
@ -1341,6 +1401,7 @@ export class LemmyHttp extends Controller {
/** /**
* Mark a person post body mention as read. * Mark a person post body mention as read.
*/ */
@Security("bearerAuth")
@Post("/account/mention/post/mark_as_read") @Post("/account/mention/post/mark_as_read")
markPostMentionAsRead( markPostMentionAsRead(
@Body() form: MarkPersonPostMentionAsRead, @Body() form: MarkPersonPostMentionAsRead,
@ -1357,6 +1418,7 @@ export class LemmyHttp extends Controller {
/** /**
* Ban a person from your site. * Ban a person from your site.
*/ */
@Security("bearerAuth")
@Post("/admin/ban") @Post("/admin/ban")
banPerson(@Body() form: BanPerson, @Inject() options?: RequestOptions) { banPerson(@Body() form: BanPerson, @Inject() options?: RequestOptions) {
return this.#wrapper<BanPerson, BanPersonResponse>( return this.#wrapper<BanPerson, BanPersonResponse>(
@ -1370,6 +1432,7 @@ export class LemmyHttp extends Controller {
/** /**
* Get a list of banned users. * Get a list of banned users.
*/ */
@Security("bearerAuth")
@Get("/admin/banned") @Get("/admin/banned")
getBannedPersons(@Inject() options?: RequestOptions) { getBannedPersons(@Inject() options?: RequestOptions) {
return this.#wrapper<object, BannedPersonsResponse>( return this.#wrapper<object, BannedPersonsResponse>(
@ -1383,6 +1446,7 @@ export class LemmyHttp extends Controller {
/** /**
* Block a person. * Block a person.
*/ */
@Security("bearerAuth")
@Post("/account/block/person") @Post("/account/block/person")
blockPerson(@Body() form: BlockPerson, @Inject() options?: RequestOptions) { blockPerson(@Body() form: BlockPerson, @Inject() options?: RequestOptions) {
return this.#wrapper<BlockPerson, BlockPersonResponse>( return this.#wrapper<BlockPerson, BlockPersonResponse>(
@ -1409,6 +1473,7 @@ export class LemmyHttp extends Controller {
/** /**
* Delete your account. * Delete your account.
*/ */
@Security("bearerAuth")
@Post("/account/delete") @Post("/account/delete")
deleteAccount( deleteAccount(
@Body() form: DeleteAccount, @Body() form: DeleteAccount,
@ -1425,6 +1490,7 @@ export class LemmyHttp extends Controller {
/** /**
* Reset your password. * Reset your password.
*/ */
@Security("bearerAuth")
@Post("/account/auth/password_reset") @Post("/account/auth/password_reset")
passwordReset( passwordReset(
@Body() form: PasswordReset, @Body() form: PasswordReset,
@ -1441,6 +1507,7 @@ export class LemmyHttp extends Controller {
/** /**
* Change your password from an email / token based reset. * Change your password from an email / token based reset.
*/ */
@Security("bearerAuth")
@Post("/account/auth/password_change") @Post("/account/auth/password_change")
passwordChangeAfterReset( passwordChangeAfterReset(
@Body() form: PasswordChangeAfterReset, @Body() form: PasswordChangeAfterReset,
@ -1457,6 +1524,7 @@ export class LemmyHttp extends Controller {
/** /**
* Mark all replies as read. * Mark all replies as read.
*/ */
@Security("bearerAuth")
@Post("/account/mark_as_read/all") @Post("/account/mark_as_read/all")
markAllNotificationsAsRead(@Inject() options?: RequestOptions) { markAllNotificationsAsRead(@Inject() options?: RequestOptions) {
return this.#wrapper<object, SuccessResponse>( return this.#wrapper<object, SuccessResponse>(
@ -1470,6 +1538,7 @@ export class LemmyHttp extends Controller {
/** /**
* Save your user settings. * Save your user settings.
*/ */
@Security("bearerAuth")
@Put("/account/settings/save") @Put("/account/settings/save")
saveUserSettings( saveUserSettings(
@Body() form: SaveUserSettings, @Body() form: SaveUserSettings,
@ -1486,6 +1555,7 @@ export class LemmyHttp extends Controller {
/** /**
* Change your user password. * Change your user password.
*/ */
@Security("bearerAuth")
@Put("/account/auth/change_password") @Put("/account/auth/change_password")
changePassword( changePassword(
@Body() form: ChangePassword, @Body() form: ChangePassword,
@ -1500,8 +1570,9 @@ export class LemmyHttp extends Controller {
} }
/** /**
* Get counts for your reports * Get counts for your reports.
*/ */
@Security("bearerAuth")
@Get("/account/report_count") @Get("/account/report_count")
getReportCount( getReportCount(
@Queries() form: GetReportCountI, @Queries() form: GetReportCountI,
@ -1516,8 +1587,9 @@ export class LemmyHttp extends Controller {
} }
/** /**
* Get your unread counts * Get your unread counts.
*/ */
@Security("bearerAuth")
@Get("/account/unread_count") @Get("/account/unread_count")
getUnreadCount(@Inject() options?: RequestOptions) { getUnreadCount(@Inject() options?: RequestOptions) {
return this.#wrapper<object, GetUnreadCountResponse>( return this.#wrapper<object, GetUnreadCountResponse>(
@ -1531,6 +1603,7 @@ export class LemmyHttp extends Controller {
/** /**
* Get your inbox (replies, comment mentions, post mentions, and messages) * Get your inbox (replies, comment mentions, post mentions, and messages)
*/ */
@Security("bearerAuth")
@Get("/account/inbox") @Get("/account/inbox")
listInbox(@Queries() form: ListInboxI, @Inject() options?: RequestOptions) { listInbox(@Queries() form: ListInboxI, @Inject() options?: RequestOptions) {
return this.#wrapper<ListInbox, ListInboxResponse>( return this.#wrapper<ListInbox, ListInboxResponse>(
@ -1557,6 +1630,7 @@ export class LemmyHttp extends Controller {
/** /**
* List your saved content. * List your saved content.
*/ */
@Security("bearerAuth")
@Get("/account/auth/saved") @Get("/account/auth/saved")
listPersonSaved( listPersonSaved(
@Queries() form: ListPersonSavedI, @Queries() form: ListPersonSavedI,
@ -1573,6 +1647,7 @@ export class LemmyHttp extends Controller {
/** /**
* Add an admin to your site. * Add an admin to your site.
*/ */
@Security("bearerAuth")
@Post("/admin/add") @Post("/admin/add")
addAdmin(@Body() form: AddAdmin, @Inject() options?: RequestOptions) { addAdmin(@Body() form: AddAdmin, @Inject() options?: RequestOptions) {
return this.#wrapper<AddAdmin, AddAdminResponse>( return this.#wrapper<AddAdmin, AddAdminResponse>(
@ -1586,6 +1661,7 @@ export class LemmyHttp extends Controller {
/** /**
* Get the unread registration applications count. * Get the unread registration applications count.
*/ */
@Security("bearerAuth")
@Get("/admin/registration_application/count") @Get("/admin/registration_application/count")
getUnreadRegistrationApplicationCount(@Inject() options?: RequestOptions) { getUnreadRegistrationApplicationCount(@Inject() options?: RequestOptions) {
return this.#wrapper<object, GetUnreadRegistrationApplicationCountResponse>( return this.#wrapper<object, GetUnreadRegistrationApplicationCountResponse>(
@ -1599,6 +1675,7 @@ export class LemmyHttp extends Controller {
/** /**
* List the registration applications. * List the registration applications.
*/ */
@Security("bearerAuth")
@Get("/admin/registration_application/list") @Get("/admin/registration_application/list")
listRegistrationApplications( listRegistrationApplications(
@Queries() form: ListRegistrationApplicationsI, @Queries() form: ListRegistrationApplicationsI,
@ -1613,6 +1690,7 @@ export class LemmyHttp extends Controller {
/** /**
* Approve a registration application * Approve a registration application
*/ */
@Security("bearerAuth")
@Put("/admin/registration_application/approve") @Put("/admin/registration_application/approve")
approveRegistrationApplication( approveRegistrationApplication(
@Body() form: ApproveRegistrationApplication, @Body() form: ApproveRegistrationApplication,
@ -1627,6 +1705,7 @@ export class LemmyHttp extends Controller {
/** /**
* Get the application a user submitted when they first registered their account * Get the application a user submitted when they first registered their account
*/ */
@Security("bearerAuth")
@Get("/admin/registration_application") @Get("/admin/registration_application")
getRegistrationApplication( getRegistrationApplication(
@Queries() form: GetRegistrationApplicationI, @Queries() form: GetRegistrationApplicationI,
@ -1641,6 +1720,7 @@ export class LemmyHttp extends Controller {
/** /**
* Purge / Delete a person from the database. * Purge / Delete a person from the database.
*/ */
@Security("bearerAuth")
@Post("/admin/purge/person") @Post("/admin/purge/person")
purgePerson(@Body() form: PurgePerson, @Inject() options?: RequestOptions) { purgePerson(@Body() form: PurgePerson, @Inject() options?: RequestOptions) {
return this.#wrapper<PurgePerson, SuccessResponse>( return this.#wrapper<PurgePerson, SuccessResponse>(
@ -1654,6 +1734,7 @@ export class LemmyHttp extends Controller {
/** /**
* Purge / Delete a community from the database. * Purge / Delete a community from the database.
*/ */
@Security("bearerAuth")
@Post("/admin/purge/community") @Post("/admin/purge/community")
purgeCommunity( purgeCommunity(
@Body() form: PurgeCommunity, @Body() form: PurgeCommunity,
@ -1670,6 +1751,7 @@ export class LemmyHttp extends Controller {
/** /**
* Purge / Delete a post from the database. * Purge / Delete a post from the database.
*/ */
@Security("bearerAuth")
@Post("/admin/purge/post") @Post("/admin/purge/post")
purgePost(@Body() form: PurgePost, @Inject() options?: RequestOptions) { purgePost(@Body() form: PurgePost, @Inject() options?: RequestOptions) {
return this.#wrapper<PurgePost, SuccessResponse>( return this.#wrapper<PurgePost, SuccessResponse>(
@ -1683,6 +1765,7 @@ export class LemmyHttp extends Controller {
/** /**
* Purge / Delete a comment from the database. * Purge / Delete a comment from the database.
*/ */
@Security("bearerAuth")
@Post("/admin/purge/comment") @Post("/admin/purge/comment")
purgeComment(@Body() form: PurgeComment, @Inject() options?: RequestOptions) { purgeComment(@Body() form: PurgeComment, @Inject() options?: RequestOptions) {
return this.#wrapper<PurgeComment, SuccessResponse>( return this.#wrapper<PurgeComment, SuccessResponse>(
@ -1696,6 +1779,7 @@ export class LemmyHttp extends Controller {
/** /**
* Create a new custom emoji. * Create a new custom emoji.
*/ */
@Security("bearerAuth")
@Post("/custom_emoji") @Post("/custom_emoji")
createCustomEmoji( createCustomEmoji(
@Body() form: CreateCustomEmoji, @Body() form: CreateCustomEmoji,
@ -1712,6 +1796,7 @@ export class LemmyHttp extends Controller {
/** /**
* Edit an existing custom emoji. * Edit an existing custom emoji.
*/ */
@Security("bearerAuth")
@Put("/custom_emoji") @Put("/custom_emoji")
editCustomEmoji( editCustomEmoji(
@Body() form: EditCustomEmoji, @Body() form: EditCustomEmoji,
@ -1728,6 +1813,7 @@ export class LemmyHttp extends Controller {
/** /**
* Delete a custom emoji. * Delete a custom emoji.
*/ */
@Security("bearerAuth")
@Post("/custom_emoji/delete") @Post("/custom_emoji/delete")
deleteCustomEmoji( deleteCustomEmoji(
@Body() form: DeleteCustomEmoji, @Body() form: DeleteCustomEmoji,
@ -1760,6 +1846,7 @@ export class LemmyHttp extends Controller {
/** /**
* Create a new tagline * Create a new tagline
*/ */
@Security("bearerAuth")
@Post("/admin/tagline") @Post("/admin/tagline")
createTagline( createTagline(
@Body() form: CreateTagline, @Body() form: CreateTagline,
@ -1776,6 +1863,7 @@ export class LemmyHttp extends Controller {
/** /**
* Edit an existing tagline * Edit an existing tagline
*/ */
@Security("bearerAuth")
@Put("/admin/tagline") @Put("/admin/tagline")
editTagline(@Body() form: UpdateTagline, @Inject() options?: RequestOptions) { editTagline(@Body() form: UpdateTagline, @Inject() options?: RequestOptions) {
return this.#wrapper<UpdateTagline, TaglineResponse>( return this.#wrapper<UpdateTagline, TaglineResponse>(
@ -1789,6 +1877,7 @@ export class LemmyHttp extends Controller {
/** /**
* Delete a tagline * Delete a tagline
*/ */
@Security("bearerAuth")
@Post("/admin/tagline/delete") @Post("/admin/tagline/delete")
deleteTagline( deleteTagline(
@Body() form: DeleteTagline, @Body() form: DeleteTagline,
@ -1805,6 +1894,7 @@ export class LemmyHttp extends Controller {
/** /**
* List taglines. * List taglines.
*/ */
@Security("bearerAuth")
@Get("/admin/tagline/list") @Get("/admin/tagline/list")
listTaglines( listTaglines(
@Queries() form: ListTaglinesI, @Queries() form: ListTaglinesI,
@ -1821,6 +1911,7 @@ export class LemmyHttp extends Controller {
/** /**
* Create a new oauth provider method * Create a new oauth provider method
*/ */
@Security("bearerAuth")
@Post("/oauth_provider") @Post("/oauth_provider")
createOAuthProvider( createOAuthProvider(
@Body() form: CreateOAuthProvider, @Body() form: CreateOAuthProvider,
@ -1837,6 +1928,7 @@ export class LemmyHttp extends Controller {
/** /**
* Edit an existing oauth provider method * Edit an existing oauth provider method
*/ */
@Security("bearerAuth")
@Put("/oauth_provider") @Put("/oauth_provider")
editOAuthProvider( editOAuthProvider(
@Body() form: EditOAuthProvider, @Body() form: EditOAuthProvider,
@ -1853,6 +1945,7 @@ export class LemmyHttp extends Controller {
/** /**
* Delete an oauth provider method * Delete an oauth provider method
*/ */
@Security("bearerAuth")
@Post("/oauth_provider/delete") @Post("/oauth_provider/delete")
deleteOAuthProvider( deleteOAuthProvider(
@Body() form: DeleteOAuthProvider, @Body() form: DeleteOAuthProvider,
@ -1869,6 +1962,7 @@ export class LemmyHttp extends Controller {
/** /**
* Authenticate with OAuth * Authenticate with OAuth
*/ */
@Security("bearerAuth")
@Post("/oauth/authenticate") @Post("/oauth/authenticate")
authenticateWithOAuth( authenticateWithOAuth(
@Body() form: AuthenticateWithOauth, @Body() form: AuthenticateWithOauth,
@ -1898,6 +1992,7 @@ export class LemmyHttp extends Controller {
/** /**
* List user reports. * List user reports.
*/ */
@Security("bearerAuth")
@Get("/report/list") @Get("/report/list")
listReports( listReports(
@Queries() form: ListReportsI, @Queries() form: ListReportsI,
@ -1914,6 +2009,7 @@ export class LemmyHttp extends Controller {
/** /**
* Block an instance as user. * Block an instance as user.
*/ */
@Security("bearerAuth")
@Post("/account/block/instance") @Post("/account/block/instance")
userBlockInstance( userBlockInstance(
@Body() form: UserBlockInstanceParams, @Body() form: UserBlockInstanceParams,
@ -1930,6 +2026,7 @@ export class LemmyHttp extends Controller {
/** /**
* Globally block an instance as admin. * Globally block an instance as admin.
*/ */
@Security("bearerAuth")
@Post("/admin/instance/block") @Post("/admin/instance/block")
adminBlockInstance( adminBlockInstance(
@Body() form: AdminBlockInstanceParams, @Body() form: AdminBlockInstanceParams,
@ -1946,6 +2043,7 @@ export class LemmyHttp extends Controller {
/** /**
* Globally allow an instance as admin. * Globally allow an instance as admin.
*/ */
@Security("bearerAuth")
@Post("/admin/instance/allow") @Post("/admin/instance/allow")
adminAllowInstance( adminAllowInstance(
@Body() form: AdminAllowInstanceParams, @Body() form: AdminAllowInstanceParams,
@ -1962,6 +2060,7 @@ export class LemmyHttp extends Controller {
/** /**
* Upload new user avatar. * Upload new user avatar.
*/ */
@Security("bearerAuth")
@Post("/account/avatar") @Post("/account/avatar")
async uploadUserAvatar( async uploadUserAvatar(
@UploadedFile() image: UploadImage, @UploadedFile() image: UploadImage,
@ -1973,6 +2072,7 @@ export class LemmyHttp extends Controller {
/** /**
* Delete the user avatar. * Delete the user avatar.
*/ */
@Security("bearerAuth")
@Delete("/account/avatar") @Delete("/account/avatar")
async deleteUserAvatar( async deleteUserAvatar(
@Inject() options?: RequestOptions, @Inject() options?: RequestOptions,
@ -1988,6 +2088,7 @@ export class LemmyHttp extends Controller {
/** /**
* Upload new user banner. * Upload new user banner.
*/ */
@Security("bearerAuth")
@Post("/account/banner") @Post("/account/banner")
async uploadUserBanner( async uploadUserBanner(
@UploadedFile() image: UploadImage, @UploadedFile() image: UploadImage,
@ -1999,6 +2100,7 @@ export class LemmyHttp extends Controller {
/** /**
* Delete the user banner. * Delete the user banner.
*/ */
@Security("bearerAuth")
@Delete("/account/banner") @Delete("/account/banner")
async deleteUserBanner(@Inject() options?: RequestOptions) { async deleteUserBanner(@Inject() options?: RequestOptions) {
return this.#wrapper<object, SuccessResponse>( return this.#wrapper<object, SuccessResponse>(
@ -2012,6 +2114,7 @@ export class LemmyHttp extends Controller {
/** /**
* Upload new community icon. * Upload new community icon.
*/ */
@Security("bearerAuth")
@Post("/community/icon") @Post("/community/icon")
async uploadCommunityIcon( async uploadCommunityIcon(
@UploadedFile() image: UploadImage, @UploadedFile() image: UploadImage,
@ -2023,6 +2126,7 @@ export class LemmyHttp extends Controller {
/** /**
* Delete the community icon. * Delete the community icon.
*/ */
@Security("bearerAuth")
@Delete("/community/icon") @Delete("/community/icon")
async deleteCommunityIcon( async deleteCommunityIcon(
@Inject() options?: RequestOptions, @Inject() options?: RequestOptions,
@ -2038,6 +2142,7 @@ export class LemmyHttp extends Controller {
/** /**
* Upload new community banner. * Upload new community banner.
*/ */
@Security("bearerAuth")
@Post("/community/banner") @Post("/community/banner")
async uploadCommunityBanner( async uploadCommunityBanner(
@UploadedFile() image: UploadImage, @UploadedFile() image: UploadImage,
@ -2049,6 +2154,7 @@ export class LemmyHttp extends Controller {
/** /**
* Delete the community banner. * Delete the community banner.
*/ */
@Security("bearerAuth")
@Delete("/community/banner") @Delete("/community/banner")
async deleteCommunityBanner( async deleteCommunityBanner(
@Inject() options?: RequestOptions, @Inject() options?: RequestOptions,
@ -2064,6 +2170,7 @@ export class LemmyHttp extends Controller {
/** /**
* Upload new site icon. * Upload new site icon.
*/ */
@Security("bearerAuth")
@Post("/site/icon") @Post("/site/icon")
async uploadSiteIcon( async uploadSiteIcon(
@UploadedFile() image: UploadImage, @UploadedFile() image: UploadImage,
@ -2075,6 +2182,7 @@ export class LemmyHttp extends Controller {
/** /**
* Delete the site icon. * Delete the site icon.
*/ */
@Security("bearerAuth")
@Delete("/site/icon") @Delete("/site/icon")
async deleteSiteIcon( async deleteSiteIcon(
@Inject() options?: RequestOptions, @Inject() options?: RequestOptions,
@ -2090,6 +2198,7 @@ export class LemmyHttp extends Controller {
/** /**
* Upload new site banner. * Upload new site banner.
*/ */
@Security("bearerAuth")
@Post("/site/banner") @Post("/site/banner")
async uploadSiteBanner( async uploadSiteBanner(
@UploadedFile() image: UploadImage, @UploadedFile() image: UploadImage,
@ -2101,6 +2210,7 @@ export class LemmyHttp extends Controller {
/** /**
* Delete the site banner. * Delete the site banner.
*/ */
@Security("bearerAuth")
@Delete("/site/banner") @Delete("/site/banner")
async deleteSiteBanner( async deleteSiteBanner(
@Inject() options?: RequestOptions, @Inject() options?: RequestOptions,
@ -2116,6 +2226,7 @@ export class LemmyHttp extends Controller {
/** /**
* Upload an image to the server. * Upload an image to the server.
*/ */
@Security("bearerAuth")
@Post("/image") @Post("/image")
async uploadImage( async uploadImage(
@UploadedFile() image: UploadImage, @UploadedFile() image: UploadImage,
@ -2127,6 +2238,7 @@ export class LemmyHttp extends Controller {
/** /**
* Delete a pictrs image * Delete a pictrs image
*/ */
@Security("bearerAuth")
@Delete("/image") @Delete("/image")
async deleteImage( async deleteImage(
@Queries() form: DeleteImageParamsI, @Queries() form: DeleteImageParamsI,

View file

@ -4,7 +4,14 @@
"controllerPathGlobs": ["src/http.ts"], "controllerPathGlobs": ["src/http.ts"],
"spec": { "spec": {
"outputDirectory": "tsoa_build", "outputDirectory": "tsoa_build",
"specVersion": 3 "specVersion": 3,
"securityDefinitions": {
"bearerAuth": {
"type": "http",
"scheme": "bearer",
"bearerFormat": "JWT"
}
}
}, },
"routes": { "routes": {
"routesDir": "tsoa_build" "routesDir": "tsoa_build"