-
Notifications
You must be signed in to change notification settings - Fork 294
[Workflows] Auth secret token mounting for Workflows #9151
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
Conversation
…ns from the ServerSideLauncher to mlrun/auth/utils so it can be accessed without launcher (such as KFP). Launcher function has been refactored to only handle run/remoteRuntime objects before passing the required info to the new core logic functions. Nuclio endpoint has been updated accordingly.
…cret and use it during create_pipeline CRUD to extract the secret name to mount. Secret name is passed into pipeline adapter where it is mounted to the argo pods
liranbg
left a comment
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.
well done, naming and some suggestions that improves readability
server/py/services/api/launcher.py
Outdated
|
|
||
| # TODO In ML-11600, implement token name resolution and validation + tests | ||
| def enrich_and_validate_auth_token_name( | ||
| def enrich_and_validate_auth_token_name_on_object( |
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.
| def enrich_and_validate_auth_token_name_on_object( | |
| def enrich_and_validate_auth_token_name( |
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 think this is pretty obvious from the parameters that you apply it on the given object
server/py/services/api/launcher.py
Outdated
| # Resolve token name and raise error only if token is explicitly provided by the user | ||
| # in ML-11600, we will implement a proper resolution logic that checks all secret tokens | ||
| # of the user and finds a valid one if no token name is provided | ||
| raise_error_on_failure = bool(provided_token_name) |
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.
| content_type: str, | ||
| env_var_names: list[str], | ||
| secrets_store: "SecretsStore", | ||
| secret_name: typing.Optional[str] = None, |
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.
| secret_name: typing.Optional[str] = None, | |
| auth_secret_name: typing.Optional[str] = None, |
and change callees + others to reflect this is not an arbitrary secret but auth one
…the raise_error_on_failure resolution inside enrich_and_validate_auth_token_name function
liranbg
left a comment
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.
really minor here
|
|
||
|
|
||
| def replace_kfp_plaintext_secret_env_vars_with_secret_refs( | ||
| def process_kfp_workflow_secret_references( |
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.
you need to bump patch version for pipeline adapter (under pyproject.toml).
mlrun/auth/utils.py
Outdated
| def enrich_and_validate_auth_token_name(token_name: typing.Optional[str]): | ||
| if mlrun.mlconf.is_iguazio_v4_mode(): | ||
| # Resolve token name and raise error only if token is explicitly provided by the user | ||
| raise_error_on_failure = bool(token_name) | ||
|
|
||
| # If token name not provided, use default | ||
| token_name = ( | ||
| token_name or mlrun.common.constants.MLRUN_RUNTIME_AUTH_DEFAULT_TOKEN_NAME | ||
| ) | ||
| validate_token_name(token_name, raise_error_on_failure=raise_error_on_failure) | ||
| return token_name | ||
|
|
||
|
|
||
| # TODO implement validation in ML-11600 | ||
| def validate_token_name( | ||
| token_name: str, | ||
| raise_error_on_failure: bool = True, | ||
| ): | ||
| pass |
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.
revisiting this agan, you dont do any enrichment nor validation here at this point (leaving some todos for validation) but honestly, I think it is better off KISSing it at this phase and remove this completely. moving the part of
token_name or mlrun.common.constants.MLRUN_RUNTIME_AUTH_DEFAULT_TOKEN_NAME
)
to its callees
…fix related tests
📝 Description
Add support for IG4 authentication on workflows by mounting the secret on the argo pods.
This PR moves the core logic of
enrich_and_validate_auth_token_nameout of the launcher to a more common place so it can be used by workflows since they don't go through launcher/runtime handler.🛠️ Changes Made
enrich_and_validate_auth_token_namecore logic from launcher tomlrun.auth.utilsresolve_auth_token_secret_namefor pipelines that gets token name and then extract secret name.replace_kfp_plaintext_secret_env_vars_with_secret_refstoprocess_kfp_workflow_secret_referencesto pass theauth_secret_nameparam so that it gets mounted to the argo pods during_enrich_kfp_workflow_yaml_credentials✅ Checklist
🧪 Testing
Unit tests
test_resolve_auth_secret_nametest_enrich_and_validate_auth_token_name🔗 References
🚨 Breaking Changes?
🔍️ Additional Notes