idp

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuthorizeEndpoint           = "/authorize"
	TokenEndpoint               = "/oauth/token"
	WellKnownEndpoint           = "/.well-known"
	OpenIDConfigurationEndpoint = "/openid-configuration"
	JWKSEndpoint                = "/jwks.json"
	LoginEndpoint               = "/u/login"
)

Variables

This section is empty.

Functions

func Encode

func Encode(header *Header, c *ClaimSet, key *rsa.PrivateKey) (string, error)

Encode encodes a signed JWS with provided header and claim set. This invokes EncodeWithSigner using crypto/rsa.SignPKCS1v15 with the given RSA private key.

func EncodeWithSigner

func EncodeWithSigner(header *Header, c *ClaimSet, sg Signer) (string, error)

EncodeWithSigner encodes a header and claim set with the provided signer.

Types

type ClaimSet

type ClaimSet struct {
	Iss   string `json:"iss"`             // email address of the client_id of the application making the access token request
	Scope string `json:"scope,omitempty"` // space-delimited list of the permissions the application requests
	Aud   string `json:"aud"`             // descriptor of the intended target of the assertion (Optional).
	Exp   int64  `json:"exp"`             // the expiration time of the assertion (seconds since Unix epoch)
	Iat   int64  `json:"iat"`             // the time the assertion was issued (seconds since Unix epoch)
	Typ   string `json:"typ,omitempty"`   // token type (Optional).

	// Email for which the application is requesting delegated access (Optional).
	Sub string `json:"sub,omitempty"`

	// The old name of Sub. Client keeps setting Prn to be
	// complaint with legacy OAuth 2.0 providers. (Optional)
	Prn string `json:"prn,omitempty"`

	// See http://tools.ietf.org/html/draft-jones-json-web-token-10#section-4.3
	// This array is marshalled using custom code (see (c *ClaimSet) encode()).
	PrivateClaims map[string]interface{} `json:"-"`
}
type Header struct {
	// The algorithm used for signature.
	Algorithm string `json:"alg"`

	// Represents the token type.
	Typ string `json:"typ"`

	// The optional hint of which key is being used.
	KeyID string `json:"kid,omitempty"`
}

type IdentityProvider

type IdentityProvider struct {
	Issuer     string
	PrivateKey *rsa.PrivateKey
	// contains filtered or unexported fields
}

func NewIdpServer

func NewIdpServer() *IdentityProvider

func (*IdentityProvider) Run

func (idp *IdentityProvider) Run()

func (*IdentityProvider) ServeHTTP

func (idp *IdentityProvider) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Signer

type Signer func(data []byte) (sig []byte, err error)

Signer returns a signature for the given data.

Jump to

Keyboard shortcuts

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