fixed #1367 - replace swagger with Stoplight Elements and add a note about token header

This commit is contained in:
Eugene 2025-06-05 11:04:19 +02:00
parent aa13534dc5
commit 1df9b45e9b
No known key found for this signature in database
GPG key ID: 5896FCBBDD1CF4F4
9 changed files with 44 additions and 36 deletions

26
Cargo.lock generated
View file

@ -5317,7 +5317,7 @@ dependencies = [
[[package]]
name = "warpgate"
version = "0.14.0"
version = "0.14.1"
dependencies = [
"ansi_term",
"anyhow",
@ -5356,7 +5356,7 @@ dependencies = [
[[package]]
name = "warpgate-admin"
version = "0.14.0"
version = "0.14.1"
dependencies = [
"anyhow",
"async-trait",
@ -5385,7 +5385,7 @@ dependencies = [
[[package]]
name = "warpgate-common"
version = "0.14.0"
version = "0.14.1"
dependencies = [
"anyhow",
"argon2",
@ -5427,7 +5427,7 @@ dependencies = [
[[package]]
name = "warpgate-core"
version = "0.14.0"
version = "0.14.1"
dependencies = [
"anyhow",
"argon2",
@ -5469,7 +5469,7 @@ dependencies = [
[[package]]
name = "warpgate-database-protocols"
version = "0.14.0"
version = "0.14.1"
dependencies = [
"bitflags 2.9.1",
"bytes",
@ -5482,7 +5482,7 @@ dependencies = [
[[package]]
name = "warpgate-db-entities"
version = "0.14.0"
version = "0.14.1"
dependencies = [
"bytes",
"chrono",
@ -5497,7 +5497,7 @@ dependencies = [
[[package]]
name = "warpgate-db-migrations"
version = "0.14.0"
version = "0.14.1"
dependencies = [
"chrono",
"data-encoding",
@ -5513,7 +5513,7 @@ dependencies = [
[[package]]
name = "warpgate-protocol-http"
version = "0.14.0"
version = "0.14.1"
dependencies = [
"anyhow",
"async-trait",
@ -5547,7 +5547,7 @@ dependencies = [
[[package]]
name = "warpgate-protocol-mysql"
version = "0.14.0"
version = "0.14.1"
dependencies = [
"anyhow",
"async-trait",
@ -5575,7 +5575,7 @@ dependencies = [
[[package]]
name = "warpgate-protocol-postgres"
version = "0.14.0"
version = "0.14.1"
dependencies = [
"anyhow",
"async-trait",
@ -5597,7 +5597,7 @@ dependencies = [
[[package]]
name = "warpgate-protocol-ssh"
version = "0.14.0"
version = "0.14.1"
dependencies = [
"ansi_term",
"anyhow",
@ -5623,7 +5623,7 @@ dependencies = [
[[package]]
name = "warpgate-sso"
version = "0.14.0"
version = "0.14.1"
dependencies = [
"bytes",
"data-encoding",
@ -5641,7 +5641,7 @@ dependencies = [
[[package]]
name = "warpgate-web"
version = "0.14.0"
version = "0.14.1"
dependencies = [
"rust-embed",
"serde",

View file

@ -45,7 +45,7 @@ poem = { version = "3.1", features = [
"server",
], default-features = false }
poem-openapi = { version = "5.1", features = [
"swagger-ui",
"stoplight-elements",
"chrono",
"uuid",
"static-files",

View file

@ -9,7 +9,7 @@ pub fn admin_api_app(services: &Services) -> impl IntoEndpoint {
OpenApiService::new(crate::api::get(), "Warpgate admin API", warpgate_version())
.server("/@warpgate/admin/api");
let ui = api_service.swagger_ui();
let ui = api_service.stoplight_elements();
let spec = api_service.spec_endpoint();
let db = services.db.clone();
let config = services.config.clone();
@ -19,7 +19,7 @@ pub fn admin_api_app(services: &Services) -> impl IntoEndpoint {
Route::new()
.nest("", api_service)
.nest("/swagger", ui)
.nest("/playground", ui)
.nest("/openapi.json", spec)
.at(
"/recordings/:id/cast",

View file

@ -62,7 +62,7 @@ impl ProtocolServer for HTTPProtocolServer {
let api_service =
OpenApiService::new(crate::api::get(), "Warpgate user API", warpgate_version())
.server("/@warpgate/api");
let ui = api_service.swagger_ui();
let ui = api_service.stoplight_elements();
let spec = api_service.spec_endpoint();
let session_storage = make_session_storage();
@ -95,7 +95,7 @@ impl ProtocolServer for HTTPProtocolServer {
.nest(
"/@warpgate",
Route::new()
.nest("/api/swagger", ui)
.nest("/api/playground", ui)
.nest("/api", api_service.with(cache_bust()))
.nest("/api/openapi.json", spec)
.nest_no_strip(

View file

@ -55,7 +55,6 @@ let activeTips: string[] = $derived.by(() => {
return result
})
let isAny = $state(false)
const validCredentials = $derived.by(() => {
let vc = new Set<CredentialKind>()
vc = new Set(existingCredentials.map(x => x.kind as CredentialKind))
@ -63,9 +62,7 @@ const validCredentials = $derived.by(() => {
return vc
})
$effect(() => {
isAny = !value[protocolId]
})
let isAny = $derived(!value[protocolId])
function updateAny () {
if (isAny) {
@ -97,7 +94,7 @@ function toggle (type: CredentialKind) {
on:change={updateAny}
/>
{#if !isAny}
{#each [...validCredentials] as type}
{#each [...validCredentials] as type (type)}
{#if possibleCredentials.has(type)}
<Input
id={'policy-editor-' + protocolId + type}
@ -111,7 +108,7 @@ function toggle (type: CredentialKind) {
{/if}
</div>
{#each activeTips as tip}
{#each activeTips as tip (tip)}
<div class="text-muted d-flex align-items-center mt-2">
<Fa icon={faInfoCircle} class="me-2" />
<small>{tip}</small>

View file

@ -238,7 +238,7 @@
/>
{/if}
<div class="list-group list-group-flush mb-3">
{#each credentials as credential}
{#each credentials as credential (credential.id)}
<div class="list-group-item credential">
{#if credential.kind === CredentialKind.Password }
<Fa fw icon={faKeyboard} />
@ -269,9 +269,10 @@
{/if}
{#if credential.kind === CredentialKind.PublicKey || credential.kind === CredentialKind.Sso}
<!-- svelte-ignore a11y_invalid_attribute -->
<a
class="ms-2"
href={''}
href=""
onclick={e => {
if (credential.kind === CredentialKind.Sso) {
editingSsoCredentialInstance = credential
@ -286,9 +287,10 @@
Change
</a>
{/if}
<!-- svelte-ignore a11y_invalid_attribute -->
<a
class="ms-2"
href={''}
href=""
onclick={e => {
deleteCredential(credential)
e.preventDefault()
@ -301,7 +303,7 @@
<h4>Auth policy</h4>
<div class="list-group list-group-flush mb-3">
{#each policyProtocols as protocol}
{#each policyProtocols as protocol (protocol)}
<div class="list-group-item">
<div class="mb-1">
<strong>{protocol.name}</strong>

View file

@ -55,14 +55,15 @@ async function deleteHost (host: SSHKnownHost) {
<h2>No known hosts</h2>
{/if}
<div class="list-group list-group-flush">
{#each knownHosts as host}
{#each knownHosts as host (host.id)}
<div class="list-group-item">
<div class="d-flex">
<strong>
{host.host}:{host.port}
</strong>
<a class="ms-auto" href={''} onclick={e => {
<!-- svelte-ignore a11y_invalid_attribute -->
<a class="ms-auto" href="" onclick={e => {
e.preventDefault()
deleteHost(host)
}}>Delete</a>

View file

@ -57,8 +57,8 @@
<div class="d-flex">
<FormGroup floating label="Authenticate using" class="w-100">
<select bind:value={options.auth.kind} class="form-control">
<option value={'PublicKey'}>Warpgate's own private keys</option>
<option value={'Password'}>Password</option>
<option value="PublicKey">Warpgate's own private keys</option>
<option value="Password">Password</option>
</select>
</FormGroup>
{#if options.auth.kind === 'PublicKey'}

View file

@ -1,7 +1,8 @@
<script lang="ts">
import { faFileContract, faFlaskVial } from '@fortawesome/free-solid-svg-icons'
import { faFileContract, faFlaskVial, faInfoCircle } from '@fortawesome/free-solid-svg-icons'
import Fa from 'svelte-fa'
import ApiTokenManager from './ApiTokenManager.svelte'
import Alert from 'common/sveltestrap-s5-ports/Alert.svelte'
</script>
<!-- <div class="page-summary-bar">
@ -10,10 +11,10 @@
<ApiTokenManager />
<div class="row">
<div class="row mt-5">
<div class="col">
<h4>User API</h4>
<a class="link" target="_blank" href="/@warpgate/api/swagger">
<a class="link" target="_blank" href="/@warpgate/api/playground">
<Fa icon={faFlaskVial} fw />
<span>Playground</span>
</a>
@ -25,7 +26,7 @@
<div class="col">
<h4>Admin API</h4>
<a class="link" target="_blank" href="/@warpgate/admin/api/swagger">
<a class="link" target="_blank" href="/@warpgate/admin/api/playground">
<Fa icon={faFlaskVial} fw />
<span>Playground</span>
</a>
@ -36,6 +37,13 @@
</div>
</div>
<div class="text-muted d-flex align-items-center mt-5">
<Fa icon={faInfoCircle} class="me-2" />
<small>
Pass the token in the <code>X-Warpgate-Token</code> header
</small>
</div>
<style lang="scss">
.link {
display: flex;