You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
993 B
43 lines
993 B
3 years ago
|
package sharedmodel
|
||
|
|
||
|
import (
|
||
|
"gorm.io/gorm"
|
||
|
"whiteboxsystems.nl/openkvpoc/openkv"
|
||
|
)
|
||
|
|
||
|
type RegistrationStatus string
|
||
|
|
||
|
const (
|
||
|
RegistrationStatusPending = RegistrationStatus("pending")
|
||
|
RegistrationStatusCompleted = RegistrationStatus("completed")
|
||
|
)
|
||
|
|
||
|
type Registration struct {
|
||
|
gorm.Model
|
||
|
OrganisationId string
|
||
|
OrganisationIdSystem string
|
||
|
OrganisationDisplayName string
|
||
|
AuthConfigID uint
|
||
|
AuthConfig *AuthConfig
|
||
|
Reference string
|
||
|
PSK string
|
||
|
Status RegistrationStatus
|
||
|
}
|
||
|
|
||
|
func (r *Registration) SetAuthConfig(cfg *openkv.AuthConfig) {
|
||
|
authConfig := &AuthConfig{
|
||
|
Method: cfg.Method,
|
||
|
}
|
||
|
|
||
|
switch cfg.Method {
|
||
|
case openkv.AuthMethod_JWT:
|
||
|
authConfig.Raw = cfg.GetJwtConfig().GetPublicKey()
|
||
|
case openkv.AuthMethod_APIToken:
|
||
|
authConfig.Raw = cfg.GetApiTokenConfig().GetToken()
|
||
|
case openkv.AuthMethod_mTLS:
|
||
|
authConfig.Raw = cfg.GetMtlsConfig().GetPublicKey()
|
||
|
}
|
||
|
|
||
|
r.AuthConfig = authConfig
|
||
|
}
|