mirror of
https://github.com/xslasd/x-oidc.git
synced 2025-10-20 22:49:40 +08:00
update IOIDCClient interface
Naming of repair methods
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# OpenID Connect SDK (client and server) for Go
|
||||
[](https://github.com/xslasd/x-oidc/blob/master/LICENSE)
|
||||
[](https://github.com/xslasd/x-oidc/releases)
|
||||
[](https://github.com/xslasd/x-oidc/releases)
|
||||
## X-OIDC Introduction
|
||||
The reimplemented OIDC (OpenID Connect) library, based on the zitadel/oidc library, includes both client (RP) and (OP) functionality.
|
||||
It is easier to use and more extensible than the original [zitadel/oidc](https://github.com/zitadel/oidc) library. This library appears to be very useful, especially for applications that need to implement the OIDC standard.
|
||||
|
@@ -48,7 +48,7 @@ func NewOIDCClient(cfg *Config, opts ...Option) (IOIDCClient, error) {
|
||||
|
||||
cli := &OIDCClient{opt: opt, cfg: cfg}
|
||||
|
||||
discoveryConfig, err := cli.Discover()
|
||||
discoveryConfig, err := cli.discover()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -59,6 +59,13 @@ func NewOIDCClient(cfg *Config, opts ...Option) (IOIDCClient, error) {
|
||||
}
|
||||
return cli, nil
|
||||
}
|
||||
func (o OIDCClient) JWKs() *jose.JSONWebKeySet {
|
||||
return o.jwks
|
||||
}
|
||||
func (o OIDCClient) DiscoveryConfiguration() *model.DiscoveryConfiguration {
|
||||
return o.discoveryConfig
|
||||
}
|
||||
|
||||
func (o OIDCClient) GenerateCodeChallenge(CodeChallengeMethod string) string {
|
||||
switch CodeChallengeMethod {
|
||||
case constant.CodeChallengeMethodPlain:
|
||||
@@ -304,7 +311,7 @@ func (o OIDCClient) SendHttpRequest(url string, method string, header map[string
|
||||
respBody, err := io.ReadAll(res.Body)
|
||||
return respBody, err
|
||||
}
|
||||
func (o OIDCClient) Discover() (*model.DiscoveryConfiguration, error) {
|
||||
func (o OIDCClient) discover() (*model.DiscoveryConfiguration, error) {
|
||||
wellKnown := strings.TrimSuffix(o.cfg.Issuer, "/") + constant.DiscoveryEndpoint
|
||||
res, err := o.SendHttpRequest(wellKnown, constant.HttpMethodGet, nil, nil)
|
||||
if err != nil {
|
||||
|
8
rp/rp.go
8
rp/rp.go
@@ -1,6 +1,9 @@
|
||||
package rp
|
||||
|
||||
import "github.com/xslasd/x-oidc/model"
|
||||
import (
|
||||
"github.com/go-jose/go-jose/v3"
|
||||
"github.com/xslasd/x-oidc/model"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
ClientID string
|
||||
@@ -60,4 +63,7 @@ type IOIDCClient interface {
|
||||
IntrospectToken(req *IntrospectionReq) (*model.IntrospectionModel, error)
|
||||
RevokeToken(req *RevokeTokenReq) (bool, error)
|
||||
ValidateIDToken(idToken string) (*model.IDTokenClaims, error)
|
||||
DiscoveryConfiguration() *model.DiscoveryConfiguration
|
||||
JWKs() *jose.JSONWebKeySet
|
||||
SendHttpRequest(url string, method string, header map[string]string, body map[string]string) ([]byte, error)
|
||||
}
|
||||
|
Reference in New Issue
Block a user