Implement WebAuthn (#967)
* implement webauthn * code review --------- Co-authored-by: Madeline <46743919+MaddyUnderStars@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
co-authored by
Madeline
parent
e98cdfbce0
commit
709dc7280e
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
|
||||
Copyright (C) 2023 Fosscord and Fosscord Contributors
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
|
||||
import { BaseClass } from "./BaseClass";
|
||||
import { User } from "./User";
|
||||
|
||||
@Entity("security_keys")
|
||||
export class SecurityKey extends BaseClass {
|
||||
@Column({ nullable: true })
|
||||
@RelationId((key: SecurityKey) => key.user)
|
||||
user_id: string;
|
||||
|
||||
@JoinColumn({ name: "user_id" })
|
||||
@ManyToOne(() => User, {
|
||||
onDelete: "CASCADE",
|
||||
})
|
||||
user: User;
|
||||
|
||||
@Column()
|
||||
key_id: string;
|
||||
|
||||
@Column()
|
||||
public_key: string;
|
||||
|
||||
@Column()
|
||||
counter: number;
|
||||
|
||||
@Column()
|
||||
name: string;
|
||||
}
|
||||
@@ -33,6 +33,7 @@ import { UserSettings } from "./UserSettings";
|
||||
import { Session } from "./Session";
|
||||
import { Config, FieldErrors, Snowflake, trimSpecial, adjustEmail } from "..";
|
||||
import { Request } from "express";
|
||||
import { SecurityKey } from "./SecurityKey";
|
||||
|
||||
export enum PublicUserEnum {
|
||||
username,
|
||||
@@ -138,6 +139,9 @@ export class User extends BaseClass {
|
||||
@Column({ select: false })
|
||||
mfa_enabled: boolean = false; // if multi factor authentication is enabled
|
||||
|
||||
@Column({ select: false, default: false })
|
||||
webauthn_enabled: boolean = false; // if webauthn multi factor authentication is enabled
|
||||
|
||||
@Column({ select: false, nullable: true })
|
||||
totp_secret?: string = "";
|
||||
|
||||
@@ -223,6 +227,9 @@ export class User extends BaseClass {
|
||||
@Column({ type: "simple-json", select: false })
|
||||
extended_settings: string = "{}";
|
||||
|
||||
@OneToMany(() => SecurityKey, (key: SecurityKey) => key.user)
|
||||
security_keys: SecurityKey[];
|
||||
|
||||
// TODO: I don't like this method?
|
||||
validate() {
|
||||
if (this.email) {
|
||||
|
||||
@@ -23,8 +23,8 @@ export * from "./BackupCodes";
|
||||
export * from "./Ban";
|
||||
export * from "./BaseClass";
|
||||
export * from "./Categories";
|
||||
export * from "./ClientRelease";
|
||||
export * from "./Channel";
|
||||
export * from "./ClientRelease";
|
||||
export * from "./Config";
|
||||
export * from "./ConnectedAccount";
|
||||
export * from "./EmbedCache";
|
||||
@@ -41,6 +41,7 @@ export * from "./ReadState";
|
||||
export * from "./Recipient";
|
||||
export * from "./Relationship";
|
||||
export * from "./Role";
|
||||
export * from "./SecurityKey";
|
||||
export * from "./Session";
|
||||
export * from "./Sticker";
|
||||
export * from "./StickerPack";
|
||||
|
||||
Reference in New Issue
Block a user