Skip to content
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

Allow Athens to Propagate Authentication to Mod Download #1650

Merged
merged 12 commits into from
Jul 30, 2020

Conversation

marwan-at-work
Copy link
Contributor

This PR allows Athens to create dynamic authentication for "go mod downloads" so that a server can serve multiple modules visible to only those who request it.

Fixes #1649

@marwan-at-work marwan-at-work requested a review from a team as a code owner July 20, 2020 14:00
Copy link
Collaborator

@twexler twexler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks pretty good. One thought, instead of a boolean, PropagateAuth should potentially be a slice of globs similar to GOPRIVATE to allow users to configure which domains to propagate authentication to, rather than propagating to all domains and leaking credentials to third parties

@marwan-at-work
Copy link
Contributor Author

@twexler this feature is most likely accompanied by a ValidationHook or an auth proxy, which can do that part of the work for us.

Do you think it's worth including here as well? Happy to do so ✌️

@twexler
Copy link
Collaborator

twexler commented Jul 20, 2020

@twexler this feature is most likely accompanied by a ValidationHook or an auth proxy, which can do that part of the work for us.

Right, but since you're using the .netrc file any go mod download call, this has the potential to leak credentials beyond the ValidationHook endpoint...no? In my opinion, users should be able to decide where these credentials are actually sent to rather than sending them everywhere

@marwan-at-work
Copy link
Contributor Author

Right, but since you're using the .netrc file any go mod download call, this has the potential to leak credentials beyond the ValidationHook endpoint...no?

So each call gets its own $HOME variable with a .netrc file. This means no two calls would ever share the same .netrc file. This ensures one call's credentials is never leaked to another call's go mod download. See this block for where it happens for the download part (same with the lister).

That said, your suggestion is definitely a nice insurance to make sure a user's auth header is never propagated to the wrong Hostname even if the Athens admin has this feature turned on.

@twexler I added the pattern matching to the latest commit. Let me know if it looks good to you, thanks! 🙌

Copy link
Collaborator

@twexler twexler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking great! A couple more comments.

config.dev.toml Outdated
# for more details.
#
# Env override: ATHENS_PROPAGATE_AUTH_PATTERNS
PropagateAuthPatterns = ["*"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if I like the default here, from a security perspective. Perhaps just ["localhost"]?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@twexler you're right. I removed this whole functionality in favor of static hosts. This should eliminate the possibility of accidentally leaking credentials to any host other host than the pre declared one.

pkg/auth/auth.go Show resolved Hide resolved
pkg/module/all_test.go Show resolved Hide resolved
Copy link
Collaborator

@twexler twexler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more thing, and then this looks good

config.dev.toml Outdated Show resolved Hide resolved
marwan-at-work and others added 3 commits July 27, 2020 12:29
@marwan-at-work marwan-at-work merged commit dfb7887 into main Jul 30, 2020
marwan-at-work added a commit that referenced this pull request Mar 11, 2021
arschles added a commit to arschles/athens that referenced this pull request Mar 11, 2021
gomods#1650 was a big change to the
authentication/authorization code, which we have decided to pull
out and potentially move into a separate process/project

Signed-off-by: Aaron Schlesinger <aaron@ecomaz.net>
arschles added a commit that referenced this pull request Mar 11, 2021
* Reverting PR 1650

#1650 was a big change to the
authentication/authorization code, which we have decided to pull
out and potentially move into a separate process/project

Signed-off-by: Aaron Schlesinger <aaron@ecomaz.net>

* removing commented, unused code

Signed-off-by: Aaron Schlesinger <aaron@ecomaz.net>

* removing more commented, unused code

Signed-off-by: Aaron Schlesinger <aaron@ecomaz.net>

* removing more unused code

Signed-off-by: Aaron Schlesinger <aaron@ecomaz.net>
@manugupt1 manugupt1 deleted the customauth branch December 10, 2021 05:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement Authentication Propagation
2 participants