akamai

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2023 License: MIT Imports: 12 Imported by: 0

README

akamai-sdk-go

Documentation

You can find detailed documentation and usage examples for the akamai-sdk-go library on GoDoc.

Installation

To install, use the go get command:

go get -u github.com/Hyper-Solutions/akamai-sdk-go

License

This project is licensed under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPixelHtmlVarNotFound   = errors.New("akamai-sdk-go: pixel HTML var not found")
	ErrPixelScriptUrlNotFound = errors.New("akamai-sdk-go: script URL not found")
	ErrPixelScriptVarNotFound = errors.New("akamai-sdk-go: script var not found")
)
View Source
var (
	ErrScriptPathNotFound = errors.New("akamai-sdk-go: script path not found")
)
View Source
var (
	ErrSecCpt = errors.New("akamai-sdk-go: error parsing sec-cpt page")
)

Functions

func IsCookieInvalidated

func IsCookieInvalidated(cookie string) bool

IsCookieInvalidated determines if the current session requires more sensors to be sent.

Protected endpoints can invalidate a session by setting a new _abck cookie that ends in '~0~-1~-1' or similar. This function returns if such an invalidated cookie is present, if it is present you should be able to make the cookie valid again with only 1 sensor post.

func IsCookieValid

func IsCookieValid(cookie string, requestCount int) bool

IsCookieValid determines if the provided _abck cookie value is valid, based on Akamai Bot Manager's client-side stop signal mechanism using the given request count. If the result is true, the client is ADVISED to halt further sensor data submissions. Submitting further would still produce a valid cookie but is unnecessary.

The stop signal mechanism in the Akamai Bot Manager's client-side script informs a client that the cookie received is valid and that any additional submissions are superfluous.

However, some applications do not activate the stop signal feature. In such scenarios, the client will continue submitting data whenever a trigger event occurs. Under these circumstances, verifying the authenticity of a cookie without sending it to a secured endpoint becomes challenging.

func ParsePixelHtmlVar

func ParsePixelHtmlVar(reader io.Reader) (int, error)

ParsePixelHtmlVar gets the required pixel challenge variable from the given HTML code src.

func ParsePixelScriptURL

func ParsePixelScriptURL(reader io.Reader) (string, string, error)

ParsePixelScriptURL gets the script URL of the pixel challenge script and the URL to post a generated payload to from the given HTML code src.

func ParsePixelScriptVar

func ParsePixelScriptVar(reader io.Reader) (string, error)

ParsePixelScriptVar gets the dynamic value from the pixel script

func ParseScriptPath

func ParseScriptPath(reader io.Reader) (string, error)

ParseScriptPath gets the Akamai Bot Manager web SDK path from the given HTML code src.

func ParseSecCpt

func ParseSecCpt(reader io.Reader) (int, string, error)

ParseSecCpt parses the duration of a sec-cpt challenge and the path of the page that contains the challenge itself

Types

type PixelInput

type PixelInput struct {
	UserAgent string `json:"userAgent"`
	HTMLVar   string `json:"htmlVar"`
	ScriptVar string `json:"scriptVar"`
}

type SensorInput

type SensorInput struct {
	Abck      string `json:"abck"`
	Bmsz      string `json:"bmsz"`
	Version   string `json:"version"`
	PageUrl   string `json:"pageUrl"`
	UserAgent string `json:"userAgent"`

	ScriptHash string `json:"scriptHash"`
}

type Session

type Session struct {
	// contains filtered or unexported fields
}

func NewSession

func NewSession(apiKey string) *Session

NewSession creates a new Session that can be used to make requests to the Hyper Solutions API.

func (*Session) GeneratePixelData

func (s *Session) GeneratePixelData(ctx context.Context, input *PixelInput) (string, error)

GeneratePixelData returns the pixel data using the Hyper Solutions API.

func (*Session) GenerateSensorData

func (s *Session) GenerateSensorData(ctx context.Context, input *SensorInput) (string, error)

GenerateSensorData returns the sensor data required to generate valid akamai cookies using the Hyper Solutions API.

func (*Session) WithClient

func (s *Session) WithClient(client *http.Client) *Session

WithClient sets a new client that will be used to make requests to the Hyper Solutions API.

func (*Session) WithJwtKey

func (s *Session) WithJwtKey(jwt string) *Session

WithJwtKey adds the JWT Key to the session. If not empty, a signature will be added to each request.

Jump to

Keyboard shortcuts

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