hydra

package
v0.0.0-...-271f870 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LOGIN_REQ   reqType = "login"
	CONSENT_REQ reqType = "consent"
)
View Source
const (
	ACCEPT_VERB reqVerb = "/accept"
	GET_VERB    reqVerb = ""
)

Variables

View Source
var (
	// ErrChallengeMissed is an error that happens when a challenge is missed.
	ErrChallengeMissed = errors.New("challenge missed")
	// ErrUnauthenticated is an error that happens when authentication is failed.
	ErrUnauthenticated = errors.New("unauthenticated")
	// ErrChallengeNotFound is an error that happens when an unknown challenge is used.
	ErrChallengeNotFound = errors.New("challenge not found")
	// ErrChallengeExpired is an error that happens when a challenge is already used.
	ErrChallengeExpired = errors.New("challenge expired")
)

Functions

func AcceptConsentRequest

func AcceptConsentRequest(ctx context.Context, cfg *Config, challenge string, remember bool, grantScope []string, claims *Claim) (string, error)

func AcceptLoginRequest

func AcceptLoginRequest(ctx context.Context, cfg *Config, remember bool, subject, challenge string) (string, error)

func GenericError

func GenericError(ctx context.Context, body io.ReadCloser) error

Types

type Claim

type Claim struct {
	Details map[string]string
	Roles   []string
}

func FilterClaims

func FilterClaims(cfg *Config, claims *Claim, requestedScopes []string) *Claim

type ClientInfo

type ClientInfo struct {
	Id   string `json:"client_id"`
	Name string `json:"client_name"`
}

type Config

type Config struct {
	Url         string
	SessionTTL  time.Duration
	ClaimScopes []string
}

func (*Config) ParsedClaimScopes

func (c *Config) ParsedClaimScopes() (map[string][]string, error)

func (*Config) ParsedUrl

func (c *Config) ParsedUrl() *url.URL

func (*Config) RememberFor

func (c *Config) RememberFor() int

func (*Config) Validate

func (c *Config) Validate() error

type HttpClient

type HttpClient struct {
	Cfg *Config
	Ctx context.Context
}

func (*HttpClient) Delete

func (client *HttpClient) Delete(u *url.URL) (*http.Response, error)

func (*HttpClient) Get

func (client *HttpClient) Get(u *url.URL) (*http.Response, error)

func (*HttpClient) GetContext

func (client *HttpClient) GetContext() context.Context

func (*HttpClient) PutJSON

func (client *HttpClient) PutJSON(u *url.URL, body io.Reader) (*http.Response, error)

type HttpClientInterface

type HttpClientInterface interface {
	PutJSON(u *url.URL, body io.Reader) (*http.Response, error)
	Get(u *url.URL) (*http.Response, error)
	Delete(u *url.URL) (*http.Response, error)
	GetContext() context.Context
}

type HydraResp

type HydraResp struct {
	Challenge       string     `json:"challenge"`
	RequestedScopes []string   `json:"requested_scope"`
	Skip            bool       `json:"skip"`
	Subject         string     `json:"subject"`
	Client          ClientInfo `json:"client"`
}

HydraResp contains response from Hydra

func GetConsentRequest

func GetConsentRequest(ctx context.Context, cfg *Config, challenge string) (*HydraResp, error)

func GetLoginRequest

func GetLoginRequest(ctx context.Context, cfg *Config, challenge string) (*HydraResp, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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