hydra

package
v0.9.15 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package hydra contains helpers for using hydra

Index

Constants

View Source
const (
	// StateIDKey uses to store stateID in hydra context.
	StateIDKey = "state"
)

Variables

This section is empty.

Functions

func AcceptConsent

func AcceptConsent(client *http.Client, hydraAdminURL, challenge string, r *hydraapi.HandledConsentRequest) (*hydraapi.RequestHandlerResponse, error)

AcceptConsent tells hydra to accept a consent request.

func AcceptLogin

func AcceptLogin(client *http.Client, hydraAdminURL, challenge string, r *hydraapi.HandledLoginRequest) (*hydraapi.RequestHandlerResponse, error)

AcceptLogin tells hydra to accept a login request.

func CreateClient

func CreateClient(client *http.Client, hydraAdminURL string, oauthClient *hydraapi.Client) (*hydraapi.Client, error)

CreateClient creates OAuth client in hydra.

func DeleteClient

func DeleteClient(client *http.Client, hydraAdminURL, id string) error

DeleteClient delete an existing OAuth 2.0 Client by its ID.

func ExtractConsentChallenge

func ExtractConsentChallenge(r *http.Request) (string, *status.Status)

ExtractConsentChallenge extracts consent_challenge from request.

func ExtractLoginChallenge

func ExtractLoginChallenge(r *http.Request) (string, *status.Status)

ExtractLoginChallenge extracts login_challenge from request.

func ExtractStateIDInConsent

func ExtractStateIDInConsent(consent *hydraapi.ConsentRequest) (string, *status.Status)

ExtractStateIDInConsent extracts stateID in ConsentRequest Context.

func ExtractTokenIDInConsentSession added in v0.9.3

func ExtractTokenIDInConsentSession(session *hydraapi.PreviousConsentSession) (string, error)

ExtractTokenIDInConsentSession finds token id in consent session.

func ExtractTokenIDInIntrospect added in v0.8.6

func ExtractTokenIDInIntrospect(in *hydraapi.Introspection) (string, error)

ExtractTokenIDInIntrospect finds token id in introspect result, return error if not found or in wront type.

func GetClient

func GetClient(client *http.Client, hydraAdminURL, id string) (*hydraapi.Client, error)

GetClient gets an OAUth 2.0 client by its ID.

func GetConsentRequest

func GetConsentRequest(client *http.Client, hydraAdminURL, challenge string) (*hydraapi.ConsentRequest, error)

GetConsentRequest fetches information on a consent request.

func GetLoginRequest

func GetLoginRequest(client *http.Client, hydraAdminURL, challenge string) (*hydraapi.LoginRequest, error)

GetLoginRequest fetches information on a login request.

func Introspect

func Introspect(client *http.Client, hydraAdminURL, token string) (*hydraapi.Introspection, error)

Introspect token, validate the given token and return token claims.

func ListClients

func ListClients(client *http.Client, hydraAdminURL string) ([]*hydraapi.Client, error)

ListClients list all OAuth clients in hydra.

func ListConsents

func ListConsents(client *http.Client, hydraAdminURL, subject string) ([]*hydraapi.PreviousConsentSession, error)

ListConsents lists all consents of user (subject).

func LoginSuccess added in v0.8.6

func LoginSuccess(r *http.Request, client *http.Client, hydraAdminURL, challenge, subject, stateID string, extra map[string]interface{}) (string, error)

LoginSuccess is the redirect for successful login.

func NormalizeIdentity added in v0.8.6

func NormalizeIdentity(id *ga4gh.Identity) *ga4gh.Identity

NormalizeIdentity converts hydra special format in access token to ga4gh.Identity 1. move "scp" to "scope" 2. move "extra.identities" to "identities"

func RejectConsent

func RejectConsent(client *http.Client, hydraAdminURL, challenge string, r *hydraapi.RequestDeniedError) (*hydraapi.RequestHandlerResponse, error)

RejectConsent tells hydra to rejects a consent request.

func RejectLogin

func RejectLogin(client *http.Client, hydraAdminURL, challenge string, r *hydraapi.RequestDeniedError) (*hydraapi.RequestHandlerResponse, error)

RejectLogin tells hydra to reject a login request.

func RevokeConsents

func RevokeConsents(client *http.Client, hydraAdminURL, subject, clientID string) error

RevokeConsents revokes all consents of user for a client. clientID is optional, will revoke all consent of user if no clientID.

func RevokeToken added in v0.8.6

func RevokeToken(client *http.Client, hydraAdminURL, token string) error

RevokeToken revokes the given token, token maybe refresh token or access token.

func SendConsentReject added in v0.8.8

func SendConsentReject(w http.ResponseWriter, r *http.Request, client *http.Client, hydraAdminURL, challenge string, err error)

SendConsentReject to hydra, requires a status err.

func SendLoginReject added in v0.8.8

func SendLoginReject(w http.ResponseWriter, r *http.Request, client *http.Client, hydraAdminURL, challenge string, err error)

SendLoginReject to hydra, requires a status err.

func SendLoginSuccess

func SendLoginSuccess(w http.ResponseWriter, r *http.Request, client *http.Client, hydraAdminURL, challenge, subject, stateID string, extra map[string]interface{})

SendLoginSuccess sends login success to hydra.

func UpdateClient

func UpdateClient(client *http.Client, hydraAdminURL, id string, oauthClient *hydraapi.Client) (*hydraapi.Client, error)

UpdateClient updates an existing OAuth 2.0 Client.

Types

This section is empty.

Jump to

Keyboard shortcuts

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