mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 11:34:26 +00:00
32 lines
986 B
Go
32 lines
986 B
Go
|
package eventstore
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
|
||
|
"github.com/caos/zitadel/internal/auth/repository/eventsourcing/view"
|
||
|
"github.com/caos/zitadel/internal/project/model"
|
||
|
proj_event "github.com/caos/zitadel/internal/project/repository/eventsourcing"
|
||
|
proj_view_model "github.com/caos/zitadel/internal/project/repository/view/model"
|
||
|
)
|
||
|
|
||
|
type ApplicationRepo struct {
|
||
|
View *view.View
|
||
|
ProjectEvents *proj_event.ProjectEventstore
|
||
|
}
|
||
|
|
||
|
func (a *ApplicationRepo) ApplicationByClientID(ctx context.Context, clientID string) (*model.ApplicationView, error) {
|
||
|
app, err := a.View.ApplicationByClientID(ctx, clientID)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
return proj_view_model.ApplicationViewToModel(app), nil
|
||
|
}
|
||
|
|
||
|
func (a *ApplicationRepo) AuthorizeOIDCApplication(ctx context.Context, clientID, secret string) error {
|
||
|
app, err := a.View.ApplicationByClientID(ctx, clientID)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
return a.ProjectEvents.VerifyOIDCClientSecret(ctx, app.ProjectID, app.ID, secret)
|
||
|
}
|