Livio Amstutz 2f7d8ca557
fix: client secret verification (for introspection) (#2825)
* fix: client secret verification (for introspection)

* revert change for ProjectIDAndOriginsByClientID
2021-12-10 09:25:17 +00:00

29 lines
731 B
Go

package eventstore
import (
"context"
"github.com/caos/zitadel/internal/command"
"github.com/caos/zitadel/internal/query"
"github.com/caos/zitadel/internal/telemetry/tracing"
)
type ApplicationRepo struct {
Commands *command.Commands
Query *query.Queries
}
func (a *ApplicationRepo) AuthorizeClientIDSecret(ctx context.Context, clientID, secret string) (err error) {
ctx, span := tracing.NewSpan(ctx)
defer func() { span.EndWithError(err) }()
app, err := a.Query.AppByClientID(ctx, clientID)
if err != nil {
return err
}
if app.OIDCConfig != nil {
return a.Commands.VerifyOIDCClientSecret(ctx, app.ProjectID, app.ID, secret)
}
return a.Commands.VerifyAPIClientSecret(ctx, app.ProjectID, app.ID, secret)
}