hydra

package
v0.8.6 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2020 License: Apache-2.0 Imports: 12 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 ConsentSkip

func ConsentSkip(r *http.Request, client *http.Client, consent *hydraapi.ConsentRequest, hydraAdminURL, challenge string) (bool, string, error)

ConsentSkip if hydra was already able to consent the user, skip will be true and we do not need to re-consent the user. Returns whether a consent is required and redirect address for the conset page.

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 ExtractIdentitiesInConsent

func ExtractIdentitiesInConsent(consent *hydraapi.ConsentRequest) ([]string, *status.Status)

ExtractIdentitiesInConsent extracts identities in ConsentRequest Context.

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 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 LoginSkip

func LoginSkip(w http.ResponseWriter, r *http.Request, client *http.Client, login *hydraapi.LoginRequest, hydraAdminURL, challenge string) bool

LoginSkip if hydra was already able to authenticate the user, skip will be true and we do not need to re-authenticate the user.

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 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