Skip to content

feat: Allow multiple extenal URLs for SSO access#14208

Closed
tjamet wants to merge 10 commits intoargoproj:masterfrom
tjamet:multiple-url
Closed

feat: Allow multiple extenal URLs for SSO access#14208
tjamet wants to merge 10 commits intoargoproj:masterfrom
tjamet:multiple-url

Conversation

@tjamet
Copy link
Contributor

@tjamet tjamet commented Jun 26, 2023

With #4780, were introduced security measures to ensure the return_url is pointing to the current ArgoCD instance.

In several occasions, an ArgoCD isntance could be exposed through multiple network connections. Internal addresses and restricted public addresses.

Currently, a single base URL can be configured in the the argocd configmap, preventing from exposing ArgoCD on several access paths.

This change allows to define multiple hosts on which ArgoCD can be exposed, keeping backward compatibility by adding a field additionalUrls accepting a list of additional URLS on which argoCD can be exposed

Fixes #5388

Note on DCO:

If the DCO action in the integration test fails, one or more of your commits are not signed off. Please click on the Details link next to the DCO action for instructions on how to resolve this.

Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this does not need to be in the release notes.
  • The title of the PR states what changed and the related issues number (used for the release note).
  • The title of the PR conforms to the Toolchain Guide
  • I've included "Closes [ISSUE #]" or "Fixes [ISSUE #]" in the description to automatically close the associated issue.
  • I've updated both the CLI and UI to expose my feature, or I plan to submit a second PR with them.
  • Does this PR require documentation updates?
  • I've updated documentation as required by this PR.
  • Optional. My organization is added to USERS.md.
  • I have signed off all my commits as required by DCO
  • I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
  • My build is green (troubleshooting builds).
  • My new feature complies with the feature status guidelines.
  • I have added a brief description of why this PR is necessary and/or what this PR solves.

Please see Contribution FAQs if you have questions about your pull-request.

@codecov
Copy link

codecov bot commented Jun 26, 2023

Codecov Report

Attention: Patch coverage is 32.55814% with 29 lines in your changes missing coverage. Please review.

Project coverage is 49.88%. Comparing base (696e6e8) to head (18b08d5).
Report is 1506 commits behind head on master.

Files with missing lines Patch % Lines
util/settings/settings.go 7.14% 24 Missing and 2 partials ⚠️
server/logout/logout.go 25.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #14208      +/-   ##
==========================================
- Coverage   49.89%   49.88%   -0.01%     
==========================================
  Files         263      263              
  Lines       45219    45254      +35     
==========================================
+ Hits        22563    22577      +14     
- Misses      20439    20460      +21     
  Partials     2217     2217              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tjamet tjamet changed the title Allow multiple extenal URLs for SSO access feat: Allow multiple extenal URLs for SSO access Jun 26, 2023
@tjamet
Copy link
Contributor Author

tjamet commented Jun 27, 2023

Alternatively, we can make the configuration field be URLs instead of additionalURLs and deprecate URL.
Happy to go both paths as you tell me

@csantanapr
Copy link
Member

This is very useful PR @tjamet 👍

@huynhsontung
Copy link

+1 for using urls and deprecating url

@trc-ikeskin
Copy link

Any progress on this PR. We could really use this feature.
@tjamet can I somehow support with this PR?

@tjamet
Copy link
Contributor Author

tjamet commented Aug 31, 2023

Hi!
I have tested this feature internally and it worked for us, I added a few fixes for log-out recently though.
It's great to see interest in this feature.
Maybe, I can push the images on my own docker hub account for you to give feedback on the feature?
Would you be interested in this?

I will post a reminder in the CNCF slack in a few days.
Here is a thread where I referenced this PR, maybe we can also use it?

With argoproj#4780, were introduced security measures to ensure the `return_url`
is pointing to the current ArgoCD instance.

In several occasions, an ArgoCD isntance could be exposed through
multiple network connections. Internal addresses and restricted public
addresses.

Currently, a single base URL can be configured in the the argocd
configmap, preventing from exposing ArgoCD on several access paths.

This change allows to define multiple hosts on which ArgoCD can be
exposed, keeping backward compatibility by adding a field
`additionalUrls` accepting a list of additional URLS on which argoCD can
be exposed

Fixes argoproj#5388

Signed-off-by: Thibault Jamet <tjamet@users.noreply.github.com>
Signed-off-by: Thibault Jamet <tjamet@users.noreply.github.com>
codeql restricts logging fields from user input. Remove log to avoid complex escapes

