mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 03:24:26 +00:00
74688394d8
* docs: add scope to request private labeling * feat: add enum to project * fix: remove unused code, add private labeling setting to query side * fix: set private labeling depending on setting * fix: private labeling depending on project setting * Update proto/zitadel/management.proto Co-authored-by: Livio Amstutz <livio.a@gmail.com> * fix: rename sql file * fix: private labeling setting Co-authored-by: Livio Amstutz <livio.a@gmail.com>
61 lines
1.7 KiB
Go
61 lines
1.7 KiB
Go
package model
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"github.com/caos/logging"
|
|
|
|
"github.com/caos/zitadel/internal/crypto"
|
|
es_models "github.com/caos/zitadel/internal/eventstore/v1/models"
|
|
"github.com/caos/zitadel/internal/project/model"
|
|
)
|
|
|
|
type APIConfig struct {
|
|
es_models.ObjectRoot
|
|
AppID string `json:"appId"`
|
|
ClientID string `json:"clientId,omitempty"`
|
|
ClientSecret *crypto.CryptoValue `json:"clientSecret,omitempty"`
|
|
AuthMethodType int32 `json:"authMethodType,omitempty"`
|
|
ClientKeys []*ClientKey `json:"-"`
|
|
}
|
|
|
|
func (c *APIConfig) Changes(changed *APIConfig) map[string]interface{} {
|
|
changes := make(map[string]interface{}, 1)
|
|
changes["appId"] = c.AppID
|
|
if c.AuthMethodType != changed.AuthMethodType {
|
|
changes["authMethodType"] = changed.AuthMethodType
|
|
}
|
|
return changes
|
|
}
|
|
|
|
func APIConfigFromModel(config *model.APIConfig) *APIConfig {
|
|
return &APIConfig{
|
|
ObjectRoot: config.ObjectRoot,
|
|
AppID: config.AppID,
|
|
ClientID: config.ClientID,
|
|
ClientSecret: config.ClientSecret,
|
|
AuthMethodType: int32(config.AuthMethodType),
|
|
}
|
|
}
|
|
|
|
func APIConfigToModel(config *APIConfig) *model.APIConfig {
|
|
oidcConfig := &model.APIConfig{
|
|
ObjectRoot: config.ObjectRoot,
|
|
AppID: config.AppID,
|
|
ClientID: config.ClientID,
|
|
ClientSecret: config.ClientSecret,
|
|
AuthMethodType: model.APIAuthMethodType(config.AuthMethodType),
|
|
ClientKeys: ClientKeysToModel(config.ClientKeys),
|
|
}
|
|
return oidcConfig
|
|
}
|
|
|
|
func (o *APIConfig) setData(event *es_models.Event) error {
|
|
o.ObjectRoot.AppendEvent(event)
|
|
if err := json.Unmarshal(event.Data, o); err != nil {
|
|
logging.Log("EVEN-d8e3s").WithError(err).Error("could not unmarshal event data")
|
|
return err
|
|
}
|
|
return nil
|
|
}
|