Files
grafana/pkg/services/ssosettings/models/models.go
T
Mihai Doarna 15d8a1f94d Auth: Remove types from SSOSettings struct in SSO service (#79459)
* replace SSOSettings with SSOSettingsDTO

* fix database tests

* fix oauth strategy

* fix sso settings service tests

* add secrets encryption on update

* rename SSOSettingsDTO to SSOSettings

* remove extraKeys from strategy

* change back settings type from createOAuthConnector to OAuthInfo

* do not parse multi-value fields in oauth strategy
2023-12-15 16:00:52 +02:00

43 lines
985 B
Go

package models
import (
"encoding/json"
"fmt"
"time"
)
type SettingsSource int
const (
DB = iota
System
)
func (s SettingsSource) MarshalJSON() ([]byte, error) {
switch s {
case DB:
return json.Marshal("database")
case System:
return json.Marshal("system")
default:
return nil, fmt.Errorf("unknown source: %d", s)
}
}
type SSOSettings struct {
ID string `xorm:"id pk" json:"id"`
Provider string `xorm:"provider" json:"provider"`
Settings map[string]any `xorm:"settings" json:"settings"`
Created time.Time `xorm:"created" json:"-"`
Updated time.Time `xorm:"updated" json:"-"`
IsDeleted bool `xorm:"is_deleted" json:"-"`
Source SettingsSource `xorm:"-" json:"source"`
}
// TableName returns the table name (needed for Xorm)
func (s SSOSettings) TableName() string {
return "sso_setting"
}
// TODO: check if we need custom marshalling/unmarshalling functions for converting the settings keys to camelCase