Prechádzať zdrojové kódy

refactor: Remove GitHub authentication

Owen Diffey 2 týždňov pred
rodič
commit
fb26083539

+ 0 - 4
.wiki/Configuration.md

@@ -89,10 +89,6 @@ For more information on configuration files please refer to the
 | `apis.soundcloud.rateLimit` | Minimum interval between SoundCloud API requests in milliseconds. |
 | `apis.soundcloud.requestTimeout` | SoundCloud API requests timeout in milliseconds. |
 | `apis.soundcloud.retryAmount` | The amount of retries to perform of a failed SoundCloud API request. |
-| `apis.github.enabled` | Whether to enable GitHub authentication. |
-| `apis.github.client` | GitHub OAuth Application client, obtained from [here](https://github.com/settings/developers). |
-| `apis.github.secret` | GitHub OAuth Application secret, obtained with client. |
-| `apis.github.redirect_uri` | The backend url with `/auth/github/authorize/callback` appended, for example `http://localhost/backend/auth/github/authorize/callback`. This is configured based on the `url` config option by default. |
 | `apis.discogs.enabled` | Whether to enable Discogs API usage. |
 | `apis.discogs.client` | Discogs Application client, obtained from [here](https://www.discogs.com/settings/developers). |
 | `apis.discogs.secret` | Discogs Application secret, obtained with client. |

+ 1 - 1
README.md

@@ -71,7 +71,7 @@ A production demonstration instance of Musare can be found at [demo.musare.com](
   - Activity logs
   - Profile page showing public playlists and activity logs
   - Text or gravatar profile pictures
-  - Email or Github login/registration
+  - Password login/registration
   - Preferences to tailor site usage
   - Password reset
   - Data deletion management

+ 0 - 6
backend/config/default.json

@@ -47,12 +47,6 @@
 			"requestTimeout": 5000,
 			"retryAmount": 2
 		},
-		"github": {
-			"enabled": false,
-			"client": "",
-			"secret": "",
-			"redirect_uri": ""
-		},
 		"discogs": {
 			"enabled": false,
 			"client": "",

+ 0 - 8
backend/src/modules/DataModule/migrations/1725485641-create-users-table.ts

@@ -72,14 +72,6 @@ export const up = async ({
 			type: DataTypes.DATE,
 			allowNull: true
 		},
-		githubId: {
-			type: DataTypes.BIGINT,
-			allowNull: true
-		},
-		githubAccessToken: {
-			type: DataTypes.STRING,
-			allowNull: true
-		},
 		songsRequested: {
 			type: DataTypes.BIGINT,
 			allowNull: false,

+ 0 - 12
backend/src/modules/DataModule/models/User.ts

@@ -59,9 +59,6 @@ export class User extends Model<
 
 	declare passwordSetExpiresAt: CreationOptional<Date | null>;
 
-	declare githubId: CreationOptional<number | null>;
-
-	declare githubAccessToken: CreationOptional<string | null>;
 	// End services
 
 	// Statistics
@@ -222,14 +219,6 @@ export const schema = {
 		type: DataTypes.DATE,
 		allowNull: true
 	},
-	githubId: {
-		type: DataTypes.BIGINT,
-		allowNull: true
-	},
-	githubAccessToken: {
-		type: DataTypes.STRING,
-		allowNull: true
-	},
 	songsRequested: {
 		type: DataTypes.BIGINT,
 		allowNull: false,
@@ -301,7 +290,6 @@ export const options = {
 				"password",
 				"passwordResetCode",
 				"passwordSetCode",
-				"githubAccessToken"
 			]
 		}
 	}

+ 0 - 1
backend/src/modules/DataModule/models/User/getData.ts

@@ -6,7 +6,6 @@ export default {
 		"services.password.reset.expires",
 		"services.password.set.code",
 		"services.password.set.expires",
-		"services.github.access_token",
 		"email.verificationToken"
 	],
 	specialProperties: {

+ 0 - 1
backend/src/modules/WebSocketModule.ts

@@ -177,7 +177,6 @@ export class WebSocketModule extends BaseModule {
 			config: {
 				cookie: config.get("cookie"),
 				sitename: config.get("sitename"),
-				githubAuthentication: config.get("apis.github.enabled"),
 				messages: config.get("messages"),
 				christmas: config.get("christmas"),
 				footerLinks: config.get("footerLinks"),

+ 0 - 13
frontend/src/App.vue

@@ -1,5 +1,4 @@
 <script setup lang="ts">
-import { useRouter } from "vue-router";
 import { defineAsyncComponent, ref, watch, onMounted } from "vue";
 import Toast from "toasters";
 import { storeToRefs } from "pinia";
@@ -22,8 +21,6 @@ const FallingSnow = defineAsyncComponent(
 	() => import("@/components/FallingSnow.vue")
 );
 
-const router = useRouter();
-
 const { socket } = useWebsocketsStore();
 const configStore = useConfigStore();
 const userAuthStore = useUserAuthStore();
@@ -165,16 +162,6 @@ onMounted(async () => {
 		});
 
 		openModal("whatIsNew");
-
-		router.isReady().then(() => {
-			if (
-				configStore.githubAuthentication &&
-				localStorage.getItem("github_redirect")
-			) {
-				router.push(localStorage.getItem("github_redirect"));
-				localStorage.removeItem("github_redirect");
-			}
-		});
 	});
 
 	socket.onDisconnect(() => {

+ 1 - 31
frontend/src/components/modals/Login.vue

@@ -21,7 +21,7 @@ const passwordVisible = ref(false);
 const passwordElement = ref();
 
 const configStore = useConfigStore();
-const { githubAuthentication, registrationDisabled } = storeToRefs(configStore);
+const { registrationDisabled } = storeToRefs(configStore);
 const { login } = useUserAuthStore();
 
 const { openModal, closeCurrentModal } = useModalsStore();
@@ -80,10 +80,6 @@ const changeToRegisterModal = () => {
 	closeCurrentModal();
 	openModal("register");
 };
-
-const githubRedirect = () => {
-	localStorage.setItem("github_redirect", route.path);
-};
 </script>
 
 <template>
@@ -168,20 +164,6 @@ const githubRedirect = () => {
 					<button class="button is-primary" @click="submitModal()">
 						Login
 					</button>
-					<a
-						v-if="githubAuthentication"
-						class="button is-github"
-						:href="configStore.urls.api + '/auth/github/authorize'"
-						@click="githubRedirect()"
-					>
-						<div class="icon">
-							<img
-								class="invert"
-								src="/assets/social/github.svg"
-							/>
-						</div>
-						&nbsp;&nbsp;Login with GitHub
-					</a>
 				</div>
 
 				<p
@@ -222,18 +204,6 @@ const githubRedirect = () => {
 	}
 }
 
-.button.is-github {
-	background-color: var(--dark-grey-2);
-	color: var(--white) !important;
-}
-
-.is-github:focus {
-	background-color: var(--dark-grey-4);
-}
-.is-primary:focus {
-	background-color: var(--primary-color) !important;
-}
-
 .invert {
 	filter: brightness(5);
 }

+ 1 - 29
frontend/src/components/modals/Register.vue

@@ -40,8 +40,7 @@ const passwordElement = ref();
 const { register } = useUserAuthStore();
 
 const configStore = useConfigStore();
-const { registrationDisabled, recaptcha, githubAuthentication } =
-	storeToRefs(configStore);
+const { registrationDisabled } = storeToRefs(configStore);
 const { openModal, closeCurrentModal } = useModalsStore();
 
 const submitModal = () => {
@@ -74,10 +73,6 @@ const changeToLoginModal = () => {
 	openModal("login");
 };
 
-const githubRedirect = () => {
-	localStorage.setItem("github_redirect", route.path);
-};
-
 watch(
 	() => username.value.value,
 	value => {
@@ -251,20 +246,6 @@ onMounted(async () => {
 					<button class="button is-primary" @click="submitModal()">
 						Register
 					</button>
-					<a
-						v-if="githubAuthentication"
-						class="button is-github"
-						:href="configStore.urls.api + '/auth/github/authorize'"
-						@click="githubRedirect()"
-					>
-						<div class="icon">
-							<img
-								class="invert"
-								src="/assets/social/github.svg"
-							/>
-						</div>
-						&nbsp;&nbsp;Register with GitHub
-					</a>
 				</div>
 
 				<p class="content-box-optional-helper">
@@ -306,15 +287,6 @@ onMounted(async () => {
 	}
 }
 
-.button.is-github {
-	background-color: var(--dark-grey-2);
-	color: var(--white) !important;
-}
-
-.is-github:focus {
-	background-color: var(--dark-grey-4);
-}
-
 .invert {
 	filter: brightness(5);
 }

+ 0 - 22
frontend/src/pages/Admin/Users/index.vue

@@ -63,14 +63,6 @@ const columns = ref<TableColumn[]>([
 		minWidth: 230,
 		defaultWidth: 230
 	},
-	{
-		name: "githubId",
-		displayName: "GitHub ID",
-		properties: ["githubId"],
-		sortProperty: "githubId",
-		minWidth: 115,
-		defaultWidth: 115
-	},
 	{
 		name: "hasPassword",
 		displayName: "Has Password",
@@ -132,13 +124,6 @@ const filters = ref<TableFilter[]>([
 		filterTypes: ["contains", "exact", "regex"],
 		defaultFilterType: "contains"
 	},
-	{
-		name: "githubId",
-		displayName: "GitHub ID",
-		property: "services.github.id",
-		filterTypes: ["contains", "exact", "regex"],
-		defaultFilterType: "contains"
-	},
 	{
 		name: "hasPassword",
 		displayName: "Has Password",
@@ -268,13 +253,6 @@ onMounted(() => {
 					slotProps.item._id
 				}}</span>
 			</template>
-			<template #column-githubId="slotProps">
-				<span
-					v-if="slotProps.item.githubId"
-					:title="slotProps.item.githubId"
-					>{{ slotProps.item.githubId }}</span
-				>
-			</template>
 			<template #column-hasPassword="slotProps">
 				<span :title="slotProps.item.hasPassword">{{
 					slotProps.item.hasPassword

+ 4 - 5
frontend/src/pages/Privacy.vue

@@ -34,11 +34,10 @@ const MainFooter = defineAsyncComponent(
 				address, mailing address, phone number, photo, username from
 				other social media sites, gender, date of birth, or other
 				relevant information. In addition, we utilize third party API’s
-				like GitHub Authentication, and other API’s that allow you to
-				transfer your profile information from those Sites to ours
-				depending on your settings on those Sites. We are not
-				responsible for any information that does not transfer or if any
-				information is inaccurate.
+				that allow you to transfer your profile information from those
+				Sites to ours depending on your settings on those Sites. We are
+				not responsible for any information that does not transfer or if
+				any information is inaccurate.
 			</p>
 
 			<p>

+ 2 - 62
frontend/src/pages/Settings/Tabs/Security.vue

@@ -17,7 +17,7 @@ const QuickConfirm = defineAsyncComponent(
 );
 
 const configStore = useConfigStore();
-const { githubAuthentication, sitename } = storeToRefs(configStore);
+const { sitename } = storeToRefs(configStore);
 const settingsStore = useSettingsStore();
 const userAuthStore = useUserAuthStore();
 const { runJob } = useWebsocketStore();
@@ -42,7 +42,7 @@ const validation = reactive({
 const newPassword = ref();
 const oldPassword = ref();
 
-const { isPasswordLinked, isGithubLinked } = settingsStore;
+const { isPasswordLinked } = settingsStore;
 const { currentUser } = storeToRefs(userAuthStore);
 
 const togglePasswordVisibility = refName => {
@@ -82,16 +82,6 @@ const changePassword = () => {
 		}
 	);
 };
-const unlinkPassword = () => {
-	socket.dispatch("users.unlinkPassword", res => {
-		new Toast(res.message);
-	});
-};
-const unlinkGitHub = () => {
-	socket.dispatch("users.unlinkGitHub", res => {
-		new Toast(res.message);
-	});
-};
 const removeSessions = async () => {
 	await runJob("data.users.logoutAll");
 
@@ -215,56 +205,6 @@ watch(validation, newValidation => {
 			<div class="section-margin-bottom" />
 		</div>
 
-		<div v-if="!isGithubLinked && githubAuthentication">
-			<h4 class="section-title">Link your GitHub account</h4>
-			<p class="section-description">
-				Link your {{ sitename }} account with GitHub
-			</p>
-
-			<hr class="section-horizontal-rule" />
-
-			<a
-				class="button is-github"
-				:href="`${configStore.urls.api}/auth/github/link`"
-			>
-				<div class="icon">
-					<img class="invert" src="/assets/social/github.svg" />
-				</div>
-				&nbsp; Link GitHub to account
-			</a>
-
-			<div class="section-margin-bottom" />
-		</div>
-
-		<div v-if="isPasswordLinked && isGithubLinked">
-			<h4 class="section-title">Remove login methods</h4>
-			<p class="section-description">
-				Remove your password as a login method or unlink GitHub
-			</p>
-
-			<hr class="section-horizontal-rule" />
-
-			<div class="row">
-				<quick-confirm
-					v-if="isPasswordLinked && githubAuthentication"
-					@confirm="unlinkPassword()"
-				>
-					<a class="button is-danger">
-						<i class="material-icons icon-with-button">close</i>
-						Remove password
-					</a>
-				</quick-confirm>
-				<quick-confirm v-if="isGithubLinked" @confirm="unlinkGitHub()">
-					<a class="button is-danger">
-						<i class="material-icons icon-with-button">link_off</i>
-						Remove GitHub from account
-					</a>
-				</quick-confirm>
-			</div>
-
-			<div class="section-margin-bottom" />
-		</div>
-
 		<div>
 			<h4 class="section-title">Log out everywhere</h4>
 			<p class="section-description">

+ 6 - 7
frontend/src/pages/Terms.vue

@@ -75,13 +75,12 @@ const MainFooter = defineAsyncComponent(
 			</p>
 			<p>
 				We may also allow you to use a third party API to sign up for
-				our Site, like GitHub Authentication. Whenever you use this
-				feature, certain information will be transferred from the third
-				party account and will populate your profile here at Musare. It
-				is important to read and understand that third parties privacy
-				and information sharing practices and principles. More
-				importantly, you will be making certain information publicly
-				viewable.
+				our Site. Whenever you use this feature, certain information will
+				be transferred from the third party account and will populate your
+				profile here at Musare. It is important to read and understand that
+				third parties privacy and information sharing practices and
+				principles. More importantly, you will be making certain information
+				publicly viewable.
 			</p>
 			<p>
 				If you register for any feature that requires a password and/or

+ 0 - 2
frontend/src/stores/config.ts

@@ -4,7 +4,6 @@ export const useConfigStore = defineStore("config", {
 	state: (): {
 		cookie: string;
 		sitename: string;
-		githubAuthentication: boolean;
 		messages: Record<string, string>;
 		christmas: boolean;
 		footerLinks: Record<string, string | boolean>;
@@ -24,7 +23,6 @@ export const useConfigStore = defineStore("config", {
 	} => ({
 		cookie: "musareSID",
 		sitename: MUSARE_SITENAME,
-		githubAuthentication: false,
 		messages: {
 			accountRemoval:
 				"Your account will be deactivated instantly and your data will shortly be deleted by an admin."

+ 0 - 1
frontend/src/stores/settings.ts

@@ -30,7 +30,6 @@ export const useSettingsStore = defineStore("settings", {
 		}
 	},
 	getters: {
-		isGithubLinked: state => state.originalUser.github,
 		isPasswordLinked: state => state.originalUser.password
 	}
 });