MDL-38474 repository: Correct context when checking permissions to access a repository