This commit is contained in:
Nelson Isioma 2025-06-25 07:51:28 +01:00
parent 5b34b6da86
commit fb0ce5892b
4 changed files with 21 additions and 13 deletions

View file

@ -37,7 +37,7 @@ type Client struct {
metadataKeySettings MetadataKeySettings
// Server Settings for password expiry
PasswordExpirySettings PasswordExpirySettings
passwordExpirySettings PasswordExpirySettings
// used for solving MFA challenges. You can block this to for example wait for user input.
// You shouden't run any unrelated API Calls while you are in this callback.
@ -239,20 +239,20 @@ func (c *Client) setMetadataTypeSettings(ctx context.Context, settings *ServerSe
return nil
}
// setPasswordExpirySettings Gets and configures the Client to use the password expiry plugin
// setPasswordExpirySettings fetches and configures the Client to use the password expiry plugin
func (c *Client) setPasswordExpirySettings(ctx context.Context, settings *ServerSettingsResponse) error {
if settings.Passbolt.IsPluginEnabled("passwordExpiry") && settings.Passbolt.IsPluginEnabled("passwordExpiryPolicies") {
c.log("Server has password expiry plugin enabled.")
passwordExpirySettings, err := c.GetServerPasswordExpirySettings(ctx)
passwordExpirySettings, err := c.getServerPasswordExpirySettings(ctx)
if err != nil {
return fmt.Errorf("Getting Password Expiry Settings: %w", err)
}
c.log("passwordExpirySettings: %+v", passwordExpirySettings)
c.PasswordExpirySettings = *passwordExpirySettings
c.passwordExpirySettings = *passwordExpirySettings
} else {
c.log("Server has password expiry plugin disabled or not installed.")
c.PasswordExpirySettings = getDefaultPasswordExpirySettings()
c.passwordExpirySettings = getDefaultPasswordExpirySettings()
}
return nil
@ -262,3 +262,8 @@ func (c *Client) setPasswordExpirySettings(ctx context.Context, settings *Server
func (c *Client) GetPGPHandle() *crypto.PGPHandle {
return c.pgp
}
// GetPasswordExpirySettings returns the password expiry settings for the client
func (c *Client) GetPasswordExpirySettings() PasswordExpirySettings {
return c.passwordExpirySettings
}

View file

@ -20,8 +20,8 @@ type PasswordExpirySettings struct {
ModifiedBy string `json:"modified_by"`
}
// GetServerPasswordExpirySettings gets the servers password expiry settings
func (c *Client) GetServerPasswordExpirySettings(ctx context.Context) (*PasswordExpirySettings, error) {
// getServerPasswordExpirySettings gets the servers password expiry settings
func (c *Client) getServerPasswordExpirySettings(ctx context.Context) (*PasswordExpirySettings, error) {
msg, err := c.DoCustomRequestV5(ctx, "GET", "/password-expiry/settings.json", nil, nil)
if err != nil {
return nil, err