@@ -36,6 +36,9 @@ type Client struct {
36
36
// Server Settings Determining which Metadata Keys to use
37
37
metadataKeySettings MetadataKeySettings
38
38
39
+ // Server Settings for password expiry
40
+ passwordExpirySettings PasswordExpirySettings
41
+
39
42
// used for solving MFA challenges. You can block this to for example wait for user input.
40
43
// You shouden't run any unrelated API Calls while you are in this callback.
41
44
// You need to Return the Cookie that Passbolt expects to verify you MFA, usually it is called passbolt_mfa
@@ -207,12 +210,7 @@ func (c *Client) GetPublicKey(ctx context.Context) (string, string, error) {
207
210
}
208
211
209
212
// setMetadataTypeSettings Gets and configures the Client to use the Types the Server wants us to use
210
- func (c * Client ) setMetadataTypeSettings (ctx context.Context ) error {
211
- settings , err := c .GetServerSettings (ctx )
212
- if err != nil {
213
- return fmt .Errorf ("Getting Server Settings: %w" , err )
214
- }
215
-
213
+ func (c * Client ) setMetadataTypeSettings (ctx context.Context , settings * ServerSettingsResponse ) error {
216
214
if settings .Passbolt .IsPluginEnabled ("metadata" ) {
217
215
c .log ("Server has metadata plugin enabled, is v5 or Higher" )
218
216
metadataTypeSettings , err := c .GetServerMetadataTypeSettings (ctx )
@@ -241,7 +239,31 @@ func (c *Client) setMetadataTypeSettings(ctx context.Context) error {
241
239
return nil
242
240
}
243
241
242
+ // setPasswordExpirySettings fetches and configures the Client to use the password expiry plugin
243
+ func (c * Client ) setPasswordExpirySettings (ctx context.Context , settings * ServerSettingsResponse ) error {
244
+ if settings .Passbolt .IsPluginEnabled ("passwordExpiry" ) && settings .Passbolt .IsPluginEnabled ("passwordExpiryPolicies" ) {
245
+ c .log ("Server has password expiry plugin enabled." )
246
+ passwordExpirySettings , err := c .getServerPasswordExpirySettings (ctx )
247
+ if err != nil {
248
+ return fmt .Errorf ("Getting Password Expiry Settings: %w" , err )
249
+ }
250
+
251
+ c .log ("passwordExpirySettings: %+v" , passwordExpirySettings )
252
+ c .passwordExpirySettings = * passwordExpirySettings
253
+ } else {
254
+ c .log ("Server has password expiry plugin disabled or not installed." )
255
+ c .passwordExpirySettings = getDefaultPasswordExpirySettings ()
256
+ }
257
+
258
+ return nil
259
+ }
260
+
244
261
// GetPGPHandle Gets the Gopgenpgp Handler
245
262
func (c * Client ) GetPGPHandle () * crypto.PGPHandle {
246
263
return c .pgp
247
264
}
265
+
266
+ // GetPasswordExpirySettings returns the password expiry settings for the client
267
+ func (c * Client ) GetPasswordExpirySettings () PasswordExpirySettings {
268
+ return c .passwordExpirySettings
269
+ }
0 commit comments