File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -133,7 +133,6 @@ export async function handleOAuthRedirect(request: NextRequest) {
133133
134134 // A user is trying to "Sign in with DevDogs" via OAuth
135135 if ( "redirect_uri" in params ) {
136- console . log ( params . client_id !== env . SHARED_AUTH_CLIENT_ID ) ;
137136 const [ insertedAuthorization ] = await db
138137 . insert ( authorizationCodes )
139138 . values ( {
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { db } from "../db";
33import { addSeconds } from "date-fns" ;
44import { oauthStates } from "../db/schema/tables" ;
55import { eq } from "drizzle-orm" ;
6+ import { env } from "~/env" ;
67
78const authorizationCode = z . object ( {
89 code : z . string ( ) ,
@@ -39,15 +40,24 @@ const completeOAuthFlow = z.object({
3940 . nonoptional ( ) ,
4041} ) ;
4142
42- const beginOAuthFlow = z . object ( {
43- redirect_uri : z . url ( {
44- // Only accept internal/private/local IP addresses
45- hostname :
46- / ( ^ l o c a l h o s t $ ) | ( ^ 0 \. 0 \. 0 \. 0 $ ) | ( ^ 1 2 7 \. ) | ( ^ 1 9 2 \. 1 6 8 \. ) | ( ^ 1 0 \. ) | ( ^ 1 7 2 \. 1 [ 6 - 9 ] \. ) | ( ^ 1 7 2 \. 2 [ 0 - 9 ] \. ) | ( ^ 1 7 2 \. 3 [ 0 - 1 ] \. ) | ( ^ : : 1 $ ) | ( ^ [ f F ] [ c C d D ] ) / i,
43+ const beginOAuthFlow = z . union ( [
44+ z . object ( {
45+ redirect_uri : z . url ( {
46+ // Only accept internal/private/local IP addresses
47+ hostname :
48+ / ( ^ l o c a l h o s t $ ) | ( ^ 0 \. 0 \. 0 \. 0 $ ) | ( ^ 1 2 7 \. ) | ( ^ 1 9 2 \. 1 6 8 \. ) | ( ^ 1 0 \. ) | ( ^ 1 7 2 \. 1 [ 6 - 9 ] \. ) | ( ^ 1 7 2 \. 2 [ 0 - 9 ] \. ) | ( ^ 1 7 2 \. 3 [ 0 - 1 ] \. ) | ( ^ : : 1 $ ) | ( ^ [ f F ] [ c C d D ] ) / i,
49+ } ) ,
50+ client_id : z . string ( ) ,
51+ state : z . string ( ) . optional ( ) ,
4752 } ) ,
48- client_id : z . string ( ) ,
49- state : z . string ( ) . optional ( ) ,
50- } ) ;
53+ z . object ( {
54+ redirect_uri : z . url ( {
55+ hostname : / d e v d o g s u g a .o r g $ / i,
56+ } ) ,
57+ client_id : z . literal ( env . SHARED_AUTH_CLIENT_ID ! ) ,
58+ state : z . string ( ) . optional ( ) ,
59+ } ) ,
60+ ] ) ;
5161
5262export const searchParamsSchema = z
5363 . instanceof ( URLSearchParams )
You can’t perform that action at this time.
0 commit comments