Fix transparent SSO enforcement for deploy tokens
What does this MR do and why?
Describe in detail what your merge request does and why.
Fixes #378928 (closed)
Implements #group_sso?(group) method on the DeployToken PolicyActor and adds tests. The failure was noticed in Staging when :transparent_sso_enforcement was enabled.
NoMethodError: undefined method `group_sso?' for #<DeployToken:0x00007f574ae72c20>
Did you mean? groups
from activemodel (6.1.6.1) lib/active_model/attribute_methods.rb:469:in `method_missing'
from ee/lib/gitlab/auth/group_saml/sso_enforcer.rb:51:in `saml_enforced?'
from ee/lib/gitlab/auth/group_saml/sso_enforcer.rb:29:in `access_restricted?'
from ee/lib/gitlab/auth/group_saml/sso_enforcer.rb:41:in `group_access_restricted?'
from ee/app/policies/ee/group_policy.rb:540:in `sso_enforcement_prevents_access?'
from ee/app/policies/ee/group_policy.rb:88:in `block (2 levels) in <module:GroupPolicy>'
We seem to have an existing paradigm where we add methods to PolicyActor which is included in DeployToken so that
deploy tokens can behave like users (or at least respond to the same methods).
I did not add a Changelog since this only occurs when :transparent_sso_enforcement feature flag is enabled, and it's currently default disabled.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.