Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions nexus/src/external_api/console_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,17 @@ pub async fn console_settings_page(
console_index_or_login_redirect(rqctx).await
}

#[endpoint {
method = GET,
path = "/",
unpublished = true,
}]
pub async fn console_root(
rqctx: Arc<RequestContext<Arc<ServerContext>>>,
) -> Result<Response<Body>, HttpError> {
console_index_or_login_redirect(rqctx).await
}

/// Make a new PathBuf with `.gz` on the end
fn with_gz_ext(path: &PathBuf) -> PathBuf {
let mut new_path = path.clone();
Expand Down
5 changes: 2 additions & 3 deletions nexus/src/external_api/device_auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::context::OpContext;
use crate::db::model::DeviceAccessToken;
use crate::ServerContext;
use dropshot::{
endpoint, HttpError, HttpResponseOk, Query, RequestContext, TypedBody,
endpoint, HttpError, HttpResponseOk, RequestContext, TypedBody,
};
use http::{header, Response, StatusCode};
use hyper::Body;
Expand Down Expand Up @@ -121,11 +121,10 @@ pub struct DeviceAuthVerify {
#[endpoint {
method = GET,
path = "/device/verify",
tags = ["hidden"], // "token"
unpublished = true,
}]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

(see line above) kind of think this should be unpublished = true instead of tags = ["hidden"], what do you think @plotnick?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, @ahl suggested that, too. It's fine with me, since we don't use most of these endpoints from our client code at all. But we do use /device/confirm from console code, so we should choose a tag or use hidden for that one.

pub async fn device_auth_verify(
rqctx: Arc<RequestContext<Arc<ServerContext>>>,
_params: Query<DeviceAuthVerify>,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We're not doing anything with these on the server, and we're going to change it to manual entry anyway: oxidecomputer/console#999

) -> Result<Response<Body>, HttpError> {
console_index_or_login_redirect(rqctx).await
}
Expand Down
2 changes: 2 additions & 0 deletions nexus/src/external_api/http_entrypoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ pub fn external_api() -> NexusApiDescription {
api.register(console_api::session_me)?;
api.register(console_api::logout)?;
api.register(console_api::console_page)?;
api.register(console_api::console_root)?;
api.register(console_api::console_settings_page)?;
api.register(console_api::asset)?;

api.register(console_api::login)?;
Expand Down
19 changes: 14 additions & 5 deletions nexus/tests/integration_tests/console_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,18 @@ async fn test_console_pages(cptestctx: &ControlPlaneTestContext) {

let session_token = log_in_and_extract_token(&testctx).await;

// hit console page with session, should get back HTML response
let console_page =
RequestBuilder::new(&testctx, Method::GET, "/orgs/irrelevant-path")
.header(http::header::COOKIE, session_token)
// hit console pages with session, should get back HTML response
let console_paths = &[
"/",
"/orgs/irrelevant-path",
"/settings/irrelevant-path",
"/device/success",
"/device/verify",
];

for path in console_paths {
let console_page = RequestBuilder::new(&testctx, Method::GET, path)
.header(http::header::COOKIE, session_token.clone())
.expect_status(Some(StatusCode::OK))
.expect_response_header(
http::header::CONTENT_TYPE,
Expand All @@ -171,7 +179,8 @@ async fn test_console_pages(cptestctx: &ControlPlaneTestContext) {
.await
.expect("failed to get console index");

assert_eq!(console_page.body, "<html></html>".as_bytes());
assert_eq!(console_page.body, "<html></html>".as_bytes());
}
}

#[nexus_test]
Expand Down
1 change: 0 additions & 1 deletion nexus/tests/output/nexus_tags.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ OPERATION ID URL PATH
device_access_token /device/token
device_auth_confirm /device/confirm
device_auth_request /device/auth
device_auth_verify /device/verify
logout /logout
session_me /session/me
spoof_login /login
Expand Down
1 change: 0 additions & 1 deletion nexus/tests/output/uncovered-authz-endpoints.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
API endpoints with no coverage in authz tests:
session_sshkey_delete (delete "/session/me/sshkeys/{ssh_key_name}")
device_auth_verify (get "/device/verify")
login (get "/login/{silo_name}/{provider_name}")
session_me (get "/session/me")
session_sshkey_list (get "/session/me/sshkeys")
Expand Down
31 changes: 0 additions & 31 deletions openapi/nexus.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,37 +112,6 @@
}
}
},
"/device/verify": {
"get": {
"tags": [
"hidden"
],
"summary": "Verify an OAuth 2.0 Device Authorization Grant",
"description": "This endpoint should be accessed in a full user agent (e.g., a browser). If the user is not logged in, we redirect them to the login page and use the `state` parameter to get them back here on completion. If they are logged in, serve up the console verification page so they can verify the user code.",
"operationId": "device_auth_verify",
"parameters": [
{
"in": "query",
"name": "user_code",
"required": true,
"schema": {
"type": "string"
},
"style": "form"
}
],
"responses": {
"default": {
"description": "",
"content": {
"*/*": {
"schema": {}
}
}
}
}
}
},
"/hardware/racks": {
"get": {
"tags": [
Expand Down