polycule-connect/polyculeconnect/internal/client/client.go
Melora Hugues 9206c8e41e
Some checks failed
/ docker-build-only (push) Failing after 45s
/ go-test (push) Failing after 1m28s
Add start of auth request storage
2024-09-22 10:26:27 +02:00

39 lines
1.1 KiB
Go

package client
import (
"context"
"fmt"
"log/slog"
"git.faercol.me/faercol/polyculeconnect/polyculeconnect/internal/db"
"git.faercol.me/faercol/polyculeconnect/polyculeconnect/internal/model"
"git.faercol.me/faercol/polyculeconnect/polyculeconnect/logger"
"github.com/zitadel/oidc/v3/pkg/client/rp"
"go.uber.org/zap"
"go.uber.org/zap/exp/zapslog"
)
type OIDCClient struct {
conf *model.Backend
provider rp.RelyingParty
ctx context.Context
st db.Storage
l *zap.SugaredLogger
}
func New(ctx context.Context, conf *model.Backend, l *zap.SugaredLogger) (*OIDCClient, error) {
options := []rp.Option{
rp.WithLogger(slog.New(zapslog.NewHandler(logger.L.Desugar().Core(), nil))),
}
pr, err := rp.NewRelyingPartyOIDC(ctx, conf.OIDCConfig.Issuer, conf.OIDCConfig.ClientID, conf.OIDCConfig.ClientSecret, conf.OIDCConfig.RedirectURI, []string{}, options...)
if err != nil {
return nil, fmt.Errorf("failed to init relying party provider: %w", err)
}
return &OIDCClient{ctx: ctx, conf: conf, provider: pr, l: l}, nil
}
func (c *OIDCClient) toto() {
c.provider.GetDeviceAuthorizationEndpoint()
}