Signed-off-by: Thibault Jamet <tjamet@users.noreply.github.com>
Currently, the documented configmap is invalid and raises error at the
time of applying it.

Ensure the configmap is valid with a unit test

Signed-off-by: Thibault Jamet <tjamet@users.noreply.github.com>
Signed-off-by: Thibault Jamet <tjamet@users.noreply.github.com>
Signed-off-by: Thibault Jamet <tjamet@users.noreply.github.com>
Signed-off-by: Thibault Jamet <tjamet@users.noreply.github.com>
Signed-off-by: Thibault Jamet <tjamet@users.noreply.github.com>
With HTTP servers, the `url` field of `http.Requests` does not contain
the host nor the protocol.

To work around this, consider `request.Host` and
`request.URL.RequestURI()`

Signed-off-by: Thibault Jamet <tjamet@users.noreply.github.com>
Currently, while login is correctly handled, when logging out from
an alternate URL, we are redirected to the main URL.

Fix this by applying the same principles as for the login part

Signed-off-by: Thibault Jamet <tjamet@users.noreply.github.com>
@tjamet
Copy link
Contributor Author

tjamet commented Sep 8, 2023

@trc-ikeskin I have pushed a build of this branch on my github container registry, if you want to take a look and provide feedback:
https://github.com/tjamet/argo-cd/pkgs/container/argo-cd%2Fargocd/126159769?tag=2.9.0-1eb72892

It is built from tjamet/master that has an additional commit to allow this build

@BulatSaif
Copy link

Can we merge this, please?

@trc-ikeskin
Copy link

@BulatSaif I guess if you want to see progress on this one you will have to do some actual testing on the feature. Unfortunately we had to move on to other customers.

@avosepp
Copy link
Contributor

avosepp commented May 3, 2024

How can I help test this functionality to help get it merged?

@tabathad
Copy link

Also eager to see this PR merged and ready to help with any additional testing or changes needed. Please let us know how we can help!

Copy link
Member

@agaudreault agaudreault left a comment

Choose a reason for hiding this comment

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

I think the feature should be documented in the ArgoCD https://argo-cd.readthedocs.io/en/stable/operator-manual/user-management/ documentation.

Is url deprecated? are urls valid on their own or only additional urls? Is this feature supported by all identity providers, or only by OIDC?

}

func (a *ClientApp) oauth2Config(scopes []string) (*oauth2.Config, error) {
func (a *ClientApp) oauth2Config(r *http.Request, scopes []string) (*oauth2.Config, error) {
Copy link
Member

Choose a reason for hiding this comment

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

If only the url is necessary to find the config, pass only the URL instead of the whole request object.

Suggested change
func (a *ClientApp) oauth2Config(r *http.Request, scopes []string) (*oauth2.Config, error) {
func (a *ClientApp) oauth2Config(request *url.URL, scopes []string) (*oauth2.Config, error) {

}
if argoCDCM.Data[settingURLsKey] != "" {
if err := yaml.Unmarshal([]byte(argoCDCM.Data[settingURLsKey]), &settings.URLs); err != nil {
log.Warnf("Failed decode all UI banner URLs in configmap: %v", err)
Copy link
Member

Choose a reason for hiding this comment

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

The error message does not seem accurate


func (a *ArgoCDSettings) IsDexConfigured() bool {
if a.URL == "" {
if a.URL == "" && len(a.URLs) == 0 {
Copy link
Member

Choose a reason for hiding this comment

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

Is Dex using this new URLs setting? It seems unclear if Dex should be valid if there are only URLs configured.

@KojoRising
Copy link
Contributor

+1, this would be super useful. Happy to help add some testing/documentation if needed.

@vinelias
Copy link

Any news on that?

@agaudreault
Copy link
Member

As @tjamet does not seem active, @vinelias, @KojoRising, @avo-sepp, @tabathad you can fork @tjamet's work and submit a new PR with the require code changes, tests and answers for the questions above.

@ClifHouck
Copy link
Contributor

@tjamet @vinelias @KojoRising @avo-sepp @tabathad: I'm going to marshal this across the finish line, if I can. New PR here: #18927

@agaudreault agaudreault added the lifecycle/rotten Issue/PR had no activity for a long time and should be closed soon label Jul 4, 2024
@agaudreault
Copy link
Member

Closing in favor of #18927

@tjamet
Copy link
Contributor Author

tjamet commented Jul 5, 2024

Sorry, I missed the latest updates and comments on this PR
Let me know if I can further help. I remain super interested in getting this change through

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lifecycle/rotten Issue/PR had no activity for a long time and should be closed soon

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multiple external URLs for SSO access