File tree Expand file tree Collapse file tree 3 files changed +31
-11
lines changed
Expand file tree Collapse file tree 3 files changed +31
-11
lines changed Original file line number Diff line number Diff line change @@ -46,11 +46,24 @@ export default async function authorizationRoute(fastify: FastifyInstance) {
4646 code_challenge_method
4747 } = request . query as z . infer < typeof authorizationQuerySchema > ;
4848
49+ // Validate response_type (additional validation beyond schema)
50+ if ( response_type !== 'code' ) {
51+ request . log . warn ( {
52+ operation : 'oauth2_authorization' ,
53+ responseType : response_type ,
54+ error : 'unsupported_response_type' ,
55+ } , 'Unsupported OAuth2 response type' ) ;
56+
57+ const errorUrl = `${ redirect_uri } ?error=unsupported_response_type&error_description=${ encodeURIComponent ( 'Only "code" response type is supported' ) } &state=${ state } ` ;
58+ return reply . redirect ( errorUrl ) ;
59+ }
60+
4961 request . log . debug ( {
5062 operation : 'oauth2_authorization' ,
5163 clientId : client_id ,
5264 redirectUri : redirect_uri ,
5365 scope,
66+ responseType : response_type ,
5467 codeChallengeMethod : code_challenge_method ,
5568 } , 'OAuth2 authorization request received' ) ;
5669
Original file line number Diff line number Diff line change @@ -40,17 +40,6 @@ export default async function teamsRoute(fastify: FastifyInstance) {
4040 requireOAuthScope ( 'teams:read' )
4141 ]
4242 } , async ( request : FastifyRequest , reply : FastifyReply ) => {
43- const authType = request . tokenPayload ? 'oauth2' : 'cookie' ;
44- const userId = request . user ! . id ;
45-
46- request . log . debug ( {
47- operation : 'get_user_default_team' ,
48- userId,
49- authType,
50- clientId : request . tokenPayload ?. clientId ,
51- scope : request . tokenPayload ?. scope ,
52- endpoint : request . url
53- } , 'Authentication method determined for default team retrieval' ) ;
5443 try {
5544 if ( ! request . user ) {
5645 return reply . status ( 401 ) . send ( {
@@ -59,6 +48,18 @@ export default async function teamsRoute(fastify: FastifyInstance) {
5948 } ) ;
6049 }
6150
51+ const authType = request . tokenPayload ? 'oauth2' : 'cookie' ;
52+ const userId = request . user . id ;
53+
54+ request . log . debug ( {
55+ operation : 'get_user_default_team' ,
56+ userId,
57+ authType,
58+ clientId : request . tokenPayload ?. clientId ,
59+ scope : request . tokenPayload ?. scope ,
60+ endpoint : request . url
61+ } , 'Authentication method determined for default team retrieval' ) ;
62+
6263 const defaultTeam = await TeamService . getUserDefaultTeam ( request . user . id ) ;
6364
6465 if ( ! defaultTeam ) {
Original file line number Diff line number Diff line change @@ -100,6 +100,12 @@ describe('Teams Route', () => {
100100 user : {
101101 id : 'user-123' ,
102102 } as any , // Use any to avoid complex Lucia User type issues in tests
103+ log : {
104+ debug : vi . fn ( ) ,
105+ info : vi . fn ( ) ,
106+ warn : vi . fn ( ) ,
107+ error : vi . fn ( ) ,
108+ } ,
103109 } as any ;
104110
105111 mockReply = {
You can’t perform that action at this time.
0 commit comments