File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change 33
33
Optional ,
34
34
cast ,
35
35
)
36
- from urllib .parse import quote
36
+ from urllib .parse import quote , unquote
37
37
38
38
from bson .binary import Binary
39
39
from pymongo .auth_aws import _authenticate_aws
@@ -173,6 +173,8 @@ def _build_credentials_tuple(
173
173
human_callback = properties .get ("OIDC_HUMAN_CALLBACK" )
174
174
environ = properties .get ("ENVIRONMENT" )
175
175
token_resource = properties .get ("TOKEN_RESOURCE" , "" )
176
+ if unquote (token_resource ) == token_resource :
177
+ token_resource = quote (token_resource )
176
178
default_allowed = [
177
179
"*.mongodb.net" ,
178
180
"*.mongodb-dev.net" ,
Original file line number Diff line number Diff line change 539
539
}
540
540
}
541
541
},
542
+ {
543
+ "description" : " should accept a url-encoded TOKEN_RESOURCE (MONGODB-OIDC)" ,
544
+ "uri" : " mongodb://user@localhost/?authMechanism=MONGODB-OIDC&authMechanismProperties=ENVIRONMENT:azure,TOKEN_RESOURCE:mongodb%253A//test-cluster" ,
545
+ "valid" : true ,
546
+ "credential" : {
547
+ "username" : " user" ,
548
+ "password" : null ,
549
+ "source" : " $external" ,
550
+ "mechanism" : " MONGODB-OIDC" ,
551
+ "mechanism_properties" : {
552
+ "ENVIRONMENT" : " azure" ,
553
+ "TOKEN_RESOURCE" : " mongodb%253A//test-cluster"
554
+ }
555
+ }
556
+ },
557
+ {
558
+ "description" : " should url-encode a TOKEN_RESOURCE (MONGODB-OIDC)" ,
559
+ "uri" : " mongodb://user@localhost/?authMechanism=MONGODB-OIDC&authMechanismProperties=ENVIRONMENT:azure,TOKEN_RESOURCE:a$b" ,
560
+ "valid" : true ,
561
+ "credential" : {
562
+ "username" : " user" ,
563
+ "password" : null ,
564
+ "source" : " $external" ,
565
+ "mechanism" : " MONGODB-OIDC" ,
566
+ "mechanism_properties" : {
567
+ "ENVIRONMENT" : " azure" ,
568
+ "TOKEN_RESOURCE" : " a%24b"
569
+ }
570
+ }
571
+ },
542
572
{
543
573
"description" : " should accept a username and throw an error for a password with azure provider (MONGODB-OIDC)" ,
544
574
"uri" : " mongodb://user:pass@localhost/?authMechanism=MONGODB-OIDC&authMechanismProperties=ENVIRONMENT:azure,TOKEN_RESOURCE:foo" ,
You can’t perform that action at this time.
0 commit comments