mirror of
https://github.com/passbolt/go-passbolt.git
synced 2025-09-13 14:29:09 +00:00
feat: adding password expiry
This commit is contained in:
parent
ffcbf94cf4
commit
5262eff022
4 changed files with 95 additions and 7 deletions
50
api/password_expiry.go
Normal file
50
api/password_expiry.go
Normal file
|
@ -0,0 +1,50 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"time"
|
||||
)
|
||||
|
||||
// PasswordExpirySettings contains the Password expiry settings
|
||||
type PasswordExpirySettings struct {
|
||||
ID string `json:"id"`
|
||||
DefaultExpiryPeriod int `json:"default_expiry_period,omitempty"`
|
||||
PolicyOverride bool `json:"policy_override"`
|
||||
AutomaticExpiry bool `json:"automatic_expiry"`
|
||||
AutomaticUpdate bool `json:"automatic_update"`
|
||||
ExpiryNotificationPeriod int `json:"expiry_notification_period,omitempty"`
|
||||
Created time.Time `json:"created"`
|
||||
Modified time.Time `json:"modified"`
|
||||
CreatedBy string `json:"created_by"`
|
||||
ModifiedBy string `json:"modified_by"`
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
var passwordExpirySettings PasswordExpirySettings
|
||||
err = json.Unmarshal(msg.Body, &passwordExpirySettings)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &passwordExpirySettings, nil
|
||||
}
|
||||
|
||||
func getDefaultPasswordExpirySettings() PasswordExpirySettings {
|
||||
return PasswordExpirySettings{
|
||||
ID: "default",
|
||||
DefaultExpiryPeriod: 0,
|
||||
PolicyOverride: false,
|
||||
AutomaticExpiry: false,
|
||||
AutomaticUpdate: false,
|
||||
ExpiryNotificationPeriod: 0,
|
||||
Created: time.Now(),
|
||||
Modified: time.Now(),
|
||||
CreatedBy: "default",
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue