introspection

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package introspection provides structures and functions to implement the additional OAuth2 Token Introspection specification.

Index

Constants

View Source
const (
	AccessToken  = "access_token"
	RefreshToken = "refresh_token"
)

The known OAuth2 token types.

Variables

This section is empty.

Functions

func KnownTokenType

func KnownTokenType(str string) bool

KnownTokenType returns true if the token type is a known token type (e.g. access token or refresh token).

func UnsupportedTokenType

func UnsupportedTokenType(description string) *oauth2.Error

UnsupportedTokenType constructs an error that indicates that the authorization server does not support the introspection of the presented token type.

func WriteResponse

func WriteResponse(w http.ResponseWriter, r *Response) error

WriteResponse will write a response to the response writer.

Types

type Request

type Request struct {
	Token         string
	TokenTypeHint string
	ClientID      string
	ClientSecret  string

	HTTP *http.Request
}

A Request is typically returned by ParseRequest and holds all information necessary to handle an introspection request.

func ParseRequest

func ParseRequest(r *http.Request) (*Request, error)

ParseRequest parses an incoming request and returns a Request. The functions validates basic constraints given by the OAuth2 spec.

type Response

type Response struct {
	Active     bool   `json:"active"`
	Scope      string `json:"scope,omitempty"`
	ClientID   string `json:"client_id,omitempty"`
	Username   string `json:"username,omitempty"`
	TokenType  string `json:"token_type,omitempty"`
	ExpiresAt  int64  `json:"exp,omitempty"`
	IssuedAt   int64  `json:"iat,omitempty"`
	NotBefore  int64  `json:"nbf,omitempty"`
	Subject    string `json:"sub,omitempty"`
	Audience   string `json:"aud,omitempty"`
	Issuer     string `json:"iss,omitempty"`
	Identifier string `json:"jti,omitempty"`

	Extra map[string]interface{} `json:"extra,omitempty"`
}

Response is a response returned by the token introspection endpoint.

func NewResponse

func NewResponse(active bool, scope, clientID, username, tokenType string) *Response

NewResponse constructs a Response.

Jump to

Keyboard shortcuts

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