Repository navigation
Proposal: auth helpers - #651
vlad-ivanov-name wants to merge 1 commit into
Conversation
|
@vlad-ivanov-name Thanks for the write-up! I think the general idea of authentication helpers in this way is pretty clever! This is already a little technical but I'm wondering if this is something we could implement in |
ruben-arts
left a comment
There was a problem hiding this comment.
Great proposal! Left one question, could you clarify that?
| A number of authentication helpers is shipped together with `pixi`. However, the interface between `pixi` and authentication helpers is documented, and it's expected that users may add a helper specific to their usecase. | ||
|
|
||
| Authentication helpers are loosely inspired by `GIT_ASKPASS`, and authentication helpers in Docker and Flyte. |
There was a problem hiding this comment.
Could you clarify this a little more, is your proposal to ship multiple binaries with together with pixi or are there commands that will be called. Or maybe pixi can install them when needed.
There was a problem hiding this comment.
Given that pixi is a package manager that can install packages, we could also ship them as conda dependencies of the project perhaps.
There was a problem hiding this comment.
@ruben-arts yes the intention was to ship multiple binaries. I think this is the simplest way.
@baszalmstra the issue here is that the binary should be available before all the other packages are installed. Is this something already supported?
There was a problem hiding this comment.
I could see a future where you might have to update the helpers without updating the version of pixi. Wouldn't that make it easier if we support them as conda packages. The logic for "pre installing" is not really in yet. But we have something in the works for installing python before the pypi solve so it shouldn't be that hard to add.
There was a problem hiding this comment.
We could also implement this by having hard coded implementations and "fallback" commands to execute instead of having to ship multiple binaries. Having multiple binaries complicates the distribution of releases.
There was a problem hiding this comment.
Im curious what that would look like! Do you mean something along the lines of pixi auth-helper x. If x is built-in it would use that but otherwise it tries to find the executable pixi-auth-helper-x?
Correct
There was a problem hiding this comment.
Regarding bundling and installation: what are the downsides of bundling and versioning everything together? The way I see it, having helpers as separate packages just creates noise. It's much easier mentally to understand that pixi vX.Y supports auth with provider "N", than to find out specific auth helper version and to check that.
Also, keep in mind that separate versioning means that there's an API version that we will need to consider -- API between helpers and pixi. In future it might create situation where pixi vX.Y is not compatible with auth helper vN.P. Dealing with semver requirements there would introduce additional complexity.
And if providers need to be updated, it's not a big deal -- a new version of pixi can be released, users don't care where exactly the change occurred, so from the point of UX an update is an update anyway.
There was a problem hiding this comment.
I have to think about this for a bit.
We could easily encode the API version in a package that the authentication helper would need to depend on. When installing an environment for the auth helper we would simply include the requirement 'pixi-auth-helper-api=1.0'.
There was a problem hiding this comment.
Just to clarify - my main goal is to get this in in any way, shape or form with least amount of work. You have authority on the project -- so if you say to change this to your proposed solution, I will -- just let me know :)
There was a problem hiding this comment.
To not get stuck on the distribution details before we have an working example. Lets continue with a separate binary that we might merge in or not when we decide what we do with this part.
I think the implementation is not an overnight thing so I guess you could start on the implementation of supporting any (not just private) pypi index to get started.
Yes I started looking into using AuthenticatedClient. I could see this being used for conda channels as well -- just need to come up with toml syntax |
|
I'm curious how we would test this feature in CI. In the |
I wonder how difficult it would be to build a small, simple pip registry server (if it can even be small and simple). I'd say for stuff like that I'd write an integration test that spawns a local server (implemented with e. g. axum -- really cool framework) and add snapshot tests with something like insta |
I think this would be cool, @tdejager you think this could be part of |
|
|
||
| Upon failure, authentication helpers exit with code other than `0`. Authentication helpers must print a human-readable error message to stderr. `pixi` will relay the message back to the user. | ||
|
|
||
| Authentication helpers are never launched in interactive mode. Authentication helpers never receive user input over `stdin`, and can't print any additional information upon success. |
There was a problem hiding this comment.
Why not? For an oauth2 flow one might need to open a url, login and paste a token into the terminal.
This works for example in the AWS CLI https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sourcing-external.html
There was a problem hiding this comment.
Good point. Initially I wanted to avoid situations where actual token is input by user, or username / password — that should be the job of the existing auth mechanisms. Also, non interactive is simple - user interface adds a lot of different complexity levels. But you’re right, there are indeed flows that would require user input. Perhaps a non interactive can be implemented first, and interactive auth can be next iteration? Because I feel like it will need some thoughtful API design
There was a problem hiding this comment.
As a follow-up: perhaps we can implement non-interactive first and then add interactive support afterwards, but with a catch: I think if we do support interactive auth at some point, pixi should keep control over it, meaning that the flow is expressed as a series of function calls returning predefined types. The variations of flows therefore would be restricted, and pixi would be able to set up the UX of these flows exactly consistent across different auth helpers. This also means no direct connection between e. g. stdin of pixi and stdout of auth helper would be established
There was a problem hiding this comment.
Implementating non-interactive first makes sense. I was just scared of the never in the sentence.
Regarding the interface to interactive auth helpers I would argue to postpone the discussion how it looks like to a later stage. Also worth looking at how other tools do it.
There was a problem hiding this comment.
Well "never" in this context means something like in RFCs -- "never in this revision of the design". It's just a note to implementors that if they'd like to implement something differently, the spec should be changed too. It's just a file in git repo after all :)
|
|
||
| Authentication helper is a program that receives an URL to the package registry as an input and outputs a JSON object containing the credentials. Authentication helpers can utilize different methods for obtaining credentials, but it's expected that they are specific to the package host implementation. | ||
|
|
||
| Authentication helper is a runnable binary available in `PATH`. The name of the binary must start with `pixi-auth-` and followed by its unique ID. |
There was a problem hiding this comment.
Why add this restriction now? What if another package or CLI tool already provides the needed functionality to return the username/password JSON? I would recommend to keep this more flexible, which means just allowing specifying a path to any binary / shell.
There was a problem hiding this comment.
I think it’s a good convention that indicates specific API compatibility. It’s unlikely to clash with anything, and if there’s an existing tool, it’s easy to write a wrapper for it. I would argue that no existing tool provides the interface because the interface doesn’t exist yet.
There was a problem hiding this comment.
It's a 5 minutes thing to implement something like aws sts assume-role ... | jq '...' which returns the desired {"username": "...", "password": "..."} JSON compared to creating wrapper packages and shipping them to pypi/conda-forge which takes even someone experienced at least a few hours.
My point is that almost any existing tool can be converted to the interface you are proposing with a few lines of code.
There was a problem hiding this comment.
Yes. Then you rename your wrapper to “pixi-auth-aws” and you can start using it :) there is no need to ship it as a package with proposed design - enabling users to add helpers as you describe is one of the main points.
No description provided.