Add MetadataTypeSettings to Client, add set function

This commit is contained in:
Samuel Lorch 2025-03-05 18:12:01 +01:00
parent b6b067c61c
commit 0c5cd9152d

View file

@ -31,6 +31,9 @@ type Client struct {
userPublicKey string userPublicKey string
userID string userID string
// Server Settings Determining which Resource Types we can use
metadataTypeSettings MetadataTypeSettings
// 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.
// You need to Return the Cookie that Passbolt expects to verify you MFA, usually it is called passbolt_mfa // You need to Return the Cookie that Passbolt expects to verify you MFA, usually it is called passbolt_mfa
@ -208,3 +211,26 @@ func (c *Client) GetPublicKey(ctx context.Context) (string, string, error) {
} }
return body.Keydata, privateKeyObj.GetFingerprint(), nil return body.Keydata, privateKeyObj.GetFingerprint(), nil
} }
// setMetadataTypeSettings Gets and configures the Client to use the Types the Server wants us to use
func (c *Client) setMetadataTypeSettings(ctx context.Context) error {
settings, err := c.GetServerSettings(ctx)
if err != nil {
return fmt.Errorf("Getting Server Settings: %w", err)
}
if settings.Passbolt.IsPluginEnabled("metadata") {
c.log("Server has metadata plugin enabled, is v5 or Higher")
metadataTypeSettings, err := c.GetMetadataTypeSettings(ctx)
if err != nil {
return fmt.Errorf("Getting Metadata Type Settings: %w", err)
}
c.log("metadataTypeSettings: %+v", metadataTypeSettings)
c.metadataTypeSettings = *metadataTypeSettings
} else {
c.log("Server has metadata plugin disabled or not installed, Server is v4")
c.metadataTypeSettings = getV4DefaultMetadataTypeSettings()
}
return nil
}