oidcdiscovery

package module
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2021 License: GPL-3.0 Imports: 6 Imported by: 1

README

OIDC Discovery client

This package covers two needs:

  1. Get the discovery document from some authority
  2. Get certificates from that authority

Usage

package main

import (
... your important stuff
"github.com/klyngen/golang-oidc-discovery"
)

func main() {
client, \_ := new oidcdiscovery.NewOidcDiscoveryClient("https://your-oidc-provider.com")

    // Now that you have all the good stuff you can do whatever you want

    // Getting certificates is really easy
    publicKeys, _ := client.GetCertificates();

    // This method returns the certificate with BEGIN and END
    publicKeys[0].GetCertificate();

    // Property of the struct and is without the BEGIN and END
    publicKeys[0].Key;

}

Happy hacking

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DiscoveryDocument

type DiscoveryDocument struct {
	RequestParameterSupported                  bool     `json:"request_parameter_supported"`
	IDTokenEncryptionAlgValuesSupported        []string `json:"id_token_encryption_alg_values_supported"`
	RegistrationEndpoint                       string   `json:"registration_endpoint"`
	UserinfoSigningAlgValuesSupported          []string `json:"userinfo_signing_alg_values_supported"`
	TokenEndpoint                              string   `json:"token_endpoint"`
	RequestURIParameterSupported               bool     `json:"request_uri_parameter_supported"`
	RequestObjectEncryptionEncValuesSupported  []string `json:"request_object_encryption_enc_values_supported"`
	TokenEndpointAuthMethodsSupported          []string `json:"token_endpoint_auth_methods_supported"`
	UserinfoEncryptionAlgValuesSupported       []string `json:"userinfo_encryption_alg_values_supported"`
	SubjectTypesSupported                      []string `json:"subject_types_supported"`
	IDTokenEncryptionEncValuesSupported        []string `json:"id_token_encryption_enc_values_supported"`
	ClaimsParameterSupported                   bool     `json:"claims_parameter_supported"`
	JwksURI                                    string   `json:"jwks_uri"`
	IDTokenSigningAlgValuesSupported           []string `json:"id_token_signing_alg_values_supported"`
	AuthorizationEndpoint                      string   `json:"authorization_endpoint"`
	RequireRequestURIRegistration              bool     `json:"require_request_uri_registration"`
	IntrospectionEndpoint                      string   `json:"introspection_endpoint"`
	RequestObjectEncryptionAlgValuesSupported  []string `json:"request_object_encryption_alg_values_supported"`
	ServiceDocumentation                       string   `json:"service_documentation"`
	ResponseTypesSupported                     []string `json:"response_types_supported"`
	TokenEndpointAuthSigningAlgValuesSupported []string `json:"token_endpoint_auth_signing_alg_values_supported"`
	RevocationEndpoint                         string   `json:"revocation_endpoint"`
	RequestObjectSigningAlgValuesSupported     []string `json:"request_object_signing_alg_values_supported"`
	ClaimTypesSupported                        []string `json:"claim_types_supported"`
	GrantTypesSupported                        []string `json:"grant_types_supported"`
	ScopesSupported                            []string `json:"scopes_supported"`
	UserinfoEndpoint                           string   `json:"userinfo_endpoint"`
	UserinfoEncryptionEncValuesSupported       []string `json:"userinfo_encryption_enc_values_supported"`
	OpTosURI                                   string   `json:"op_tos_uri"`
	Issuer                                     string   `json:"issuer"`
	OpPolicyURI                                string   `json:"op_policy_uri"`
	ClaimsSupported                            []string `json:"claims_supported"`
}

DiscoveryDocument is the discovery document structure

type JwksEndpointResponse

type JwksEndpointResponse struct {
	Keys []struct {
		Kid     string   `json:"kid"`
		Kty     string   `json:"kty"`
		Alg     string   `json:"alg"`
		Use     string   `json:"use"`
		N       string   `json:"n"`
		E       string   `json:"e"`
		X5C     []string `json:"x5c"`
		X5T     string   `json:"x5t"`
		X5TS256 string   `json:"x5t#S256"`
	} `json:"keys"`
}

JwksEndpointResponse is the response from the JWKS-endoint

type OidcDiscoveryClient

type OidcDiscoveryClient struct {
	// contains filtered or unexported fields
}

OidcDiscoveryClient describes a OIDC Configuration of a given authority

func NewOidcDiscoveryClient

func NewOidcDiscoveryClient(authorityUrl string) (*OidcDiscoveryClient, error)

NewOidcDiscoveryClient instantiates a new confiuration

func (*OidcDiscoveryClient) DiscoveryDocument

func (c *OidcDiscoveryClient) DiscoveryDocument() DiscoveryDocument

DiscoveryDocument returns the current discovery document

func (*OidcDiscoveryClient) GetCertificates

func (c *OidcDiscoveryClient) GetCertificates() ([]PublicKey, error)

GetCertificates gets the certificates and returns a handy struct

type PublicKey

type PublicKey struct {
	Key string
	Kid string
	Alg string
}

func (*PublicKey) GetCertificate

func (p *PublicKey) GetCertificate() string

GetCertificate the key in the public key is without the BEGIN and END. This function returns a valid certificate

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL