polycule-connect/polyculeconnect/internal/client/client.go

24 lines
627 B
Go
Raw Normal View History

package client
import (
"context"
"fmt"
"git.faercol.me/faercol/polyculeconnect/polyculeconnect/internal/model"
"github.com/zitadel/oidc/v3/pkg/client/rp"
)
type OIDCClient struct {
Conf *model.Backend
provider rp.RelyingParty
}
func New(ctx context.Context, conf *model.Backend) (*OIDCClient, error) {
pr, err := rp.NewRelyingPartyOIDC(ctx, conf.OIDCConfig.Issuer, conf.OIDCConfig.ClientID, conf.OIDCConfig.ClientSecret, conf.OIDCConfig.RedirectURI, []string{})
if err != nil {
return nil, fmt.Errorf("failed to init relying party provider: %w", err)
}
return &OIDCClient{Conf: conf, provider: pr}, nil
}