Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added x509/JWT svid field to frontend Create entry page #236 #294

Merged
merged 2 commits into from
Aug 3, 2023
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
2 changes: 1 addition & 1 deletion docs/quickstart/tornjak-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ data:

# configure HTTP connection to Tornjak server
http {
port = 10080 # opens at port 10080
port = 10000 # opens at port 10080
}

}
Expand Down
64 changes: 47 additions & 17 deletions tornjak-frontend/src/components/entry-create-json.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ type CreateEntryJsonState = {
parentIdPath: string,
parentId: string,
selectorsList: string,
ttl: number,
jwt_svid_ttl: number,
x509_svid_ttl: number,
expiresAt: number,
federatesWith: string,
dnsNames: string,
Expand Down Expand Up @@ -80,7 +81,8 @@ class CreateEntryJson extends Component<CreateEntryJsonProp, CreateEntryJsonStat
this.handleChange = this.handleChange.bind(this);
this.setSelectedEntriesIds = this.setSelectedEntriesIds.bind(this);
this.onChangeSelectors = this.onChangeSelectors.bind(this);
this.onChangeTtl = this.onChangeTtl.bind(this);
this.onChangex509Ttl = this.onChangex509Ttl.bind(this);
this.onChangeJwtTtl = this.onChangeJwtTtl.bind(this);
this.onChangeExpiresAt = this.onChangeExpiresAt.bind(this);
this.onChangeFederatesWith = this.onChangeFederatesWith.bind(this);
this.onChangeDnsNames = this.onChangeDnsNames.bind(this);
Expand All @@ -102,7 +104,8 @@ class CreateEntryJson extends Component<CreateEntryJsonProp, CreateEntryJsonStat
spiffe_id: { trust_domain: "", path: "" },
parent_id: { trust_domain: "", path: "" },
selectors: [],
ttl: 0,
jwt_svid_ttl: 0,
x509_svid_ttl: 0,
federates_with: [],
admin: false,
downstream: false,
Expand All @@ -121,7 +124,8 @@ class CreateEntryJson extends Component<CreateEntryJsonProp, CreateEntryJsonStat
parentIdPath: "",
parentId: "",
selectorsList: "",
ttl: 0,
x509_svid_ttl: 0,
jwt_svid_ttl: 0,
expiresAt: 0,
federatesWith: "",
dnsNames: "",
Expand Down Expand Up @@ -258,7 +262,8 @@ class CreateEntryJson extends Component<CreateEntryJsonProp, CreateEntryJsonStat
parentIdTrustDomain: parentId_trustDomain,
parentIdPath: parentId_path,
selectorsList: selectorsWithNewline,
ttl: localNewEntry.ttl,
x509_svid_ttl: localNewEntry.x509_svid_ttl,
jwt_svid_ttl: localNewEntry.jwt_svid_ttl,
expiresAt: localNewEntry.expires_at,
federatesWith: federates_with,
dnsNames: dns_names,
Expand Down Expand Up @@ -333,13 +338,16 @@ class CreateEntryJson extends Component<CreateEntryJsonProp, CreateEntryJsonStat
entriesToUpload[selectedEntryId]["parent_id"]["trust_domain"] = this.state.parentIdTrustDomain;
entriesToUpload[selectedEntryId]["parent_id"]["path"] = this.state.parentIdPath;
entriesToUpload[selectedEntryId]["selectors"] = selectorEntries;
if (this.state.ttl !== undefined) {
entriesToUpload[selectedEntryId]["ttl"] = this.state.ttl;
if (this.state.jwt_svid_ttl !== undefined) {
entriesToUpload[selectedEntryId]["jwt_svid_ttl"] = this.state.jwt_svid_ttl;
}
if (this.state.ttl !== undefined) {
entriesToUpload[selectedEntryId]["expires_at"] = this.state.expiresAt;
if (this.state.x509_svid_ttl !== undefined) {
entriesToUpload[selectedEntryId]["x509_svid_ttl"] = this.state.x509_svid_ttl;
}
if (this.state.expiresAt !== undefined) {
entriesToUpload[selectedEntryId]["expires_at"] = this.state.expiresAt;
}
if (federatedWithList !== undefined) {
entriesToUpload[selectedEntryId]["federates_with"] = federatedWithList;
}
if (this.state.dnsNames.length !== 0) {
Expand All @@ -361,7 +369,8 @@ class CreateEntryJson extends Component<CreateEntryJsonProp, CreateEntryJsonStat
parentId: "",
spiffeId: "",
selectorsList: "",
ttl: 0,
x509_svid_ttl: 0,
jwt_svid_ttl: 0,
expiresAt: 0,
federatesWith: "",
dnsNames: "",
Expand Down Expand Up @@ -412,9 +421,16 @@ class CreateEntryJson extends Component<CreateEntryJsonProp, CreateEntryJsonStat
}

// TODO(mamy-CS): e - any for now will be explicitly typed
onChangeTtl(e: any): void {
onChangeJwtTtl(e: any): void {
this.setState({
ttl: Number(e.target.value)
jwt_svid_ttl: Number(e.target.value)
});
}

// TODO(mamy-CS): e - any for now will be explicitly typed
onChangex509Ttl(e: any): void {
this.setState({
x509_svid_ttl: Number(e.target.value)
});
}

Expand Down Expand Up @@ -463,7 +479,8 @@ class CreateEntryJson extends Component<CreateEntryJsonProp, CreateEntryJsonStat
parentId: "",
spiffeId: "",
selectorsList: "",
ttl: 0,
x509_svid_ttl: 0,
jwt_svid_ttl: 0,
expiresAt: 0,
federatesWith: "",
dnsNames: "",
Expand Down Expand Up @@ -792,15 +809,28 @@ class CreateEntryJson extends Component<CreateEntryJsonProp, CreateEntryJsonStat
<legend className="bx--label">Advanced</legend>
<div className="ttl-input" data-test="ttl-input">
<NumberInput
helperText="Ttl for identities issued for this entry (In seconds)"
helperText="x509 SVID Ttl for identities issued for this entry (In seconds) Overrides JWT TTL if set"
id="ttl-input"
invalidText="Number is not valid"
label="x509 Time to Leave (Ttl)"
//max={100}
min={0}
step={1}
value={this.state.x509_svid_ttl}
onChange={this.onChangex509Ttl}
/>
</div>
<div className="ttl-input" data-test="ttl-input">
<NumberInput
helperText="JWT SVID ttl for identities issued for this entry (In seconds) "
id="ttl-input"
invalidText="Number is not valid"
label="Time to Leave (Ttl)"
label="JWT Time to Leave (Ttl)"
//max={100}
min={0}
step={1}
value={this.state.ttl}
onChange={this.onChangeTtl}
value={this.state.jwt_svid_ttl}
onChange={this.onChangeJwtTtl}
/>
</div>
<div className="expiresAt-input" data-test="expiresAt-input">
Expand Down
61 changes: 42 additions & 19 deletions tornjak-frontend/src/components/entry-create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ type CreateEntryState = {
selectors: string,
selectorsRecommendationList: string,
adminFlag: boolean,
ttl: number,
jwt_svid_ttl: number,
x509_svid_ttl: number,
expiresAt: number,
dnsNames: string,
federatesWith: string,
Expand Down Expand Up @@ -139,7 +140,8 @@ class CreateEntry extends Component<CreateEntryProp, CreateEntryState> {
this.prepareParentIdAgentsList = this.prepareParentIdAgentsList.bind(this);
this.prepareSelectorsList = this.prepareSelectorsList.bind(this);
this.onChangeSelectorsRecommended = this.onChangeSelectorsRecommended.bind(this);
this.onChangeTtl = this.onChangeTtl.bind(this);
this.onChangeJwtTtl = this.onChangeJwtTtl.bind(this);
this.onChangex509Ttl = this.onChangex509Ttl.bind(this);
this.onChangeExpiresAt = this.onChangeExpiresAt.bind(this);
this.onChangeFederatesWith = this.onChangeFederatesWith.bind(this);
this.onChangeDownStream = this.onChangeDownStream.bind(this);
Expand All @@ -161,7 +163,8 @@ class CreateEntry extends Component<CreateEntryProp, CreateEntryState> {
selectors: "",
selectorsRecommendationList: "",
adminFlag: false,
ttl: 0,
x509_svid_ttl: 0,
jwt_svid_ttl: 0,
expiresAt: 0,
dnsNames: "",
federatesWith: "",
Expand Down Expand Up @@ -363,9 +366,15 @@ class CreateEntry extends Component<CreateEntryProp, CreateEntryState> {
}

// TODO(mamy-CS): e - any for now will be explicitly typed on currently open entry create PR
onChangeTtl(e: any): void {
onChangex509Ttl(e: any): void {
this.setState({
ttl: Number(e.target.value)
x509_svid_ttl: Number(e.target.value)
});
}

onChangeJwtTtl(e: any): void {
this.setState({
jwt_svid_ttl: Number(e.target.value)
});
}

Expand Down Expand Up @@ -640,7 +649,8 @@ class CreateEntry extends Component<CreateEntryProp, CreateEntryState> {
},
selectors: selectorEntries,
admin: this.state.adminFlag,
ttl: this.state.ttl,
x509_svid_ttl: this.state.x509_svid_ttl,
jwt_svid_ttl: this.state.jwt_svid_ttl,
expires_at: this.props.globalEntryExpiryTime,
downstream: this.state.downstream,
federates_with: federatedWithList,
Expand Down Expand Up @@ -864,19 +874,32 @@ class CreateEntry extends Component<CreateEntryProp, CreateEntryState> {
<div className="advanced">
<fieldset className="bx--fieldset">
<legend className="bx--label">Advanced</legend>
<div className="ttl-input" data-test="ttl-input">
<NumberInput
helperText="Ttl for identities issued for this entry (In seconds)"
id="ttl-input"
invalidText="Number is not valid"
label="Time to Leave (Ttl)"
//max={100}
min={0}
step={1}
value={0}
onChange={this.onChangeTtl}
/>
</div>
<div className="ttl-input" data-test="ttl-input">
<NumberInput
helperText="x509 SVID Ttl for identities issued for this entry (In seconds) Overrides JWT TTL if set"
id="ttl-input"
invalidText="Number is not valid"
label="x509 Time to Leave (Ttl)"
//max={100}
min={0}
step={1}
value={this.state.x509_svid_ttl}
onChange={this.onChangex509Ttl}
/>
</div>
<div className="ttl-input" data-test="ttl-input">
<NumberInput
helperText="JWT SVID ttl for identities issued for this entry (In seconds) "
id="ttl-input"
invalidText="Number is not valid"
label="JWT Time to Leave (Ttl)"
//max={100}
min={0}
step={1}
value={this.state.jwt_svid_ttl}
onChange={this.onChangeJwtTtl}
/>
</div>
<div className="expiresAt-input" data-test="expiresAt-input">
<EntryExpiryFeatures />
</div>
Expand Down
3 changes: 2 additions & 1 deletion tornjak-frontend/src/components/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ export interface EntriesList {
// node attestation. Otherwise, these selectors represent those produced by
// workload attestation.
selectors: Array<Selector>;
ttl: number; // The time to live for identities issued for this entry (in seconds).
jwt_svid_ttl: number; // time to live for JWT SVID in seconds
x509_svid_ttl: number; // time to live for x509-SVID in seconds
federates_with: string[]; // The names of trust domains the identity described by this entry federates with
// Whether or not the identity described by this entry is an administrative
// workload. Administrative workloads are granted additional access to
Expand Down