-
Notifications
You must be signed in to change notification settings - Fork 59
feat: Add is_primary_for_scope attribute to boundary_auth_method and boundary_auth_method_password resources
#753
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
is_primary_for_scope attribute to auth_method and auth_method_password resourcesis_primary_for_scope attribute to boundary_auth_method and boundary_auth_method_password resources
3e2f56b to
6f6924a
Compare
| if err := updateScopeWithPrimaryAuthMethodId(ctx, scopeId, authMethodId, meta); err != nil { | ||
| return diag.Errorf("%v", err) | ||
| } | ||
| } else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As @moduli pointed out there are a few differences in how this is being implemented here vs oidc and ldap is there a specific reason for this?
I would need to think through this specific else case here, but the initial thoughts I am thinking about are unsetting this here might break another update that is trying to set this for the scope.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@moduli @louisruch Many thanks for the review !
The differences in my implementation were intended to address two issues I encountered when reproducing the OIDC and LDAP auth method implementations:
- Ignored updates: When
is_primary_for_scopeis the only attribute changed, the update is silently ignored - Cannot unset primary: Once an auth method is set as primary, removing or setting
is_primary_for_scope = falsehas no effect, the auth method remains primary
My initial implementation solved both issues, but as @louisruch correctly identified, the else block introduces a race condition: if auth method A is being unset while auth method B is being set as primary simultaneously, one of them will fail with a scope version conflict error.
Proposed solution:
-
Remove the
elseblock to prevent the race condition. This reintroduces issue 2. (cannot unset primary), but this is the same behavior as OIDC/LDAP and is probably safer from a concurrency perspective. -
Keep the fix for issue 1. (ignored updates when only
is_primary_for_scopechanges) and apply it consistently to OIDC and LDAP auth methods as well.
The workaround for users who want to unset a primary auth method would be to either :
- Set another auth method as primary (which automatically unsets the previous one)
- Manually unset via the Boundary API/CLI
We could update the attribute description to document this limitation:
Description: "When true, makes this auth method the primary auth method for the scope. To unset, either set another auth method as primary or use the Boundary API/CLI directly."What are you thoughts on this approach ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would want to be consistent in how we approach this for all scenarios. If we want to allow unsettling - I would need to chat with the rest of the team how we want to approach this and we would need to update oidc/ldap.
Overall I am happy with this PR, my recommendation is that we remove the else block and then merge it. We can then, if we feel it is the correct approach, open a different PR to update the behavior of all oidc/ldap/password
This PR adds a new attribute,
is_primary_for_scope, for both theboundary_auth_methodandboundary_auth_method_passwordresources.Notes
I don't know what direction will be given to
boundary_auth_methodcompared toboundary_auth_method_password. To be safe, I’ve added the new attribute to both resources for consistency.Acceptance tests
Closes #754