mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-14 20:08:02 +00:00
2bd255106a
* fix: org tests * fix: org tests * fix: user grant test * fix: user grant test * fix: project and project role test * fix: project grant test * fix: project grant test * fix: project member, grant member, app changed tests * fix: application tests * fix: application tests * fix: add oidc app test * fix: add oidc app test * fix: add api keys test * fix: iam policies * fix: iam and org member tests * fix: clock skew validation * revert crypto changes * fix: tests * fix project grant member commands Co-authored-by: Livio Amstutz <livio.a@gmail.com>
62 lines
1.2 KiB
Go
62 lines
1.2 KiB
Go
package domain
|
|
|
|
import (
|
|
"github.com/caos/zitadel/internal/crypto"
|
|
"github.com/caos/zitadel/internal/eventstore/v1/models"
|
|
)
|
|
|
|
type APIApp struct {
|
|
models.ObjectRoot
|
|
|
|
AppID string
|
|
AppName string
|
|
ClientID string
|
|
ClientSecret *crypto.CryptoValue
|
|
ClientSecretString string
|
|
AuthMethodType APIAuthMethodType
|
|
|
|
State AppState
|
|
}
|
|
|
|
func (a *APIApp) GetApplicationName() string {
|
|
return a.AppName
|
|
}
|
|
|
|
func (a *APIApp) GetState() AppState {
|
|
return a.State
|
|
}
|
|
|
|
type APIAuthMethodType int32
|
|
|
|
const (
|
|
APIAuthMethodTypeBasic APIAuthMethodType = iota
|
|
APIAuthMethodTypePrivateKeyJWT
|
|
)
|
|
|
|
func (a *APIApp) IsValid() bool {
|
|
return a.AppName != ""
|
|
}
|
|
|
|
func (a *APIApp) setClientID(clientID string) {
|
|
a.ClientID = clientID
|
|
}
|
|
|
|
func (a *APIApp) setClientSecret(clientSecret *crypto.CryptoValue) {
|
|
a.ClientSecret = clientSecret
|
|
}
|
|
|
|
func (a *APIApp) requiresClientSecret() bool {
|
|
return a.AuthMethodType == APIAuthMethodTypeBasic
|
|
}
|
|
|
|
func (a *APIApp) GenerateClientSecretIfNeeded(generator crypto.Generator) (secret string, err error) {
|
|
if a.AuthMethodType == APIAuthMethodTypePrivateKeyJWT {
|
|
return "", nil
|
|
}
|
|
a.ClientSecret, secret, err = NewClientSecret(generator)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return secret, nil
|
|
}
|