mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-18 22:07:32 +00:00
3473156c7e
* fix: move queries to query package * fix(auth): switch project role requests to query pkg * refactor: delete unused project role code * remove repo * implement sql queries * fix(database): oidc config change type to int2 * fix(queries): implement app queries * refactor: simplify code * fix: correct app query * Update app.go * fix token check * fix mock * test: app prepares * test: oidc compliance * test: OIDCOriginAllowList * fix: converter * resolve unsupported oidc version Co-authored-by: Livio Amstutz <livio.a@gmail.com>
49 lines
1.2 KiB
Go
49 lines
1.2 KiB
Go
package view
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/caos/zitadel/internal/errors"
|
|
"github.com/caos/zitadel/internal/query"
|
|
"github.com/caos/zitadel/internal/telemetry/tracing"
|
|
)
|
|
|
|
func (v *View) ApplicationByOIDCClientID(clientID string) (*query.App, error) {
|
|
return v.Query.AppByOIDCClientID(context.TODO(), clientID)
|
|
}
|
|
|
|
func (v *View) ApplicationByProjecIDAndAppName(ctx context.Context, projectID, appName string) (_ *query.App, err error) {
|
|
ctx, span := tracing.NewSpan(ctx)
|
|
defer func() { span.EndWithError(err) }()
|
|
|
|
nameQuery, err := query.NewAppNameSearchQuery(query.TextEquals, appName)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
projectQuery, err := query.NewAppProjectIDSearchQuery(projectID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
queries := &query.AppSearchQueries{
|
|
Queries: []query.SearchQuery{
|
|
nameQuery,
|
|
projectQuery,
|
|
},
|
|
}
|
|
|
|
apps, err := v.Query.SearchApps(ctx, queries)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if len(apps.Apps) != 1 {
|
|
return nil, errors.ThrowNotFound(nil, "VIEW-svLQq", "app not found")
|
|
}
|
|
|
|
return apps.Apps[0], nil
|
|
}
|
|
|
|
func (v *View) SearchApplications(request *query.AppSearchQueries) (*query.Apps, error) {
|
|
return v.Query.SearchApps(context.TODO(), request)
|
|
}
|