Skip to content

Commit

Permalink
Issue 5646 - CLI/UI - do not hardcode password storage schemes
Browse files Browse the repository at this point in the history
Description:  Previously all the password storage schemes were hardcoded
              in the UI.  Now dsconf can list all the current schemes the
              server supports

relates: #5636

Reviewed by: spichugi(Thanks!)
  • Loading branch information
mreynolds389 committed Feb 14, 2023
1 parent ff93944 commit 2cc7649
Show file tree
Hide file tree
Showing 5 changed files with 216 additions and 154 deletions.
21 changes: 21 additions & 0 deletions src/cockpit/389-console/src/database.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export class Database extends React.Component {
BackupRows: [],
backupRefreshing: false,
suffixList: [],
pwdStorageSchemes: [],
loaded: false,
};

Expand All @@ -111,6 +112,7 @@ export class Database extends React.Component {
this.loadLDIFs = this.loadLDIFs.bind(this);
this.loadBackups = this.loadBackups.bind(this);
this.loadSuffixList = this.loadSuffixList.bind(this);
this.loadPwdStorageSchemes = this.loadPwdStorageSchemes.bind(this);

// Suffix
this.handleShowSuffixModal = this.handleShowSuffixModal.bind(this);
Expand Down Expand Up @@ -144,6 +146,7 @@ export class Database extends React.Component {
this.loadLDIFs();
this.loadBackups();
this.loadSuffixList();
this.loadPwdStorageSchemes();
}
this.loadSuffixTree(false);
} else {
Expand All @@ -170,6 +173,22 @@ export class Database extends React.Component {
});
}

loadPwdStorageSchemes () {
const cmd = [
"dsconf", "-j", "ldapi://%2fvar%2frun%2fslapd-" + this.props.serverId + ".socket",
"pwpolicy", "list-schemes"
];
log_cmd("loadPwdStorageSchemes", "Get a list of all the password storage sehemes", cmd);
cockpit
.spawn(cmd, { superuser: true, err: "message" })
.done(content => {
const schemes = JSON.parse(content);
this.setState(() => (
{ pwdStorageSchemes: schemes.items }
));
});
}

loadNDN() {
this.setState({
loaded: false,
Expand Down Expand Up @@ -1222,6 +1241,7 @@ export class Database extends React.Component {
serverId={this.props.serverId}
addNotification={this.props.addNotification}
attrs={this.state.attributes}
pwdStorageSchemes={this.state.pwdStorageSchemes}
enableTree={this.enableTree}
/>;
} else if (this.state.node_name === LOCAL_PWP_CONFIG) {
Expand All @@ -1230,6 +1250,7 @@ export class Database extends React.Component {
serverId={this.props.serverId}
addNotification={this.props.addNotification}
attrs={this.state.attributes}
pwdStorageSchemes={this.state.pwdStorageSchemes}
enableTree={this.enableTree}
/>;
} else if (this.state.node_name === BACKUP_CONFIG) {
Expand Down
22 changes: 9 additions & 13 deletions src/cockpit/389-console/src/lib/database/globalPwp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1364,19 +1364,13 @@ export class GlobalPwPolicy extends React.Component {
}}
aria-label="FormSelect Input"
>
<FormSelectOption key="0" value="PBKDF2_SHA256" label="PBKDF2_SHA256" />
<FormSelectOption key="1" value="SSHA512" label="SSHA512" />
<FormSelectOption key="2" value="SSHA384" label="SSHA384" />
<FormSelectOption key="3" value="SSHA256" label="SSHA256" />
<FormSelectOption key="4" value="SSHA" label="SSHA" />
<FormSelectOption key="5" value="MD5" label="MD5" />
<FormSelectOption key="6" value="SMD5" label="SMD5" />
<FormSelectOption key="7" value="CRYPT-MD5" label="CRYPT-MD5" />
<FormSelectOption key="8" value="CRYPT-SHA512" label="CRYPT-SHA512" />
<FormSelectOption key="9" value="CRYPT-SHA256" label="CRYPT-SHA256" />
<FormSelectOption key="10" value="CRYPT" label="CRYPT" />
<FormSelectOption key="11" value="GOST_YESCRYPT" label="GOST_YESCRYPT" />
<FormSelectOption key="12" value="CLEAR" label="CLEAR" />
{this.props.pwdStorageSchemes.map((option, index) => (
<FormSelectOption
key={index}
value={option}
label={option}
/>
))}
</FormSelect>
</GridItem>
</Grid>
Expand Down Expand Up @@ -1635,8 +1629,10 @@ export class GlobalPwPolicy extends React.Component {

GlobalPwPolicy.propTypes = {
attrs: PropTypes.array,
pwdStorageSchemes: PropTypes.array,
};

GlobalPwPolicy.defaultProps = {
attrs: [],
pwdStorageSchemes: []
};
Loading

0 comments on commit 2cc7649

Please sign in to comment.