mirror of
https://github.com/passbolt/go-passbolt.git
synced 2025-09-13 14:29:09 +00:00
Compare commits
1 commit
2652858fe5
...
1704d5387c
Author | SHA1 | Date | |
---|---|---|---|
![]() |
1704d5387c |
4 changed files with 13 additions and 21 deletions
|
@ -37,7 +37,7 @@ type Client struct {
|
||||||
metadataKeySettings MetadataKeySettings
|
metadataKeySettings MetadataKeySettings
|
||||||
|
|
||||||
// Server Settings for password expiry
|
// 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.
|
// 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.
|
// 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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// setPasswordExpirySettings fetches and configures the Client to use the password expiry plugin
|
// setPasswordExpirySettings Gets and configures the Client to use the password expiry plugin
|
||||||
func (c *Client) setPasswordExpirySettings(ctx context.Context, settings *ServerSettingsResponse) error {
|
func (c *Client) setPasswordExpirySettings(ctx context.Context, settings *ServerSettingsResponse) error {
|
||||||
if settings.Passbolt.IsPluginEnabled("passwordExpiry") && settings.Passbolt.IsPluginEnabled("passwordExpiryPolicies") {
|
if settings.Passbolt.IsPluginEnabled("passwordExpiry") && settings.Passbolt.IsPluginEnabled("passwordExpiryPolicies") {
|
||||||
c.log("Server has password expiry plugin enabled.")
|
c.log("Server has password expiry plugin enabled.")
|
||||||
passwordExpirySettings, err := c.getServerPasswordExpirySettings(ctx)
|
passwordExpirySettings, err := c.GetServerPasswordExpirySettings(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Getting Password Expiry Settings: %w", err)
|
return fmt.Errorf("Getting Password Expiry Settings: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
c.log("passwordExpirySettings: %+v", passwordExpirySettings)
|
c.log("passwordExpirySettings: %+v", passwordExpirySettings)
|
||||||
c.passwordExpirySettings = *passwordExpirySettings
|
c.PasswordExpirySettings = *passwordExpirySettings
|
||||||
} else {
|
} else {
|
||||||
c.log("Server has password expiry plugin disabled or not installed.")
|
c.log("Server has password expiry plugin disabled or not installed.")
|
||||||
c.passwordExpirySettings = getDefaultPasswordExpirySettings()
|
c.PasswordExpirySettings = getDefaultPasswordExpirySettings()
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -262,8 +262,3 @@ func (c *Client) setPasswordExpirySettings(ctx context.Context, settings *Server
|
||||||
func (c *Client) GetPGPHandle() *crypto.PGPHandle {
|
func (c *Client) GetPGPHandle() *crypto.PGPHandle {
|
||||||
return c.pgp
|
return c.pgp
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetPasswordExpirySettings returns the password expiry settings for the client
|
|
||||||
func (c *Client) GetPasswordExpirySettings() PasswordExpirySettings {
|
|
||||||
return c.passwordExpirySettings
|
|
||||||
}
|
|
||||||
|
|
|
@ -20,8 +20,8 @@ type PasswordExpirySettings struct {
|
||||||
ModifiedBy string `json:"modified_by"`
|
ModifiedBy string `json:"modified_by"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// getServerPasswordExpirySettings gets the servers password expiry settings
|
// GetServerPasswordExpirySettings gets the servers password expiry settings
|
||||||
func (c *Client) getServerPasswordExpirySettings(ctx context.Context) (*PasswordExpirySettings, error) {
|
func (c *Client) GetServerPasswordExpirySettings(ctx context.Context) (*PasswordExpirySettings, error) {
|
||||||
msg, err := c.DoCustomRequestV5(ctx, "GET", "/password-expiry/settings.json", nil, nil)
|
msg, err := c.DoCustomRequestV5(ctx, "GET", "/password-expiry/settings.json", nil, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -100,9 +100,8 @@ func CreateResourceV5(ctx context.Context, c *api.Client, folderParentID, name,
|
||||||
}
|
}
|
||||||
resource.Secrets = []api.Secret{{Data: encSecretData}}
|
resource.Secrets = []api.Secret{{Data: encSecretData}}
|
||||||
|
|
||||||
passwordExpirySettings := c.GetPasswordExpirySettings()
|
if c.PasswordExpirySettings.DefaultExpiryPeriod != 0 {
|
||||||
if passwordExpirySettings.DefaultExpiryPeriod != 0 {
|
expiry := time.Now().Add(time.Hour * 24 * time.Duration(c.PasswordExpirySettings.DefaultExpiryPeriod))
|
||||||
expiry := time.Now().Add(time.Hour * 24 * time.Duration(passwordExpirySettings.DefaultExpiryPeriod))
|
|
||||||
resource.Expired = &api.Time{Time: expiry}
|
resource.Expired = &api.Time{Time: expiry}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,9 +160,8 @@ func CreateResourceV4(ctx context.Context, c *api.Client, folderParentID, name,
|
||||||
}
|
}
|
||||||
resource.Secrets = []api.Secret{{Data: encSecretData}}
|
resource.Secrets = []api.Secret{{Data: encSecretData}}
|
||||||
|
|
||||||
passwordExpirySettings := c.GetPasswordExpirySettings()
|
if c.PasswordExpirySettings.DefaultExpiryPeriod != 0 {
|
||||||
if passwordExpirySettings.DefaultExpiryPeriod != 0 {
|
expiry := time.Now().Add(time.Hour * 24 * time.Duration(c.PasswordExpirySettings.DefaultExpiryPeriod))
|
||||||
expiry := time.Now().Add(time.Hour * 24 * time.Duration(passwordExpirySettings.DefaultExpiryPeriod))
|
|
||||||
resource.Expired = &api.Time{Time: expiry}
|
resource.Expired = &api.Time{Time: expiry}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -377,9 +377,8 @@ func UpdateResource(ctx context.Context, c *api.Client, resourceID, name, userna
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
passwordExpirySettings := c.GetPasswordExpirySettings()
|
if resource.Expired != nil && c.PasswordExpirySettings.AutomaticUpdate {
|
||||||
if resource.Expired != nil && passwordExpirySettings.AutomaticUpdate {
|
expiry := time.Now().Add(time.Hour * 24 * time.Duration(c.PasswordExpirySettings.DefaultExpiryPeriod))
|
||||||
expiry := time.Now().Add(time.Hour * 24 * time.Duration(passwordExpirySettings.DefaultExpiryPeriod))
|
|
||||||
newResource.Expired = &api.Time{expiry}
|
newResource.Expired = &api.Time{expiry}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue