Skip to content

Commit

Permalink
Rename to label
Browse files Browse the repository at this point in the history
  • Loading branch information
moalshak committed Dec 15, 2024
1 parent ba352f0 commit dab624a
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 31 deletions.
10 changes: 5 additions & 5 deletions warpgate-admin/src/api/public_key_credentials.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@ use super::AnySecurityScheme;
#[derive(Object)]
struct ExistingPublicKeyCredential {
id: Uuid,
openssh_public_key_title: String,
label: String,
openssh_public_key: String,
}

#[derive(Object)]
struct NewPublicKeyCredential {
openssh_public_key_title: String,
label: String,
openssh_public_key: String,
}

impl From<PublicKeyCredential::Model> for ExistingPublicKeyCredential {
fn from(credential: PublicKeyCredential::Model) -> Self {
Self {
id: credential.id,
openssh_public_key_title: credential.openssh_public_key_title,
label: credential.label,
openssh_public_key: credential.openssh_public_key,
}
}
Expand Down Expand Up @@ -115,7 +115,7 @@ impl ListApi {
let object = PublicKeyCredential::ActiveModel {
id: Set(Uuid::new_v4()),
user_id: Set(*user_id),
openssh_public_key_title: Set(body.openssh_public_key_title.clone()),
label: Set(body.label.clone()),
..PublicKeyCredential::ActiveModel::from(UserPublicKeyCredential::try_from(&*body)?)
}
.insert(&*db)
Expand Down Expand Up @@ -158,7 +158,7 @@ impl DetailApi {
let model = PublicKeyCredential::ActiveModel {
id: Set(id.0),
user_id: Set(*user_id),
openssh_public_key_title: Set(body.openssh_public_key_title.clone()),
label: Set(body.label.clone()),
..<_>::from(UserPublicKeyCredential::try_from(&*body)?)
}
.update(&*db)
Expand Down
2 changes: 1 addition & 1 deletion warpgate-db-entities/src/PublicKeyCredential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub user_id: Uuid,
pub openssh_public_key_title: String,
pub label: String,
pub openssh_public_key: String,
}

Expand Down
4 changes: 2 additions & 2 deletions warpgate-db-migrations/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ mod m00008_users;
mod m00009_credential_models;
mod m00010_parameters;
mod m00011_rsa_key_algos;
mod m00012_add_openssh_public_key_title;
mod m00012_add_openssh_public_key_label;

pub struct Migrator;

Expand All @@ -32,7 +32,7 @@ impl MigratorTrait for Migrator {
Box::new(m00009_credential_models::Migration),
Box::new(m00010_parameters::Migration),
Box::new(m00011_rsa_key_algos::Migration),
Box::new(m00012_add_openssh_public_key_title::Migration),
Box::new(m00012_add_openssh_public_key_label::Migration),
]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pub struct Migration;

impl MigrationName for Migration {
fn name(&self) -> &str {
"m00012_add_openssh_public_key_title"
"m00012_add_openssh_public_key_label"
}
}

Expand All @@ -18,7 +18,7 @@ impl MigrationTrait for Migration {
Table::alter()
.table(public_key_credential::Entity)
.add_column(
ColumnDef::new(Alias::new("openssh_public_key_title"))
ColumnDef::new(Alias::new("label"))
.string()
.not_null()
).to_owned()
Expand All @@ -31,7 +31,7 @@ impl MigrationTrait for Migration {
.alter_table(
Table::alter()
.table(public_key_credential::Entity)
.drop_column(Alias::new("openssh_public_key_title"))
.drop_column(Alias::new("label"))
.to_owned(),
)
.await
Expand Down
4 changes: 2 additions & 2 deletions warpgate-protocol-http/src/api/credentials.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ enum CredentialsStateResponse {

#[derive(Object)]
struct NewPublicKeyCredential {
openssh_public_key_title: String,
label: String,
openssh_public_key: String,
}

Expand Down Expand Up @@ -289,7 +289,7 @@ impl Api {
let object = PublicKeyCredential::ActiveModel {
id: Set(Uuid::new_v4()),
user_id: Set(user_model.id),
openssh_public_key_title: Set(body.openssh_public_key_title.clone()),
label: Set(body.label.clone()),
openssh_public_key: Set(body.openssh_public_key.clone()),
}
.insert(&*db)
Expand Down
8 changes: 4 additions & 4 deletions warpgate-web/src/admin/CredentialEditor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@
editingSsoCredentialInstance = null
}
async function savePublicKeyCredential (opensshPublicKeyTitle: string, opensshPublicKey: string) {
async function savePublicKeyCredential (label: string, opensshPublicKey: string) {
if (editingPublicKeyCredentialInstance) {
editingPublicKeyCredentialInstance.opensshPublicKeyTitle = opensshPublicKeyTitle
editingPublicKeyCredentialInstance.label = label
editingPublicKeyCredentialInstance.opensshPublicKey = opensshPublicKey
await api.updatePublicKeyCredential({
userId,
Expand All @@ -197,7 +197,7 @@
const credential = await api.createPublicKeyCredential({
userId,
newPublicKeyCredential: {
opensshPublicKeyTitle,
label,
opensshPublicKey,
},
})
Expand Down Expand Up @@ -252,7 +252,7 @@
{/if}
{#if credential.kind === 'PublicKey'}
<Fa fw icon={faKey} />
<span class="type">{credential.opensshPublicKeyTitle}</span>
<span class="type">{credential.label}</span>
<span class="text-muted ms-2">{abbreviatePublicKey(credential.opensshPublicKey)}</span>
{/if}
{#if credential.kind === 'Totp'}
Expand Down
16 changes: 8 additions & 8 deletions warpgate-web/src/admin/PublicKeyCredentialModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
interface Props {
isOpen: boolean
instance?: ExistingPublicKeyCredential
save: (opensshPublicKeyTitle: string, opensshPublicKey: string) => void
save: (label: string, opensshPublicKey: string) => void
}
let {
Expand All @@ -25,20 +25,20 @@
}: Props = $props()
let field: HTMLInputElement|undefined = $state()
let opensshPublicKeyTitle: string = $state('')
let label: string = $state('')
let opensshPublicKey: string = $state('')
let validated = $state(false)
function _save () {
if (!opensshPublicKey || !opensshPublicKeyTitle) {
if (!opensshPublicKey || !label) {
return
}
if (opensshPublicKey.includes(' ')) {
const parts = opensshPublicKey.split(' ').filter(x => x)
opensshPublicKey = `${parts[0]} ${parts[1]}`
}
isOpen = false
save(opensshPublicKeyTitle, opensshPublicKey)
save(label, opensshPublicKey)
}
function _cancel () {
Expand All @@ -48,7 +48,7 @@

<Modal toggle={_cancel} isOpen={isOpen} on:open={() => {
if (instance) {
opensshPublicKeyTitle = instance.opensshPublicKeyTitle
label = instance.label
opensshPublicKey = instance.opensshPublicKey
}
field?.focus()
Expand All @@ -58,15 +58,15 @@
e.preventDefault()
}}>
<ModalHeader toggle={_cancel}>
Add new SSH Public Key
Add an SSH public key
</ModalHeader>
<ModalBody>
<FormGroup floating label="Title">
<FormGroup floating label="Label">
<Input
bind:inner={field}
type="text"
required
bind:value={opensshPublicKeyTitle} />
bind:value={label} />
</FormGroup>
<FormGroup floating label="Public key in OpenSSH format">
<Input
Expand Down
8 changes: 4 additions & 4 deletions warpgate-web/src/admin/lib/openapi-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2154,15 +2154,15 @@
"type": "object",
"required": [
"id",
"openssh_public_key_title",
"label",
"openssh_public_key"
],
"properties": {
"id": {
"type": "string",
"format": "uuid"
},
"openssh_public_key_title": {
"label": {
"type": "string"
},
"openssh_public_key": {
Expand Down Expand Up @@ -2276,11 +2276,11 @@
"NewPublicKeyCredential": {
"type": "object",
"required": [
"openssh_public_key_title",
"label",
"openssh_public_key"
],
"properties": {
"openssh_public_key_title": {
"label": {
"type": "string"
},
"openssh_public_key": {
Expand Down
4 changes: 2 additions & 2 deletions warpgate-web/src/gateway/lib/openapi-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -799,11 +799,11 @@
"NewPublicKeyCredential": {
"type": "object",
"required": [
"openssh_public_key_title",
"label",
"openssh_public_key"
],
"properties": {
"openssh_public_key_title": {
"label": {
"type": "string"
},
"openssh_public_key": {
Expand Down

0 comments on commit dab624a

Please sign in to comment.