See https://www.mongodb.com/docs/manual/reference/method/db.createRole/ specifically the role document key authenticationRestrictions which does what you want.

2 Likes