mirror of
https://github.com/zitadel/zitadel.git
synced 2025-07-19 08:28:35 +00:00

# Which Problems Are Solved This PR *partially* addresses #9450 . Specifically, it implements the resource based API for the apps. APIs for app keys ARE not part of this PR. # How the Problems Are Solved - `CreateApplication`, `PatchApplication` (update) and `RegenerateClientSecret` endpoints are now unique for all app types: API, SAML and OIDC apps. - All new endpoints have integration tests - All new endpoints are using permission checks V2 # Additional Changes - The `ListApplications` endpoint allows to do sorting (see protobuf for details) and filtering by app type (see protobuf). - SAML and OIDC update endpoint can now receive requests for partial updates # Additional Context Partially addresses #9450
61 lines
1.9 KiB
Go
61 lines
1.9 KiB
Go
package convert
|
|
|
|
import (
|
|
"github.com/zitadel/zitadel/internal/domain"
|
|
"github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
|
"github.com/zitadel/zitadel/internal/query"
|
|
app "github.com/zitadel/zitadel/pkg/grpc/app/v2beta"
|
|
)
|
|
|
|
func CreateAPIApplicationRequestToDomain(name, projectID, appID string, app *app.CreateAPIApplicationRequest) *domain.APIApp {
|
|
return &domain.APIApp{
|
|
ObjectRoot: models.ObjectRoot{
|
|
AggregateID: projectID,
|
|
},
|
|
AppName: name,
|
|
AppID: appID,
|
|
AuthMethodType: apiAuthMethodTypeToDomain(app.GetAuthMethodType()),
|
|
}
|
|
}
|
|
|
|
func UpdateAPIApplicationConfigurationRequestToDomain(appID, projectID string, app *app.UpdateAPIApplicationConfigurationRequest) *domain.APIApp {
|
|
return &domain.APIApp{
|
|
ObjectRoot: models.ObjectRoot{
|
|
AggregateID: projectID,
|
|
},
|
|
AppID: appID,
|
|
AuthMethodType: apiAuthMethodTypeToDomain(app.GetAuthMethodType()),
|
|
}
|
|
}
|
|
|
|
func appAPIConfigToPb(apiApp *query.APIApp) app.ApplicationConfig {
|
|
return &app.Application_ApiConfig{
|
|
ApiConfig: &app.APIConfig{
|
|
ClientId: apiApp.ClientID,
|
|
AuthMethodType: apiAuthMethodTypeToPb(apiApp.AuthMethodType),
|
|
},
|
|
}
|
|
}
|
|
|
|
func apiAuthMethodTypeToDomain(authType app.APIAuthMethodType) domain.APIAuthMethodType {
|
|
switch authType {
|
|
case app.APIAuthMethodType_API_AUTH_METHOD_TYPE_BASIC:
|
|
return domain.APIAuthMethodTypeBasic
|
|
case app.APIAuthMethodType_API_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT:
|
|
return domain.APIAuthMethodTypePrivateKeyJWT
|
|
default:
|
|
return domain.APIAuthMethodTypeBasic
|
|
}
|
|
}
|
|
|
|
func apiAuthMethodTypeToPb(methodType domain.APIAuthMethodType) app.APIAuthMethodType {
|
|
switch methodType {
|
|
case domain.APIAuthMethodTypeBasic:
|
|
return app.APIAuthMethodType_API_AUTH_METHOD_TYPE_BASIC
|
|
case domain.APIAuthMethodTypePrivateKeyJWT:
|
|
return app.APIAuthMethodType_API_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT
|
|
default:
|
|
return app.APIAuthMethodType_API_AUTH_METHOD_TYPE_BASIC
|
|
}
|
|
}
|