mirror of
https://github.com/passbolt/go-passbolt.git
synced 2025-05-10 01:48:22 +00:00
Add MetadataTypeSettings to Client, add set function
This commit is contained in:
parent
b6b067c61c
commit
0c5cd9152d
1 changed files with 26 additions and 0 deletions
|
@ -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
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue