mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 07:47:32 +00:00
feat: App API v2 (#10077)
# 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
This commit is contained in:
60
internal/api/grpc/app/v2beta/convert/api_app.go
Normal file
60
internal/api/grpc/app/v2beta/convert/api_app.go
Normal file
@@ -0,0 +1,60 @@
|
||||
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
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user