Skip to content

Commit

Permalink
Format code before release
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieuancelin committed Feb 24, 2021
1 parent 6293533 commit 55e8be3
Show file tree
Hide file tree
Showing 9 changed files with 214 additions and 129 deletions.
13 changes: 11 additions & 2 deletions otoroshi/javascript/src/components/JwtVerifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,10 @@ export class AlgoSettings extends Component {
{ label: 'JWK Set (only for verification)', value: 'JWKSAlgoSettings' },
{ label: 'RSASSA-PKCS1 + SHA from KeyPair', value: 'RSAKPAlgoSettings' },
{ label: 'ECDSA + SHA from KeyPair', value: 'ESKPAlgoSettings' },
{ label: 'Otoroshi KeyPair from token kid (only for verification)', value: 'KidAlgoSettings' },
{
label: 'Otoroshi KeyPair from token kid (only for verification)',
value: 'KidAlgoSettings',
},
]}
help="What kind of algorithm you want to use to verify/sign your JWT token with"
/>
Expand Down Expand Up @@ -533,7 +536,13 @@ export class JwtVerifier extends Component {
/>
<br />
{/* **************************************************************************************************** */}
<Separator title={verifier.strategy.type === 'DefaultToken' ? 'Default token signature': "Token validation"} />
<Separator
title={
verifier.strategy.type === 'DefaultToken'
? 'Default token signature'
: 'Token validation'
}
/>
<AlgoSettings
path={`${path}.algoSettings`}
changeTheValue={this.changeTheValue}
Expand Down
2 changes: 1 addition & 1 deletion otoroshi/javascript/src/components/inputs/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export class Form extends Component {
<SelectInput
disabled={disabled}
key={name}
value={this.getValue(name, (props.defaultValue || ''))}
value={this.getValue(name, props.defaultValue || '')}
{...props}
onChange={(v) => this.changeValue(name, v)}
/>
Expand Down
91 changes: 45 additions & 46 deletions otoroshi/javascript/src/components/inputs/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,54 +303,53 @@ export class Table extends Component {
return <h3>Something went wrong !!!</h3>;
}
const windowWidth = window.innerWidth;
const columns = this.props.columns
.map((c) => {
return {
Header: c.title,
id: c.title,
headerStyle: c.style,
width: c.style && c.style.width ? c.style.width : undefined,
style: { ...c.style, height: 30 },
sortable: !c.notSortable,
filterable: !c.notFilterable,
accessor: (d) => (c.content ? c.content(d) : d),
Filter: (d) => (
<input
type="text"
className="form-control input-sm"
value={d.filter ? d.filter.value : ''}
onChange={(e) => d.onChange(e.target.value)}
placeholder="Search ..."
/>
),
Cell: (r) => {
const value = r.value;
const original = r.original;
return c.cell ? (
c.cell(value, original, this)
) : (
<div
onClick={(e) => {
if (this.props.rowNavigation) {
if (e.metaKey) {
if (this.props.itemUrl) {
const a = document.createElement('a');
a.setAttribute('target', '_blank');
a.setAttribute('href', this.props.itemUrl(original));
a.click();
}
} else {
this.gotoItem(e, original);
const columns = this.props.columns.map((c) => {
return {
Header: c.title,
id: c.title,
headerStyle: c.style,
width: c.style && c.style.width ? c.style.width : undefined,
style: { ...c.style, height: 30 },
sortable: !c.notSortable,
filterable: !c.notFilterable,
accessor: (d) => (c.content ? c.content(d) : d),
Filter: (d) => (
<input
type="text"
className="form-control input-sm"
value={d.filter ? d.filter.value : ''}
onChange={(e) => d.onChange(e.target.value)}
placeholder="Search ..."
/>
),
Cell: (r) => {
const value = r.value;
const original = r.original;
return c.cell ? (
c.cell(value, original, this)
) : (
<div
onClick={(e) => {
if (this.props.rowNavigation) {
if (e.metaKey) {
if (this.props.itemUrl) {
const a = document.createElement('a');
a.setAttribute('target', '_blank');
a.setAttribute('href', this.props.itemUrl(original));
a.click();
}
} else {
this.gotoItem(e, original);
}
}}
style={{ cursor: 'pointer', width: '100%' }}>
{c.wrappedCell ? c.wrappedCell(value, original, this) : value}
</div>
);
},
};
});
}
}}
style={{ cursor: 'pointer', width: '100%' }}>
{c.wrappedCell ? c.wrappedCell(value, original, this) : value}
</div>
);
},
};
});
if (this.props.showActions) {
columns.push({
Header: 'Actions',
Expand Down
139 changes: 98 additions & 41 deletions otoroshi/javascript/src/pages/CertificatesPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,57 @@ import moment from 'moment';
import faker from 'faker';

const RevocationReason = {
VALID: { value: 'VALID', label: 'Valid - The certificate is not revoked' },
UNSPECIFIED: { value: 'UNSPECIFIED', label: 'Unspecified - Can be used to revoke certificates for reasons other than the specific codes.' },
KEY_COMPROMISE: { value: 'KEY_COMPROMISE', label: 'KeyCompromise - It is known or suspected that the subject\'s private key or other aspects have been compromised.' },
CA_COMPROMISE: { value: 'CA_COMPROMISE', label: 'CACompromise - It is known or suspected that the subject\'s private key or other aspects have been compromised.' },
AFFILIATION_CHANGED : { value: 'AFFILIATION_CHANGED', label: 'AffiliationChanged - The subject\'s name or other information in the certificate has been modified but there is no cause to suspect that the private key has been compromised.' },
SUPERSEDED : { value: 'SUPERSEDED', label: 'Superseded - The certificate has been superseded but there is no cause to suspect that the private key has been compromised' },
CESSATION_OF_OPERATION : { value: 'CESSATION_OF_OPERATION', label: 'CessationOfOperation - The certificate is no longer needed for the purpose for which it was issued but there is no cause to suspect that the private key has been compromised' },
CERTIFICATE_HOLD : { value: 'CERTIFICATE_HOLD', label: 'CertificateHold - The certificate is temporarily revoked but there is no cause to suspect that the private kye has been compromised' },
REMOVE_FROM_CRL : { value: 'REMOVE_FROM_CRL', label: 'RemoveFromCRL - The certificate has been unrevoked' },
PRIVILEGE_WITH_DRAWN : { value: 'PRIVILEGE_WITH_DRAWN', label: 'PrivilegeWithdrawn - The certificate was revoked because a privilege contained within that certificate has been withdrawn' },
AA_COMPROMISE : { value: 'AA_COMPROMISE', label: 'AACompromise - It is known or suspected that aspects of the AA validated in the attribute certificate, have been compromised' }
}
VALID: { value: 'VALID', label: 'Valid - The certificate is not revoked' },
UNSPECIFIED: {
value: 'UNSPECIFIED',
label:
'Unspecified - Can be used to revoke certificates for reasons other than the specific codes.',
},
KEY_COMPROMISE: {
value: 'KEY_COMPROMISE',
label:
"KeyCompromise - It is known or suspected that the subject's private key or other aspects have been compromised.",
},
CA_COMPROMISE: {
value: 'CA_COMPROMISE',
label:
"CACompromise - It is known or suspected that the subject's private key or other aspects have been compromised.",
},
AFFILIATION_CHANGED: {
value: 'AFFILIATION_CHANGED',
label:
"AffiliationChanged - The subject's name or other information in the certificate has been modified but there is no cause to suspect that the private key has been compromised.",
},
SUPERSEDED: {
value: 'SUPERSEDED',
label:
'Superseded - The certificate has been superseded but there is no cause to suspect that the private key has been compromised',
},
CESSATION_OF_OPERATION: {
value: 'CESSATION_OF_OPERATION',
label:
'CessationOfOperation - The certificate is no longer needed for the purpose for which it was issued but there is no cause to suspect that the private key has been compromised',
},
CERTIFICATE_HOLD: {
value: 'CERTIFICATE_HOLD',
label:
'CertificateHold - The certificate is temporarily revoked but there is no cause to suspect that the private kye has been compromised',
},
REMOVE_FROM_CRL: {
value: 'REMOVE_FROM_CRL',
label: 'RemoveFromCRL - The certificate has been unrevoked',
},
PRIVILEGE_WITH_DRAWN: {
value: 'PRIVILEGE_WITH_DRAWN',
label:
'PrivilegeWithdrawn - The certificate was revoked because a privilege contained within that certificate has been withdrawn',
},
AA_COMPROMISE: {
value: 'AA_COMPROMISE',
label:
'AACompromise - It is known or suspected that aspects of the AA validated in the attribute certificate, have been compromised',
},
};

class CertificateInfos extends Component {
state = {
Expand Down Expand Up @@ -285,7 +324,12 @@ class CertificateValid extends Component {
if (payload.error) {
this.setState({ loading: false, valid: false, error: payload.error });
} else {
this.setState({ valid: payload.valid, loading: false, error: null, revoked: cert.revoked });
this.setState({
valid: payload.valid,
loading: false,
error: null,
revoked: cert.revoked,
});
}
})
.catch((e) => {
Expand Down Expand Up @@ -322,18 +366,24 @@ class CertificateValid extends Component {
<div className="form-group">
<label className="col-sm-2 control-label" />
<div className="col-sm-10">
{this.state.valid === true && (
this.state.revoked === RevocationReason.VALID.value ?
<div className="alert alert-success" role="alert">
Your certificate is valid
</div> :
this.state.revoked && <div className="alert alert-warning" role="alert">
Your certificate is valid but it has been revoked : {this.state.revoked}
</div>
)}
{this.state.valid === true &&
(this.state.revoked === RevocationReason.VALID.value ? (
<div className="alert alert-success" role="alert">
Your certificate is valid
</div>
) : (
this.state.revoked && (
<div className="alert alert-warning" role="alert">
Your certificate is valid but it has been revoked : {this.state.revoked}
</div>
)
))}
{this.state.valid === false && (
<div className="alert alert-danger" role="alert">
Your certificate is not valid {this.state.revoked !== RevocationReason.VALID.value ? (' : ' + this.state.revoked) : ''}
Your certificate is not valid{' '}
{this.state.revoked !== RevocationReason.VALID.value
? ' : ' + this.state.revoked
: ''}
</div>
)}
</div>
Expand Down Expand Up @@ -490,7 +540,12 @@ export class CertificatesPage extends Component {
},
{
title: 'revoked',
cell: (v, item) => (item.revoked !== RevocationReason.VALID.value ? <span className="label label-danger">yes</span> : ''),
cell: (v, item) =>
item.revoked !== RevocationReason.VALID.value ? (
<span className="label label-danger">yes</span>
) : (
''
),
content: (item) => (item.revoked !== RevocationReason.VALID.value ? 'yes' : 'no'),
style: { textAlign: 'center', width: 70 },
},
Expand Down Expand Up @@ -712,29 +767,31 @@ export class CertificatesPage extends Component {
});
};

updateCertificate = cert => {
if(cert.revoked === RevocationReason.VALID)
delete cert.metadata.revocationReason
updateCertificate = (cert) => {
if (cert.revoked === RevocationReason.VALID) delete cert.metadata.revocationReason;
else {
cert.metadata.revocationReason = cert.revoked
cert.metadata.revocationReason = cert.revoked;
cert.revoked = true;
}

BackOfficeServices.updateCertificate(cert)
}
BackOfficeServices.updateCertificate(cert);
};

findAllCertificates = () => {
return BackOfficeServices.findAllCertificates()
.then(certificates => certificates.map(cert => {
if(cert.metadata.revocationReason)
cert.revoked = RevocationReason[cert.metadata.revocationReason]? RevocationReason[cert.metadata.revocationReason].value : RevocationReason.UNSPECIFIED
else if(cert.revoked) // cert was revoked before revocation reason list implementation so set unspecified as reason
cert.revoked = RevocationReason.UNSPECIFIED.value
else
cert.revoked = RevocationReason.VALID.value
return BackOfficeServices.findAllCertificates().then((certificates) =>
certificates.map((cert) => {
if (cert.metadata.revocationReason)
cert.revoked = RevocationReason[cert.metadata.revocationReason]
? RevocationReason[cert.metadata.revocationReason].value
: RevocationReason.UNSPECIFIED;
else if (cert.revoked)
// cert was revoked before revocation reason list implementation so set unspecified as reason
cert.revoked = RevocationReason.UNSPECIFIED.value;
else cert.revoked = RevocationReason.VALID.value;
return cert;
}))
}
})
);
};

render() {
return (
Expand Down Expand Up @@ -849,7 +906,7 @@ export class NewCertificateForm extends Component {
hosts: this.props.host ? [this.props.host] : this.props.hosts || [],
signatureAlg: 'SHA256WithRSAEncryption',
digestAlg: 'SHA-256',
includeAIA: false
includeAIA: false,
};

componentDidMount() {
Expand Down
11 changes: 9 additions & 2 deletions otoroshi/javascript/src/pages/GlobalStatusPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,15 @@ export class GlobalStatusPage extends Component {
if (this.state.error || (this.state.status && this.state.status.length === 0)) {
return (
<>
<p>Your don't have any service health data available. Maybe you don't have an ElasticSearch instance connected to your Otoroshi</p>
<p>To do that, add a <a href="/bo/dashboard/exporters">data exporter</a> sending events to an ElasticSearch and settings to read events from your ElasticSeach in the <a href="/bo/dashboard/dangerzone">Danger Zone</a></p>
<p>
Your don't have any service health data available. Maybe you don't have an ElasticSearch
instance connected to your Otoroshi
</p>
<p>
To do that, add a <a href="/bo/dashboard/exporters">data exporter</a> sending events to
an ElasticSearch and settings to read events from your ElasticSeach in the{' '}
<a href="/bo/dashboard/dangerzone">Danger Zone</a>
</p>
</>
);
}
Expand Down
2 changes: 1 addition & 1 deletion otoroshi/javascript/src/pages/ScriptsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ export class ScriptsPage extends Component {

columns = [
{ title: 'Name', content: (item) => item.name },
{ title: 'Description', content: (item) => item.desc },
{ title: 'Description', content: (item) => item.desc },
];

formFlow = ['_loc', 'id', 'name', 'desc', 'type', 'compilation', 'code', 'metadata'];
Expand Down
15 changes: 11 additions & 4 deletions otoroshi/javascript/src/pages/ServiceHealthPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,18 @@ export class ServiceHealthPage extends Component {
if (!this.state.service || !this.state.status.length) {
return (
<>
<p>Your don't have any service health data available. Maybe you don't have an ElasticSearch instance connected to your Otoroshi</p>
<p>To do that, add a <a href="/bo/dashboard/exporters">data exporter</a> sending events to an ElasticSearch and settings to read events from your ElasticSeach in the <a href="/bo/dashboard/dangerzone">Danger Zone</a></p>
<p>
Your don't have any service health data available. Maybe you don't have an ElasticSearch
instance connected to your Otoroshi
</p>
<p>
To do that, add a <a href="/bo/dashboard/exporters">data exporter</a> sending events to
an ElasticSearch and settings to read events from your ElasticSeach in the{' '}
<a href="/bo/dashboard/dangerzone">Danger Zone</a>
</p>
</>
)
};
);
}

return (
<div className="content-health">
Expand Down
6 changes: 3 additions & 3 deletions otoroshi/javascript/src/pages/ServicePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class Target extends Component {
.replace('http://', '')
.replace('https://', '')
.replace('tcp://', '')
.replace('udp://', '')
.replace('udp://', '');
if (this.containsOneValueOf(domain, ['http:', 'https:', 'tcp:', 'udp:', '/'])) {
window.newAlert('You cannot put the path here, use target root');
return;
Expand All @@ -143,8 +143,8 @@ class Target extends Component {
};

containsOneValueOf = (value, values) => {
return values.filter(v => value.indexOf(v) > -1).length > 0;
}
return values.filter((v) => value.indexOf(v) > -1).length > 0;
};

render() {
const value = this.props.itemValue;
Expand Down
Loading

0 comments on commit 55e8be3

Please sign in to comment.