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

Implement logging in via external identity providers #219

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions src/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { CreateCommentLike } from "./types/CreateCommentLike";
import { CreateCommentReport } from "./types/CreateCommentReport";
import { CreateCommunity } from "./types/CreateCommunity";
import { CreateCustomEmoji } from "./types/CreateCustomEmoji";
import { CreateExternalAuth } from "./types/CreateExternalAuth";
import { CreatePost } from "./types/CreatePost";
import { CreatePostLike } from "./types/CreatePostLike";
import { CreatePostReport } from "./types/CreatePostReport";
Expand All @@ -35,15 +36,18 @@ import { DeleteAccount } from "./types/DeleteAccount";
import { DeleteComment } from "./types/DeleteComment";
import { DeleteCommunity } from "./types/DeleteCommunity";
import { DeleteCustomEmoji } from "./types/DeleteCustomEmoji";
import { DeleteExternalAuth } from "./types/DeleteExternalAuth";
import { DeletePost } from "./types/DeletePost";
import { DeletePrivateMessage } from "./types/DeletePrivateMessage";
import { DistinguishComment } from "./types/DistinguishComment";
import { EditComment } from "./types/EditComment";
import { EditCommunity } from "./types/EditCommunity";
import { EditCustomEmoji } from "./types/EditCustomEmoji";
import { EditExternalAuth } from "./types/EditExternalAuth";
import { EditPost } from "./types/EditPost";
import { EditPrivateMessage } from "./types/EditPrivateMessage";
import { EditSite } from "./types/EditSite";
import { ExternalAuth } from "./types/ExternalAuth";
import { FeaturePost } from "./types/FeaturePost";
import { FollowCommunity } from "./types/FollowCommunity";
import { GetCaptchaResponse } from "./types/GetCaptchaResponse";
Expand Down Expand Up @@ -1376,6 +1380,45 @@ export class LemmyHttp {
);
}

/**
* Create a new external auth method
*
* `HTTP.POST /external_auth`
*/
createExternalAuth(form: CreateExternalAuth) {
return this.#wrapper<CreateExternalAuth, ExternalAuth>(
HttpType.Post,
"/external_auth",
form,
);
}

/**
* Edit an existing external auth method
*
* `HTTP.PUT /external_auth`
*/
editExternalAuth(form: EditExternalAuth) {
return this.#wrapper<EditExternalAuth, ExternalAuth>(
HttpType.Put,
"/external_auth",
form,
);
}

/**
* Delete an external auth method
*
* `HTTP.Post /external_auth/delete`
*/
deleteExternalAuth(form: DeleteExternalAuth) {
return this.#wrapper<DeleteExternalAuth, SuccessResponse>(
HttpType.Post,
"/external_auth/delete",
form,
);
}

/**
* Fetch federated instances.
*
Expand Down
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export { CreateCommentLike } from "./types/CreateCommentLike";
export { CreateCommentReport } from "./types/CreateCommentReport";
export { CreateCommunity } from "./types/CreateCommunity";
export { CreateCustomEmoji } from "./types/CreateCustomEmoji";
export { CreateExternalAuth } from "./types/CreateExternalAuth";
export { CreatePost } from "./types/CreatePost";
export { CreatePostLike } from "./types/CreatePostLike";
export { CreatePostReport } from "./types/CreatePostReport";
Expand All @@ -68,12 +69,14 @@ export { DeleteAccount } from "./types/DeleteAccount";
export { DeleteComment } from "./types/DeleteComment";
export { DeleteCommunity } from "./types/DeleteCommunity";
export { DeleteCustomEmoji } from "./types/DeleteCustomEmoji";
export { DeleteExternalAuth } from "./types/DeleteExternalAuth";
export { DeletePost } from "./types/DeletePost";
export { DeletePrivateMessage } from "./types/DeletePrivateMessage";
export { DistinguishComment } from "./types/DistinguishComment";
export { EditComment } from "./types/EditComment";
export { EditCommunity } from "./types/EditCommunity";
export { EditCustomEmoji } from "./types/EditCustomEmoji";
export { EditExternalAuth } from "./types/EditExternalAuth";
export { EditPost } from "./types/EditPost";
export { EditPrivateMessage } from "./types/EditPrivateMessage";
export { EditSite } from "./types/EditSite";
Expand Down
14 changes: 14 additions & 0 deletions src/types/CreateExternalAuth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export interface CreateExternalAuth {
display_name: string;
auth_type: string;
auth_endpoint: string;
token_endpoint: string;
user_endpoint: string;
id_attribute: string;
issuer: string;
client_id: string;
client_secret: string;
scopes: string;
}
1 change: 1 addition & 0 deletions src/types/CreateSite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ export interface CreateSite {
blocked_instances?: Array<string>;
taglines?: Array<string>;
registration_mode?: RegistrationMode;
oauth_registration?: boolean;
}
6 changes: 6 additions & 0 deletions src/types/DeleteExternalAuth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { ExternalAuthId } from "./ExternalAuthId";

export interface DeleteExternalAuth {
id: ExternalAuthId;
}
16 changes: 16 additions & 0 deletions src/types/EditExternalAuth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { ExternalAuthId } from "./ExternalAuthId";

export interface EditExternalAuth {
id: ExternalAuthId;
display_name: string;
auth_type: string;
auth_endpoint: string;
token_endpoint: string;
user_endpoint: string;
id_attribute: string;
issuer: string;
client_id: string;
client_secret: string;
scopes: string;
}
1 change: 1 addition & 0 deletions src/types/EditSite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@ export interface EditSite {
blocked_instances?: Array<string>;
taglines?: Array<string>;
registration_mode?: RegistrationMode;
oauth_registration?: boolean;
reports_email_admins?: boolean;
}
19 changes: 19 additions & 0 deletions src/types/ExternalAuth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { ExternalAuthId } from "./ExternalAuthId";
import type { LocalSiteId } from "./LocalSiteId";

export interface ExternalAuth {
id: ExternalAuthId;
display_name: string;
auth_type: string;
auth_endpoint: string;
token_endpoint: string;
user_endpoint: string;
id_attribute: string;
issuer: string;
client_id: string;
client_secret: string;
scopes: string;
published: string;
updated: string;
}
3 changes: 3 additions & 0 deletions src/types/ExternalAuthId.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type ExternalAuthId = number;
2 changes: 2 additions & 0 deletions src/types/GetSiteResponse.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { CustomEmojiView } from "./CustomEmojiView";
import type { ExternalAuth } from "./ExternalAuth";
import type { Language } from "./Language";
import type { LanguageId } from "./LanguageId";
import type { MyUserInfo } from "./MyUserInfo";
Expand All @@ -16,4 +17,5 @@ export interface GetSiteResponse {
discussion_languages: Array<LanguageId>;
taglines: Array<Tagline>;
custom_emojis: Array<CustomEmojiView>;
external_auths: Array<ExternalAuth>;
}
1 change: 1 addition & 0 deletions src/types/LocalSite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface LocalSite {
published: string;
updated?: string;
registration_mode: RegistrationMode;
oauth_registration: boolean;
reports_email_admins: boolean;
federation_signed_fetch: boolean;
}