@@ -57,7 +57,7 @@ describe "OAuthTagger" do
5757 it " tags with exactly 3 matching parameters" do
5858 tagger = OAuthTagger .new(default_tagger_options)
5959
60- endpoint = Endpoint .new(" /oauth /token" , " POST" , [
60+ endpoint = Endpoint .new(" /api/integrations /token" , " POST" , [
6161 Param .new(" grant_type" , " client_credentials" , " form" ),
6262 Param .new(" client_id" , " my-app" , " form" ),
6363 Param .new(" client_secret" , " secret" , " form" ),
@@ -101,10 +101,9 @@ describe "OAuthTagger" do
101101 endpoint2.tags.size.should eq(0 )
102102 end
103103
104- it " is case-sensitive for parameter matching" do
104+ it " normalizes parameter names for matching" do
105105 tagger = OAuthTagger .new(default_tagger_options)
106106
107- # OAuth parameter names are case-sensitive
108107 endpoint = Endpoint .new(" /oauth/token" , " POST" , [
109108 Param .new(" GRANT_TYPE" , " authorization_code" , " form" ),
110109 Param .new(" CODE" , " abc123" , " form" ),
@@ -113,7 +112,65 @@ describe "OAuthTagger" do
113112
114113 tagger.perform([endpoint])
115114
116- # Should not match because case doesn't match
115+ endpoint.tags.size.should eq(1 )
116+ endpoint.tags[0 ].name.should eq(" oauth" )
117+ end
118+
119+ it " tags OAuth authorization endpoints with OIDC parameters" do
120+ tagger = OAuthTagger .new(default_tagger_options)
121+
122+ endpoint = Endpoint .new(" /oauth2/authorize" , " GET" , [
123+ Param .new(" response_type" , " code" , " query" ),
124+ Param .new(" client_id" , " my-app" , " query" ),
125+ Param .new(" redirect_uri" , " https://example.com/callback" , " query" ),
126+ Param .new(" scope" , " openid profile" , " query" ),
127+ Param .new(" state" , " abc123" , " query" ),
128+ ])
129+
130+ tagger.perform([endpoint])
131+
132+ endpoint.tags.size.should eq(1 )
133+ endpoint.tags[0 ].name.should eq(" oauth" )
134+ end
135+
136+ it " tags OAuth token endpoints using PKCE verifier without client secret" do
137+ tagger = OAuthTagger .new(default_tagger_options)
138+
139+ endpoint = Endpoint .new(" /oauth/token" , " POST" , [
140+ Param .new(" grant-type" , " authorization_code" , " form" ),
141+ Param .new(" code_verifier" , " pkce-secret" , " form" ),
142+ ])
143+
144+ tagger.perform([endpoint])
145+
146+ endpoint.tags.size.should eq(1 )
147+ endpoint.tags[0 ].name.should eq(" oauth" )
148+ end
149+
150+ it " does not tag generic token routes with weak OAuth parameters" do
151+ tagger = OAuthTagger .new(default_tagger_options)
152+
153+ endpoint = Endpoint .new(" /api/token" , " POST" , [
154+ Param .new(" code" , " 123456" , " form" ),
155+ Param .new(" state" , " ready" , " form" ),
156+ ])
157+
158+ tagger.perform([endpoint])
159+
160+ endpoint.tags.size.should eq(0 )
161+ end
162+
163+ it " does not tag non-OAuth endpoints with weak OAuth-like parameter names" do
164+ tagger = OAuthTagger .new(default_tagger_options)
165+
166+ endpoint = Endpoint .new(" /api/promotions" , " POST" , [
167+ Param .new(" code" , " SPRING" , " form" ),
168+ Param .new(" state" , " published" , " form" ),
169+ Param .new(" scope" , " regional" , " form" ),
170+ ])
171+
172+ tagger.perform([endpoint])
173+
117174 endpoint.tags.size.should eq(0 )
118175 end
119176 end
0 commit comments