hydra/internal/httpclient
aeneasr 282dedb432
feat: add CHIPS (partitioned) cookies
2024-03-01 06:09:17 +01:00
..
.openapi-generator chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
api chore: improve context (#3656) 2024-01-31 09:35:17 +01:00
docs chore: improve context (#3656) 2024-01-31 09:35:17 +01:00
.gitignore fix: remove goswagger generated client 2022-09-07 08:10:31 +02:00
.openapi-generator-ignore fix: remove goswagger generated client 2022-09-07 08:10:31 +02:00
.travis.yml autogen(openapi): regenerate swagger spec and internal client 2022-11-03 15:13:26 +00:00
README.md chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
api_jwk.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
api_metadata.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
api_o_auth2.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
api_oidc.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
api_wellknown.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
client.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
configuration.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
git_push.sh chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
go.mod autogen(openapi): regenerate swagger spec and internal client 2024-02-12 10:12:17 +00:00
go.sum feat: add CHIPS (partitioned) cookies 2024-03-01 06:09:17 +01:00
model_accept_o_auth2_consent_request.go autogen(openapi): regenerate swagger spec and internal client 2024-01-31 08:36:47 +00:00
model_accept_o_auth2_consent_request_session.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
model_accept_o_auth2_login_request.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
model_create_json_web_key_set.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
model_create_verifiable_credential_request_body.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
model_credential_supported_draft00.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
model_error_o_auth2.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
model_generic_error.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
model_get_version_200_response.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
model_health_not_ready_status.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
model_health_status.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
model_introspected_o_auth2_token.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
model_is_ready_200_response.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
model_is_ready_503_response.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
model_json_patch.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
model_json_web_key.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
model_json_web_key_set.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
model_o_auth2_client.go feat: add skip_logout_consent option to clients (#3705) 2024-01-30 16:19:34 +01:00
model_o_auth2_client_token_lifespans.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
model_o_auth2_consent_request.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
model_o_auth2_consent_request_open_id_connect_context.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
model_o_auth2_consent_session.go autogen(openapi): regenerate swagger spec and internal client 2024-01-31 08:36:47 +00:00
model_o_auth2_consent_session_expires_at.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
model_o_auth2_login_request.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
model_o_auth2_logout_request.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
model_o_auth2_redirect_to.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
model_o_auth2_token_exchange.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
model_oidc_configuration.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
model_oidc_user_info.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
model_pagination.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
model_pagination_headers.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
model_reject_o_auth2_request.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
model_rfc6749_error_json.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
model_token_pagination.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
model_token_pagination_headers.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
model_token_pagination_request_parameters.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
model_token_pagination_response_headers.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
model_trust_o_auth2_jwt_grant_issuer.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
model_trusted_o_auth2_jwt_grant_issuer.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
model_trusted_o_auth2_jwt_grant_json_web_key.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
model_verifiable_credential_priming_response.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
model_verifiable_credential_proof.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
model_verifiable_credential_response.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
model_version.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00
response.go fix: remove goswagger generated client 2022-09-07 08:10:31 +02:00
utils.go chore: bump openapi-generator (#3696) 2024-01-22 12:32:35 +01:00

README.md

Go API client for openapi

Documentation for all of Ory Hydra's APIs.

Overview

This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.

  • API version:
  • Package version: 1.0.0
  • Build package: org.openapitools.codegen.languages.GoClientCodegen

Installation

Install the following dependencies:

go get github.com/stretchr/testify/assert
go get golang.org/x/oauth2
go get golang.org/x/net/context

Put the package under your project folder and add the following in import:

import openapi "github.com/ory/hydra-client-go/v2"

To use a proxy, set the environment variable HTTP_PROXY:

os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")

Configuration of Server URL

Default configuration comes with Servers field that contains server objects as defined in the OpenAPI specification.

Select Server Configuration

For using other server than the one defined on index 0 set context value openapi.ContextServerIndex of type int.

ctx := context.WithValue(context.Background(), openapi.ContextServerIndex, 1)

Templated Server URL

Templated server URL is formatted using default variables from configuration or from context value openapi.ContextServerVariables of type map[string]string.

ctx := context.WithValue(context.Background(), openapi.ContextServerVariables, map[string]string{
	"basePath": "v2",
})

Note, enum values are always validated and all unused variables are silently ignored.

URLs Configuration per Operation

Each operation can use different server URL defined using OperationServers map in the Configuration. An operation is uniquely identified by "{classname}Service.{nickname}" string. Similar rules for overriding default operation server index and variables applies by using openapi.ContextOperationServerIndices and openapi.ContextOperationServerVariables context maps.

ctx := context.WithValue(context.Background(), openapi.ContextOperationServerIndices, map[string]int{
	"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), openapi.ContextOperationServerVariables, map[string]map[string]string{
	"{classname}Service.{nickname}": {
		"port": "8443",
	},
})

Documentation for API Endpoints

All URIs are relative to http://localhost

Class Method HTTP request Description
JwkApi CreateJsonWebKeySet Post /admin/keys/{set} Create JSON Web Key
JwkApi DeleteJsonWebKey Delete /admin/keys/{set}/{kid} Delete JSON Web Key
JwkApi DeleteJsonWebKeySet Delete /admin/keys/{set} Delete JSON Web Key Set
JwkApi GetJsonWebKey Get /admin/keys/{set}/{kid} Get JSON Web Key
JwkApi GetJsonWebKeySet Get /admin/keys/{set} Retrieve a JSON Web Key Set
JwkApi SetJsonWebKey Put /admin/keys/{set}/{kid} Set JSON Web Key
JwkApi SetJsonWebKeySet Put /admin/keys/{set} Update a JSON Web Key Set
MetadataApi GetVersion Get /version Return Running Software Version.
MetadataApi IsAlive Get /health/alive Check HTTP Server Status
MetadataApi IsReady Get /health/ready Check HTTP Server and Database Status
OAuth2Api AcceptOAuth2ConsentRequest Put /admin/oauth2/auth/requests/consent/accept Accept OAuth 2.0 Consent Request
OAuth2Api AcceptOAuth2LoginRequest Put /admin/oauth2/auth/requests/login/accept Accept OAuth 2.0 Login Request
OAuth2Api AcceptOAuth2LogoutRequest Put /admin/oauth2/auth/requests/logout/accept Accept OAuth 2.0 Session Logout Request
OAuth2Api CreateOAuth2Client Post /admin/clients Create OAuth 2.0 Client
OAuth2Api DeleteOAuth2Client Delete /admin/clients/{id} Delete OAuth 2.0 Client
OAuth2Api DeleteOAuth2Token Delete /admin/oauth2/tokens Delete OAuth 2.0 Access Tokens from specific OAuth 2.0 Client
OAuth2Api DeleteTrustedOAuth2JwtGrantIssuer Delete /admin/trust/grants/jwt-bearer/issuers/{id} Delete Trusted OAuth2 JWT Bearer Grant Type Issuer
OAuth2Api GetOAuth2Client Get /admin/clients/{id} Get an OAuth 2.0 Client
OAuth2Api GetOAuth2ConsentRequest Get /admin/oauth2/auth/requests/consent Get OAuth 2.0 Consent Request
OAuth2Api GetOAuth2LoginRequest Get /admin/oauth2/auth/requests/login Get OAuth 2.0 Login Request
OAuth2Api GetOAuth2LogoutRequest Get /admin/oauth2/auth/requests/logout Get OAuth 2.0 Session Logout Request
OAuth2Api GetTrustedOAuth2JwtGrantIssuer Get /admin/trust/grants/jwt-bearer/issuers/{id} Get Trusted OAuth2 JWT Bearer Grant Type Issuer
OAuth2Api IntrospectOAuth2Token Post /admin/oauth2/introspect Introspect OAuth2 Access and Refresh Tokens
OAuth2Api ListOAuth2Clients Get /admin/clients List OAuth 2.0 Clients
OAuth2Api ListOAuth2ConsentSessions Get /admin/oauth2/auth/sessions/consent List OAuth 2.0 Consent Sessions of a Subject
OAuth2Api ListTrustedOAuth2JwtGrantIssuers Get /admin/trust/grants/jwt-bearer/issuers List Trusted OAuth2 JWT Bearer Grant Type Issuers
OAuth2Api OAuth2Authorize Get /oauth2/auth OAuth 2.0 Authorize Endpoint
OAuth2Api Oauth2TokenExchange Post /oauth2/token The OAuth 2.0 Token Endpoint
OAuth2Api PatchOAuth2Client Patch /admin/clients/{id} Patch OAuth 2.0 Client
OAuth2Api RejectOAuth2ConsentRequest Put /admin/oauth2/auth/requests/consent/reject Reject OAuth 2.0 Consent Request
OAuth2Api RejectOAuth2LoginRequest Put /admin/oauth2/auth/requests/login/reject Reject OAuth 2.0 Login Request
OAuth2Api RejectOAuth2LogoutRequest Put /admin/oauth2/auth/requests/logout/reject Reject OAuth 2.0 Session Logout Request
OAuth2Api RevokeOAuth2ConsentSessions Delete /admin/oauth2/auth/sessions/consent Revoke OAuth 2.0 Consent Sessions of a Subject
OAuth2Api RevokeOAuth2LoginSessions Delete /admin/oauth2/auth/sessions/login Revokes OAuth 2.0 Login Sessions by either a Subject or a SessionID
OAuth2Api RevokeOAuth2Token Post /oauth2/revoke Revoke OAuth 2.0 Access or Refresh Token
OAuth2Api SetOAuth2Client Put /admin/clients/{id} Set OAuth 2.0 Client
OAuth2Api SetOAuth2ClientLifespans Put /admin/clients/{id}/lifespans Set OAuth2 Client Token Lifespans
OAuth2Api TrustOAuth2JwtGrantIssuer Post /admin/trust/grants/jwt-bearer/issuers Trust OAuth2 JWT Bearer Grant Type Issuer
OidcApi CreateOidcDynamicClient Post /oauth2/register Register OAuth2 Client using OpenID Dynamic Client Registration
OidcApi CreateVerifiableCredential Post /credentials Issues a Verifiable Credential
OidcApi DeleteOidcDynamicClient Delete /oauth2/register/{id} Delete OAuth 2.0 Client using the OpenID Dynamic Client Registration Management Protocol
OidcApi DiscoverOidcConfiguration Get /.well-known/openid-configuration OpenID Connect Discovery
OidcApi GetOidcDynamicClient Get /oauth2/register/{id} Get OAuth2 Client using OpenID Dynamic Client Registration
OidcApi GetOidcUserInfo Get /userinfo OpenID Connect Userinfo
OidcApi RevokeOidcSession Get /oauth2/sessions/logout OpenID Connect Front- and Back-channel Enabled Logout
OidcApi SetOidcDynamicClient Put /oauth2/register/{id} Set OAuth2 Client using OpenID Dynamic Client Registration
WellknownApi DiscoverJsonWebKeys Get /.well-known/jwks.json Discover Well-Known JSON Web Keys

Documentation For Models

Documentation For Authorization

Authentication schemes defined for the API:

basic

  • Type: HTTP basic authentication

Example

auth := context.WithValue(context.Background(), openapi.ContextBasicAuth, openapi.BasicAuth{
	UserName: "username",
	Password: "password",
})
r, err := client.Service.Operation(auth, args)

bearer

  • Type: HTTP Bearer token authentication

Example

auth := context.WithValue(context.Background(), openapi.ContextAccessToken, "BEARER_TOKEN_STRING")
r, err := client.Service.Operation(auth, args)

oauth2

  • Type: OAuth
  • Flow: accessCode
  • Authorization URL: https://hydra.demo.ory.sh/oauth2/auth
  • Scopes:
  • offline: A scope required when requesting refresh tokens (alias for offline_access)
  • offline_access: A scope required when requesting refresh tokens
  • openid: Request an OpenID Connect ID Token

Example

auth := context.WithValue(context.Background(), openapi.ContextAccessToken, "ACCESSTOKENSTRING")
r, err := client.Service.Operation(auth, args)

Or via OAuth2 module to automatically refresh tokens and perform user authentication.

import "golang.org/x/oauth2"

/* Perform OAuth2 round trip request and obtain a token */

tokenSource := oauth2cfg.TokenSource(createContext(httpClient), &token)
auth := context.WithValue(oauth2.NoContext, openapi.ContextOAuth2, tokenSource)
r, err := client.Service.Operation(auth, args)

Documentation for Utility Methods

Due to the fact that model structure members are all pointers, this package contains a number of utility functions to easily obtain pointers to values of basic types. Each of these functions takes a value of the given basic type and returns a pointer to it:

  • PtrBool
  • PtrInt
  • PtrInt32
  • PtrInt64
  • PtrFloat
  • PtrFloat32
  • PtrFloat64
  • PtrString
  • PtrTime

Author

hi@ory.sh