Skip to content

Commit 222b1d7

Browse files
committed
refactor: change pathname check from startsWith to strict equality for OAuth protected resource handling
1 parent 2916ad7 commit 222b1d7

File tree

28 files changed

+28
-50
lines changed

28 files changed

+28
-50
lines changed

exercises/01.discovery/03.solution.pr/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export default {
7979
return handleOAuthAuthorizationServerRequest()
8080
}
8181

82-
if (url.pathname.startsWith('/.well-known/oauth-protected-resource')) {
82+
if (url.pathname === '/.well-known/oauth-protected-resource') {
8383
return handleOAuthProtectedResourceRequest(request)
8484
}
8585

exercises/02.init/01.problem.authenticate/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export default {
7979
return handleOAuthAuthorizationServerRequest()
8080
}
8181

82-
if (url.pathname.startsWith('/.well-known/oauth-protected-resource')) {
82+
if (url.pathname === '/.well-known/oauth-protected-resource') {
8383
return handleOAuthProtectedResourceRequest(request)
8484
}
8585

exercises/02.init/01.solution.authenticate/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export default {
8080
return handleOAuthAuthorizationServerRequest()
8181
}
8282

83-
if (url.pathname.startsWith('/.well-known/oauth-protected-resource')) {
83+
if (url.pathname === '/.well-known/oauth-protected-resource') {
8484
return handleOAuthProtectedResourceRequest(request)
8585
}
8686

exercises/02.init/02.problem.params/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export default {
8080
return handleOAuthAuthorizationServerRequest()
8181
}
8282

83-
if (url.pathname.startsWith('/.well-known/oauth-protected-resource')) {
83+
if (url.pathname === '/.well-known/oauth-protected-resource') {
8484
return handleOAuthProtectedResourceRequest(request)
8585
}
8686

exercises/02.init/02.solution.params/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export default {
8080
return handleOAuthAuthorizationServerRequest()
8181
}
8282

83-
if (url.pathname.startsWith('/.well-known/oauth-protected-resource')) {
83+
if (url.pathname === '/.well-known/oauth-protected-resource') {
8484
return handleOAuthProtectedResourceRequest(request)
8585
}
8686

exercises/03.auth-info/01.problem.introspect/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export default {
8080
return handleOAuthAuthorizationServerRequest()
8181
}
8282

83-
if (url.pathname.startsWith('/.well-known/oauth-protected-resource')) {
83+
if (url.pathname === '/.well-known/oauth-protected-resource') {
8484
return handleOAuthProtectedResourceRequest(request)
8585
}
8686

exercises/03.auth-info/01.solution.introspect/src/auth.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ const introspectResponseSchema = z.object({
88
client_id: z.string(),
99
scope: z.string(),
1010
sub: z.string(),
11-
exp: z.number(),
1211
})
1312

1413
export async function getAuthInfo(
@@ -29,13 +28,12 @@ export async function getAuthInfo(
2928

3029
const data = introspectResponseSchema.parse(rawData)
3130

32-
const { sub, client_id, scope, exp } = data
31+
const { sub, client_id, scope } = data
3332

3433
return {
3534
token,
3635
clientId: client_id,
3736
scopes: scope.split(' '),
38-
expiresAt: exp,
3937
extra: { userId: sub },
4038
}
4139
}

exercises/03.auth-info/01.solution.introspect/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export default {
8181
return handleOAuthAuthorizationServerRequest()
8282
}
8383

84-
if (url.pathname.startsWith('/.well-known/oauth-protected-resource')) {
84+
if (url.pathname === '/.well-known/oauth-protected-resource') {
8585
return handleOAuthProtectedResourceRequest(request)
8686
}
8787

exercises/03.auth-info/02.problem.active/src/auth.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ const introspectResponseSchema = z.object({
88
client_id: z.string(),
99
scope: z.string(),
1010
sub: z.string(),
11-
exp: z.number(),
1211
})
1312

1413
export async function getAuthInfo(
@@ -29,13 +28,12 @@ export async function getAuthInfo(
2928

3029
const data = introspectResponseSchema.parse(rawData)
3130

32-
const { sub, client_id, scope, exp } = data
31+
const { sub, client_id, scope } = data
3332

3433
return {
3534
token,
3635
clientId: client_id,
3736
scopes: scope.split(' '),
38-
expiresAt: exp,
3937
extra: { userId: sub },
4038
}
4139
}

exercises/03.auth-info/02.problem.active/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export default {
8181
return handleOAuthAuthorizationServerRequest()
8282
}
8383

84-
if (url.pathname.startsWith('/.well-known/oauth-protected-resource')) {
84+
if (url.pathname === '/.well-known/oauth-protected-resource') {
8585
return handleOAuthProtectedResourceRequest(request)
8686
}
8787

0 commit comments

Comments
 (0)