Skip to content

Serve unauthed console page at /login/{silo_name}/local#3217

Merged
david-crespo merged 9 commits into
mainfrom
pw-login-2
May 27, 2023
Merged

Serve unauthed console page at /login/{silo_name}/local#3217
david-crespo merged 9 commits into
mainfrom
pw-login-2

Conversation

@david-crespo

@david-crespo david-crespo commented May 24, 2023

Copy link
Copy Markdown
Contributor

A version of #3203 where I keep it simple instead.

  • Serve console at /login/{silo_name}/local without auth check
  • Do not get rid of spoof login yet. People are using it on dogfood and we don't have a great way to replace that
  • Add /v1 prefix to POST /login/{silo_name}/local and POST /logout
    • A few more endpoints are missing it but I'll get those later
  • Change POST /login/{silo_name}/local success response from a 303 redirect to a 204
    • This is definitely debatable, but because it's a JSON API endpoint, it's hard for me to see why anyone would be in a situation where they want to follow that redirect. The problem is that because it's made in the background, the browser doesn't navigate to the redirect URL, the background fetch just follows it and downloads the HTML. The TS client errors out because it doesn't know what to do with HTML.
    • Alternatives:
      • Use redirect: manual in fetch() call to prevent it following the redirect. This does seem to work, but based on the spec it really seems like you're not supposed to do this. The resulting response is called an opaque-filtered redirect response and is not supposed to be good for anything but following the same redirect later
      • Fix oxide.ts to not error out on HTML. That would be here. It's feasible but it would complicate things and it doesn't seem worthwhile.

.await
.expect("failed to get login form");
let unauthed_console_paths =
&["/spoof_login", "/login/irrelevant-silo/local"];

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The changes in this file are mostly cleanup. This line is the only substantive change: check the new path in addition to /spoof_login.

david-crespo added a commit to oxidecomputer/console that referenced this pull request May 25, 2023
// apictx.external_latencies.instrument_dropshot_handler(&rqctx, handler).await
serve_console_index(rqctx.context()).await
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure this endpoint will need to exist after we have silo in the domain. I was thinking a single GET /login endpoint could show either username/password login or a link to the IdP as appropriate depending on the silo. Because this is all done through the console, the generic console page be served as usual, and then the console would have to make an API call to determine which thing to show.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It'd be nice if we could avoid having to make an extra API call by including the silo in the header or something. Not for this PR, but in whatever solution we ultimately end up with.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it really would. I think we might soon get to the point where doing that is less ridiculous than the stuff we're doing to get around it. On the other hand, the total decoupling of the frontend from the API has been very beneficial to my sanity so far.

Comment on lines -393 to +424
path = "/login/{silo_name}/local",
path = "/v1/login/{silo_name}/local",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I intentionally left the /v1/ off the console endpoints which the thought being that they'd need to be relatively stable. I can see wanting to gate the POST endpoint though given that it'll mostly be treated like any other API endpoint.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I went back and forth. It is a JSON API endpoint, so I figured it should probably follow the convention. I'm thinking we should get to a point where only the GETs don't have v1 and they're all unpublished. It feels weird to have prefixed and non-prefixed endpoints right next to each other, but that's where I landed as least unreasonable.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Like above, will this endpoint not exist in a subdomain world?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure. We could have POST /v1/login just always be username/password, and that would make this endpoint unnecessary. Or maybe we could have POST /v1/login/local and we'd change POST /login/{silo_name}/saml/{provider_name} to POST /v1/login/saml/{provider_name}?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The latter part feels better than me. Given that username/password log ins should be relatively rare I don't know that I'd want it to be the root endpoint (which makes it feel like the default).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I think that's right.

@just-be-dev just-be-dev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice! Let's jam.

@david-crespo david-crespo enabled auto-merge (squash) May 25, 2023 17:28
@david-crespo david-crespo disabled auto-merge May 25, 2023 18:07
@david-crespo

Copy link
Copy Markdown
Contributor Author

😅

@david-crespo david-crespo merged commit 0ea0627 into main May 27, 2023
@david-crespo david-crespo deleted the pw-login-2 branch May 27, 2023 04:55
david-crespo added a commit to oxidecomputer/console that referenced this pull request May 27, 2023
* basic username/password login page

* extract shared code

* fix comment

* regen API with oxidecomputer/omicron#3217

* bump omicron version to an actual omicron main commit
@davepacheco davepacheco mentioned this pull request Jun 1, 2023
69 tasks
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.

2 participants