From 198add87beec48c8257c6e8479e2f37f1446e907 Mon Sep 17 00:00:00 2001 From: Bram Borggreve Date: Wed, 17 Jan 2024 08:36:02 +0000 Subject: [PATCH] refactor: clean up auth strategy files --- libs/api/auth/data-access/src/index.ts | 8 ++++---- .../strategies/oauth/api-auth-strategy-discord-guard.ts | 5 ----- .../src/lib/strategies/oauth/api-auth-strategy-discord.ts | 5 ++++- .../strategies/oauth/api-auth-strategy-github-guard.ts | 5 ----- .../src/lib/strategies/oauth/api-auth-strategy-github.ts | 5 ++++- .../strategies/oauth/api-auth-strategy-google-guard.ts | 5 ----- .../src/lib/strategies/oauth/api-auth-strategy-google.ts | 5 ++++- .../strategies/oauth/api-auth-strategy-twitter-guard.ts | 5 ----- .../src/lib/strategies/oauth/api-auth-strategy-twitter.ts | 5 ++++- 9 files changed, 20 insertions(+), 28 deletions(-) delete mode 100644 libs/api/auth/data-access/src/lib/strategies/oauth/api-auth-strategy-discord-guard.ts delete mode 100644 libs/api/auth/data-access/src/lib/strategies/oauth/api-auth-strategy-github-guard.ts delete mode 100644 libs/api/auth/data-access/src/lib/strategies/oauth/api-auth-strategy-google-guard.ts delete mode 100644 libs/api/auth/data-access/src/lib/strategies/oauth/api-auth-strategy-twitter-guard.ts diff --git a/libs/api/auth/data-access/src/index.ts b/libs/api/auth/data-access/src/index.ts index 912d586..cbff1f7 100644 --- a/libs/api/auth/data-access/src/index.ts +++ b/libs/api/auth/data-access/src/index.ts @@ -7,7 +7,7 @@ export * from './lib/guards/api-anon-jwt-guard' export * from './lib/guards/api-auth-graphql-admin-guard' export * from './lib/guards/api-auth-graphql-user-guard' export * from './lib/interfaces/api-auth.request' -export * from './lib/strategies/oauth/api-auth-strategy-discord-guard' -export * from './lib/strategies/oauth/api-auth-strategy-github-guard' -export * from './lib/strategies/oauth/api-auth-strategy-google-guard' -export * from './lib/strategies/oauth/api-auth-strategy-twitter-guard' +export * from './lib/strategies/oauth/api-auth-strategy-discord' +export * from './lib/strategies/oauth/api-auth-strategy-github' +export * from './lib/strategies/oauth/api-auth-strategy-google' +export * from './lib/strategies/oauth/api-auth-strategy-twitter' diff --git a/libs/api/auth/data-access/src/lib/strategies/oauth/api-auth-strategy-discord-guard.ts b/libs/api/auth/data-access/src/lib/strategies/oauth/api-auth-strategy-discord-guard.ts deleted file mode 100644 index bb2ccb0..0000000 --- a/libs/api/auth/data-access/src/lib/strategies/oauth/api-auth-strategy-discord-guard.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { Injectable } from '@nestjs/common' -import { AuthGuard } from '@nestjs/passport' - -@Injectable() -export class ApiAuthStrategyDiscordGuard extends AuthGuard('discord') {} diff --git a/libs/api/auth/data-access/src/lib/strategies/oauth/api-auth-strategy-discord.ts b/libs/api/auth/data-access/src/lib/strategies/oauth/api-auth-strategy-discord.ts index 994d505..4b8d31d 100644 --- a/libs/api/auth/data-access/src/lib/strategies/oauth/api-auth-strategy-discord.ts +++ b/libs/api/auth/data-access/src/lib/strategies/oauth/api-auth-strategy-discord.ts @@ -1,11 +1,14 @@ import { Injectable } from '@nestjs/common' -import { PassportStrategy } from '@nestjs/passport' +import { AuthGuard, PassportStrategy } from '@nestjs/passport' import { IdentityProvider } from '@prisma/client' import { ApiCoreService } from '@pubkey-stack/api-core-data-access' import { Profile, Strategy } from 'passport-discord' import type { ApiAuthRequest } from '../../interfaces/api-auth.request' import { ApiAuthStrategyService } from '../api-auth-strategy.service' +@Injectable() +export class ApiAuthStrategyDiscordGuard extends AuthGuard('discord') {} + @Injectable() export class ApiAuthStrategyDiscord extends PassportStrategy(Strategy, 'discord') { constructor(private core: ApiCoreService, private service: ApiAuthStrategyService) { diff --git a/libs/api/auth/data-access/src/lib/strategies/oauth/api-auth-strategy-github-guard.ts b/libs/api/auth/data-access/src/lib/strategies/oauth/api-auth-strategy-github-guard.ts deleted file mode 100644 index 64fb7b7..0000000 --- a/libs/api/auth/data-access/src/lib/strategies/oauth/api-auth-strategy-github-guard.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { Injectable } from '@nestjs/common' -import { AuthGuard } from '@nestjs/passport' - -@Injectable() -export class ApiAuthStrategyGithubGuard extends AuthGuard('github') {} diff --git a/libs/api/auth/data-access/src/lib/strategies/oauth/api-auth-strategy-github.ts b/libs/api/auth/data-access/src/lib/strategies/oauth/api-auth-strategy-github.ts index 2ed2492..7e77a7c 100644 --- a/libs/api/auth/data-access/src/lib/strategies/oauth/api-auth-strategy-github.ts +++ b/libs/api/auth/data-access/src/lib/strategies/oauth/api-auth-strategy-github.ts @@ -1,11 +1,14 @@ import { Injectable } from '@nestjs/common' -import { PassportStrategy } from '@nestjs/passport' +import { AuthGuard, PassportStrategy } from '@nestjs/passport' import { IdentityProvider } from '@prisma/client' import { ApiCoreService } from '@pubkey-stack/api-core-data-access' import { Profile, Strategy } from 'passport-github' import type { ApiAuthRequest } from '../../interfaces/api-auth.request' import { ApiAuthStrategyService } from '../api-auth-strategy.service' +@Injectable() +export class ApiAuthStrategyGithubGuard extends AuthGuard('github') {} + @Injectable() export class ApiAuthStrategyGithub extends PassportStrategy(Strategy, 'github') { constructor(private core: ApiCoreService, private service: ApiAuthStrategyService) { diff --git a/libs/api/auth/data-access/src/lib/strategies/oauth/api-auth-strategy-google-guard.ts b/libs/api/auth/data-access/src/lib/strategies/oauth/api-auth-strategy-google-guard.ts deleted file mode 100644 index 507b75e..0000000 --- a/libs/api/auth/data-access/src/lib/strategies/oauth/api-auth-strategy-google-guard.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { Injectable } from '@nestjs/common' -import { AuthGuard } from '@nestjs/passport' - -@Injectable() -export class ApiAuthStrategyGoogleGuard extends AuthGuard('google') {} diff --git a/libs/api/auth/data-access/src/lib/strategies/oauth/api-auth-strategy-google.ts b/libs/api/auth/data-access/src/lib/strategies/oauth/api-auth-strategy-google.ts index ac23ea8..c23e1b0 100644 --- a/libs/api/auth/data-access/src/lib/strategies/oauth/api-auth-strategy-google.ts +++ b/libs/api/auth/data-access/src/lib/strategies/oauth/api-auth-strategy-google.ts @@ -1,11 +1,14 @@ import { Injectable } from '@nestjs/common' -import { PassportStrategy } from '@nestjs/passport' +import { AuthGuard, PassportStrategy } from '@nestjs/passport' import { IdentityProvider } from '@prisma/client' import { ApiCoreService } from '@pubkey-stack/api-core-data-access' import { Profile, Strategy } from 'passport-google-oauth20' import type { ApiAuthRequest } from '../../interfaces/api-auth.request' import { ApiAuthStrategyService } from '../api-auth-strategy.service' +@Injectable() +export class ApiAuthStrategyGoogleGuard extends AuthGuard('google') {} + @Injectable() export class ApiAuthStrategyGoogle extends PassportStrategy(Strategy, 'google') { constructor(private core: ApiCoreService, private service: ApiAuthStrategyService) { diff --git a/libs/api/auth/data-access/src/lib/strategies/oauth/api-auth-strategy-twitter-guard.ts b/libs/api/auth/data-access/src/lib/strategies/oauth/api-auth-strategy-twitter-guard.ts deleted file mode 100644 index 84e43fe..0000000 --- a/libs/api/auth/data-access/src/lib/strategies/oauth/api-auth-strategy-twitter-guard.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { Injectable } from '@nestjs/common' -import { AuthGuard } from '@nestjs/passport' - -@Injectable() -export class ApiAuthStrategyTwitterGuard extends AuthGuard('twitter') {} diff --git a/libs/api/auth/data-access/src/lib/strategies/oauth/api-auth-strategy-twitter.ts b/libs/api/auth/data-access/src/lib/strategies/oauth/api-auth-strategy-twitter.ts index 9d0bf8c..d9b1994 100644 --- a/libs/api/auth/data-access/src/lib/strategies/oauth/api-auth-strategy-twitter.ts +++ b/libs/api/auth/data-access/src/lib/strategies/oauth/api-auth-strategy-twitter.ts @@ -1,11 +1,14 @@ import { Injectable } from '@nestjs/common' -import { PassportStrategy } from '@nestjs/passport' +import { AuthGuard, PassportStrategy } from '@nestjs/passport' import { IdentityProvider } from '@prisma/client' import { ApiCoreService } from '@pubkey-stack/api-core-data-access' import { Profile, Strategy } from 'passport-twitter' import type { ApiAuthRequest } from '../../interfaces/api-auth.request' import { ApiAuthStrategyService } from '../api-auth-strategy.service' +@Injectable() +export class ApiAuthStrategyTwitterGuard extends AuthGuard('twitter') {} + @Injectable() export class ApiAuthStrategyTwitter extends PassportStrategy(Strategy, 'twitter') { constructor(private core: ApiCoreService, private service: ApiAuthStrategyService) {