Documentation
¶
Index ¶
- Constants
- func Content(body string) functional.OptionWithError[HttpResponse]
- func ContentTypeUrlFormEncoded() map[string]string
- func CreateAuthorizationHeader(params *HttpRequestParameters) (string, error)
- func CreateHttpClient(timeoutInS uint64, certAuth *tls.CertificateAuthentication) (*http.Client, error)
- func Headers(headers http.Header) functional.OptionWithError[HttpResponse]
- func IsSuccessfulBasedOnSuccessResponseCodes(statusCode int, successResponseCodes []string) functional.OptionWithError[HttpResponse]
- func Method(method string) functional.OptionWithError[HttpResponse]
- func ResponseBodyTransformer(transformer string) functional.OptionWithError[HttpResponse]
- func StatusCode(code int) functional.OptionWithError[HttpResponse]
- func Time(time int64) functional.OptionWithError[HttpResponse]
- func Url(url string) functional.OptionWithError[HttpResponse]
- func WithAuthorizationHeader(h string) functional.OptionWithError[HttpRequestParameters]
- func WithBody(b string) functional.OptionWithError[HttpRequestParameters]
- func WithCertificateAuthentication(cauth *tls.CertificateAuthentication) functional.OptionWithError[HttpRequestParameters]
- func WithClientId(id string) functional.OptionWithError[HttpRequestParameters]
- func WithClientSecret(s string) functional.OptionWithError[HttpRequestParameters]
- func WithCsrfUrl(u string) functional.OptionWithError[HttpRequestParameters]
- func WithHeaders(h map[string]string) functional.OptionWithError[HttpRequestParameters]
- func WithPassword(p string) functional.OptionWithError[HttpRequestParameters]
- func WithRefreshToken(rt string) functional.OptionWithError[HttpRequestParameters]
- func WithSucceedOnTimeout(s bool) functional.OptionWithError[HttpRequestParameters]
- func WithSuccessResponseCodes(src []string) functional.OptionWithError[HttpRequestParameters]
- func WithTimeout(t uint64) functional.OptionWithError[HttpRequestParameters]
- func WithTokenUrl(u string) functional.OptionWithError[HttpRequestParameters]
- func WithUser(u string) functional.OptionWithError[HttpRequestParameters]
- type AuthorizationHeaderGenerator
- type CacheableAuthorizationHeaderGenerator
- type GrantType
- type HttpExecutor
- type HttpHeaders
- type HttpRequestExecutor
- type HttpRequestParameters
- func (p HttpRequestParameters) GetAuthorizationHeader() string
- func (p HttpRequestParameters) GetCertificateAuthentication() *tls.CertificateAuthentication
- func (p HttpRequestParameters) GetClientId() string
- func (p HttpRequestParameters) GetClientSecret() string
- func (p HttpRequestParameters) GetCsrfUrl() string
- func (p HttpRequestParameters) GetPassword() string
- func (p HttpRequestParameters) GetRefreshToken() string
- func (p HttpRequestParameters) GetTokenUrl() string
- func (p HttpRequestParameters) GetUser() string
- type HttpResponse
- type IllegalTokenTypeError
- type OAuthToken
- type OAuthorizationHeaderOption
- func UseCertificateAuthentication(certAuthentication *tls.CertificateAuthentication) OAuthorizationHeaderOption
- func WithAuthenticationHeader(header string) OAuthorizationHeaderOption
- func WithCacheStore(store map[string]string) OAuthorizationHeaderOption
- func WithCachingKey(cacheKey string) OAuthorizationHeaderOption
- type TokenFetcher
- type TokenType
Constants ¶
View Source
const ( AuthorizationHeaderName = "Authorization" IasTokenUrlPattern = "^https:\\/\\/(accounts\\.sap\\.com|[A-Za-z0-9+]+\\.accounts400\\.ondemand\\.com|[A-Za-z0-9+]+\\.accounts\\.ondemand\\.com)" )
View Source
const ( METHOD string = "method" URL string = "url" TOKEN_URL string = "tokenUrl" CSRF_URL string = "csrfUrl" CLIENT_ID string = "clientId" CLIENT_SECRET string = "clientSecret" REFRESH_TOKEN string = "refreshToken" RESPONSE_BODY_TRANSFORMER string = "responseBodyTransformer" HEADERS string = "headers" BODY string = "body" USER string = "user" PASSWORD string = "password" TIMEOUT string = "timeout" SUCCESS_RESPONSE_CODES string = "successResponseCodes" SUCCEED_ON_TIMEOUT string = "succeedOnTimeout" TRUSTED_CERTS string = "trustedCerts" CLIENT_CERT string = "clientCert" TRUST_ANY_CERT string = "trustAnyCert" AUTHORIZATION_HEADER string = "authorizationHeader" )
View Source
const ( CACHING_KEY_FORMAT string = "tokenUrl=%s&oAuthUser=%s&oAuthPwd=%s&getTokenBody=%s" PASSWORD_GRANT_FORMAT string = "grant_type=password&username=%s&password=%s" PASSWORD_CREDENTIALS_FORMAT_WITH_CLIENT_ID string = "grant_type=password&client_id=%s&username=%s&password=%s" CLIENT_CREDENTIALS_FORMAT string = "grant_type=client_credentials&client_id=%s&client_secret=%s" REFRESH_TOKEN_FORMAT string = "grant_type=refresh_token&refresh_token=%s" REFRESH_TOKEN_FORMAT_WITH_CERT string = "grant_type=refresh_token&client_id=%s&refresh_token=%s" )
View Source
const CsrfVerb = "fetch"
View Source
const (
DefaultHttpRequestTimeout = 3 * time.Second
)
View Source
const PASSCODE string = "passcode"
Variables ¶
This section is empty.
Functions ¶
func Content ¶
func Content(body string) functional.OptionWithError[HttpResponse]
func CreateAuthorizationHeader ¶
func CreateAuthorizationHeader(params *HttpRequestParameters) (string, error)
func CreateHttpClient ¶
func Headers ¶
func Headers(headers http.Header) functional.OptionWithError[HttpResponse]
func IsSuccessfulBasedOnSuccessResponseCodes ¶
func IsSuccessfulBasedOnSuccessResponseCodes(statusCode int, successResponseCodes []string) functional.OptionWithError[HttpResponse]
func Method ¶
func Method(method string) functional.OptionWithError[HttpResponse]
func ResponseBodyTransformer ¶ added in v0.0.3
func ResponseBodyTransformer(transformer string) functional.OptionWithError[HttpResponse]
func StatusCode ¶
func StatusCode(code int) functional.OptionWithError[HttpResponse]
func Time ¶
func Time(time int64) functional.OptionWithError[HttpResponse]
func Url ¶
func Url(url string) functional.OptionWithError[HttpResponse]
func WithAuthorizationHeader ¶
func WithAuthorizationHeader(h string) functional.OptionWithError[HttpRequestParameters]
func WithBody ¶
func WithBody(b string) functional.OptionWithError[HttpRequestParameters]
func WithCertificateAuthentication ¶
func WithCertificateAuthentication(cauth *tls.CertificateAuthentication) functional.OptionWithError[HttpRequestParameters]
func WithClientId ¶
func WithClientId(id string) functional.OptionWithError[HttpRequestParameters]
func WithClientSecret ¶
func WithClientSecret(s string) functional.OptionWithError[HttpRequestParameters]
func WithCsrfUrl ¶
func WithCsrfUrl(u string) functional.OptionWithError[HttpRequestParameters]
func WithHeaders ¶
func WithHeaders(h map[string]string) functional.OptionWithError[HttpRequestParameters]
func WithPassword ¶
func WithPassword(p string) functional.OptionWithError[HttpRequestParameters]
func WithRefreshToken ¶
func WithRefreshToken(rt string) functional.OptionWithError[HttpRequestParameters]
func WithSucceedOnTimeout ¶
func WithSucceedOnTimeout(s bool) functional.OptionWithError[HttpRequestParameters]
func WithSuccessResponseCodes ¶
func WithSuccessResponseCodes(src []string) functional.OptionWithError[HttpRequestParameters]
func WithTimeout ¶
func WithTimeout(t uint64) functional.OptionWithError[HttpRequestParameters]
func WithTokenUrl ¶
func WithTokenUrl(u string) functional.OptionWithError[HttpRequestParameters]
func WithUser ¶
func WithUser(u string) functional.OptionWithError[HttpRequestParameters]
Types ¶
type AuthorizationHeaderGenerator ¶
func NewBasicAuthorizationHeader ¶
func NewBasicAuthorizationHeader(u string, p string) AuthorizationHeaderGenerator
func NewIasAuthorizationHeader ¶
func NewIasAuthorizationHeader(tokenUrl, user, clientCert string) AuthorizationHeaderGenerator
type CacheableAuthorizationHeaderGenerator ¶ added in v0.0.4
type CacheableAuthorizationHeaderGenerator interface { AuthorizationHeaderGenerator GenerateWithCacheAside() (string, error) }
func NewOAuthHeaderGenerator ¶
func NewOAuthHeaderGenerator(p *HttpRequestParameters) CacheableAuthorizationHeaderGenerator
func NewOAuthorizationHeaderGenerator ¶ added in v0.0.4
func NewOAuthorizationHeaderGenerator(tokenType TokenType, tokenUrl string, executor HttpExecutor, requestBody string, opts ...OAuthorizationHeaderOption) CacheableAuthorizationHeaderGenerator
type HttpExecutor ¶
type HttpExecutor interface {
ExecuteWithParameters(*HttpRequestParameters) (*HttpResponse, error)
}
type HttpHeaders ¶
func (HttpHeaders) String ¶ added in v0.0.4
func (h HttpHeaders) String() string
type HttpRequestExecutor ¶
func NewDefaultHttpRequestExecutor ¶ added in v0.0.4
func NewDefaultHttpRequestExecutor() *HttpRequestExecutor
func (*HttpRequestExecutor) Execute ¶
func (e *HttpRequestExecutor) Execute(ctx executors.Context) *executors.ExecutorResult
func (*HttpRequestExecutor) ExecuteWithParameters ¶
func (e *HttpRequestExecutor) ExecuteWithParameters(p *HttpRequestParameters) (*HttpResponse, error)
type HttpRequestParameters ¶
type HttpRequestParameters struct {
// contains filtered or unexported fields
}
func NewHttpRequestParameters ¶
func NewHttpRequestParameters(method, url string, opts ...functional.OptionWithError[HttpRequestParameters]) (*HttpRequestParameters, error)
func NewHttpRequestParametersFromContext ¶
func NewHttpRequestParametersFromContext(ctx executors.Context) (*HttpRequestParameters, error)
func (HttpRequestParameters) GetAuthorizationHeader ¶
func (p HttpRequestParameters) GetAuthorizationHeader() string
func (HttpRequestParameters) GetCertificateAuthentication ¶
func (p HttpRequestParameters) GetCertificateAuthentication() *tls.CertificateAuthentication
func (HttpRequestParameters) GetClientId ¶
func (p HttpRequestParameters) GetClientId() string
func (HttpRequestParameters) GetClientSecret ¶
func (p HttpRequestParameters) GetClientSecret() string
func (HttpRequestParameters) GetCsrfUrl ¶
func (p HttpRequestParameters) GetCsrfUrl() string
func (HttpRequestParameters) GetPassword ¶
func (p HttpRequestParameters) GetPassword() string
func (HttpRequestParameters) GetRefreshToken ¶
func (p HttpRequestParameters) GetRefreshToken() string
func (HttpRequestParameters) GetTokenUrl ¶
func (p HttpRequestParameters) GetTokenUrl() string
func (HttpRequestParameters) GetUser ¶
func (p HttpRequestParameters) GetUser() string
type HttpResponse ¶
type HttpResponse struct { Url string `json:"url"` Method string `json:"method"` Content string `json:"body"` Headers HttpHeaders `json:"headers"` StatusCode string `json:"status"` SizeInBytes uint64 `json:"size"` Time int64 `json:"time"` ResponseBodyTransformer string `json:"responseBodyTransformer"` // contains filtered or unexported fields }
func NewHttpResponse ¶
func NewHttpResponse(opts ...functional.OptionWithError[HttpResponse]) (*HttpResponse, error)
func (HttpResponse) ToMap ¶
func (r HttpResponse) ToMap() map[string]string
type IllegalTokenTypeError ¶
type IllegalTokenTypeError struct {
// contains filtered or unexported fields
}
func NewIllegalTokenTypeError ¶
func NewIllegalTokenTypeError(tokenType TokenType) *IllegalTokenTypeError
func (*IllegalTokenTypeError) Error ¶
func (e *IllegalTokenTypeError) Error() string
type OAuthToken ¶
type OAuthToken struct { TokenType string `json:"token_type"` AccessToken string `json:"access_token"` IdToken string `json:"id_token,omitempty"` ExpiresIn int64 `json:"expires_in,omitempty"` }
func NewOAuthToken ¶
func NewOAuthToken(token string) (*OAuthToken, error)
type OAuthorizationHeaderOption ¶ added in v0.0.4
type OAuthorizationHeaderOption func(*oAuthorizationHeaderGenerator)
func UseCertificateAuthentication ¶
func UseCertificateAuthentication(certAuthentication *tls.CertificateAuthentication) OAuthorizationHeaderOption
func WithAuthenticationHeader ¶ added in v0.0.4
func WithAuthenticationHeader(header string) OAuthorizationHeaderOption
func WithCacheStore ¶ added in v0.0.6
func WithCacheStore(store map[string]string) OAuthorizationHeaderOption
func WithCachingKey ¶ added in v0.0.4
func WithCachingKey(cacheKey string) OAuthorizationHeaderOption
type TokenFetcher ¶
func NewCsrfTokenFetcher ¶
func NewCsrfTokenFetcher(p *HttpRequestParameters, authHeader string) TokenFetcher
func NewIasTokenFetcher ¶
func NewIasTokenFetcher(tokenUrl, user, clientCert string) TokenFetcher
func NewOAuthTokenFetcher ¶
func NewOAuthTokenFetcher(opts ...functional.Option[oAuthTokenFetcher]) TokenFetcher
Source Files
¶
- authorization_header.go
- basic_authorization_header.go
- csrf_token_fetcher.go
- errors.go
- generator.go
- grant_type.go
- http_client.go
- http_executor.go
- http_executor_parameters.go
- http_response.go
- ias_authorization_header.go
- ias_token_fetcher.go
- oauth_header_generator.go
- oauth_header_generator_factory.go
- oauth_token.go
- oauth_token_fetcher.go
- token_fetcher.go
- token_type.go
Click to show internal directories.
Click to hide internal directories.