lib

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2019 License: Apache-2.0 Imports: 25 Imported by: 1

Documentation

Overview

This file implements helper functions to validate AWS Signature Version '4' authorization header.

This package provides comprehensive helpers for following signature types. - Based on Authorization header. - Based on Query parameters. - Based on Form POST policy.

Index

Constants

View Source
const (
	// BucketCannedACLPrivate is a BucketCannedACL enum value
	BucketCannedACLPrivate = "private"

	// BucketCannedACLPublicRead is a BucketCannedACL enum value
	BucketCannedACLPublicRead = "public-read"

	// BucketCannedACLPublicReadWrite is a BucketCannedACL enum value
	BucketCannedACLPublicReadWrite = "public-read-write"

	// BucketCannedACLAuthenticatedRead is a BucketCannedACL enum value
	BucketCannedACLAuthenticatedRead = "authenticated-read"

	// ObjectCannedACLPrivate is a ObjectCannedACL enum value
	ObjectCannedACLPrivate = "private"

	// ObjectCannedACLPublicRead is a ObjectCannedACL enum value
	ObjectCannedACLPublicRead = "public-read"

	// ObjectCannedACLPublicReadWrite is a ObjectCannedACL enum value
	ObjectCannedACLPublicReadWrite = "public-read-write"

	// ObjectCannedACLAuthenticatedRead is a ObjectCannedACL enum value
	ObjectCannedACLAuthenticatedRead = "authenticated-read"

	// ObjectCannedACLAwsExecRead is a ObjectCannedACL enum value
	ObjectCannedACLAwsExecRead = "aws-exec-read"

	// ObjectCannedACLBucketOwnerRead is a ObjectCannedACL enum value
	ObjectCannedACLBucketOwnerRead = "bucket-owner-read"

	// ObjectCannedACLBucketOwnerFullControl is a ObjectCannedACL enum value
	ObjectCannedACLBucketOwnerFullControl = "bucket-owner-full-control"
)
View Source
const (
	TEST_BUCKET      = "mybucket"
	TEST_KEY         = "testput"
	TEST_KEY_SPECIAL = "testputspecial:!@$%^&*()_+=-;?><| "
	TEST_VALUE       = "valueput"
)

Variables

This section is empty.

Functions

func AESDecrypt

func AESDecrypt(cryptData, key []byte) ([]byte, error)

func AESDecryptHexStringToOrigin

func AESDecryptHexStringToOrigin(hexStr string, key []byte) (string, error)

func AESEncrypt

func AESEncrypt(data, key []byte) ([]byte, error)

func AESEncryptToHexString

func AESEncryptToHexString(data, key []byte) (string, error)

func GenMinimalPart

func GenMinimalPart() []byte

Generate 128KiB part data

func GenTestObjectUrl

func GenTestObjectUrl(sc *S3Client) string

func GenTestSpecialCharaterObjectUrl

func GenTestSpecialCharaterObjectUrl(sc *S3Client) string

func HTTPRequestToGetObject

func HTTPRequestToGetObject(url string) (status int, val []byte, err error)

func RandBytes

func RandBytes(ln int) []byte

RandBytes return the random byte sequence.

func TransferToS3AccessControlPolicy

func TransferToS3AccessControlPolicy(policy *datatype.AccessControlPolicy) (s3policy *s3.AccessControlPolicy)

Types

type AccessPolicyGroup

type AccessPolicyGroup struct {
	BucketPolicy string
	BucketACL    string
	ObjectACL    string
}

type PostObjectInput

type PostObjectInput struct {
	Url        string
	Bucket     string
	ObjName    string
	Expiration time.Time
	Date       time.Time
	Region     string
	AK         string
	SK         string
	FileSize   int
}

type S3Client

type S3Client struct {
	Client *s3.S3
}

func NewS3

func NewS3() *S3Client

func NewS3Internal

func NewS3Internal() *S3Client

func (*S3Client) AbortMultiPartUpload

func (s3client *S3Client) AbortMultiPartUpload(bucketName, key, uploadId string) (err error)

func (*S3Client) AppendObject

func (s3client *S3Client) AppendObject(bucketName, key, value string, position int64) (nextPos int64, err error)

func (*S3Client) ChangeObjectStorageClass

func (s3client *S3Client) ChangeObjectStorageClass(bucketName, key string, storageClass string) (err error)

func (*S3Client) CleanEnv

func (sc *S3Client) CleanEnv()

func (*S3Client) CompleteMultiPartUpload

func (s3client *S3Client) CompleteMultiPartUpload(bucketName, key, uploadId string, completed *s3.CompletedMultipartUpload) (err error)

func (*S3Client) CreateMultiPartUpload

func (s3client *S3Client) CreateMultiPartUpload(bucketName, key, storageClass string) (uploadId string, err error)

func (*S3Client) DeleteBucket

func (s3client *S3Client) DeleteBucket(bucketName string) (err error)

func (*S3Client) DeleteBucketPolicy

func (s3client *S3Client) DeleteBucketPolicy(bucketName string) (err error)

func (*S3Client) DeleteObject

func (s3client *S3Client) DeleteObject(bucketName, key string) (err error)

func (*S3Client) GetBucketAcl

func (s3client *S3Client) GetBucketAcl(bucketName string) (ret string, err error)

func (*S3Client) GetBucketPolicy

func (s3client *S3Client) GetBucketPolicy(bucketName string) (policy string, err error)

func (*S3Client) GetEncryptObjectWithSSEC

func (s3client *S3Client) GetEncryptObjectWithSSEC(bucketName, key string) (value string, err error)

func (*S3Client) GetEncryptObjectWithSSES3

func (s3client *S3Client) GetEncryptObjectWithSSES3(bucketName, key string) (value string, err error)

func (*S3Client) GetObject

func (s3client *S3Client) GetObject(bucketName, key string) (value string, err error)

func (*S3Client) GetObjectAcl

func (s3client *S3Client) GetObjectAcl(bucketName, objName string) (ret string, err error)

func (*S3Client) GetObjectOutPut

func (s3client *S3Client) GetObjectOutPut(bucketName, key string) (out *s3.GetObjectOutput, err error)

func (*S3Client) GetObjectPreSigned

func (s3client *S3Client) GetObjectPreSigned(bucketName, key string, expire time.Duration) (url string, err error)

func (*S3Client) HeadBucket

func (s3client *S3Client) HeadBucket(bucketName string) (err error)

func (*S3Client) HeadObject

func (s3client *S3Client) HeadObject(bucketName, key string) (err error)

func (*S3Client) MakeBucket

func (s3client *S3Client) MakeBucket(bucketName string) (err error)

func (*S3Client) PostObject

func (s3Client *S3Client) PostObject(pbi *PostObjectInput) error

func (*S3Client) PutBucketAcl

func (s3client *S3Client) PutBucketAcl(bucketName string, acl string) (err error)

func (*S3Client) PutBucketAclWithXml

func (s3client *S3Client) PutBucketAclWithXml(bucketName string, acl *s3.AccessControlPolicy) (err error)

func (*S3Client) PutBucketPolicy

func (s3client *S3Client) PutBucketPolicy(bucketName, policy string) (err error)

func (*S3Client) PutEncryptObjectWithSSEC

func (s3client *S3Client) PutEncryptObjectWithSSEC(bucketName, key, value string) (err error)

func (*S3Client) PutEncryptObjectWithSSES3

func (s3client *S3Client) PutEncryptObjectWithSSES3(bucketName, key, value string) (err error)

func (*S3Client) PutObject

func (s3client *S3Client) PutObject(bucketName, key, value string) (err error)

func (*S3Client) PutObjectAcl

func (s3client *S3Client) PutObjectAcl(bucketName, objName string, acl string) (err error)

func (*S3Client) PutObjectAclWithXml

func (s3client *S3Client) PutObjectAclWithXml(bucketName, objName string, acl *s3.AccessControlPolicy) (err error)

func (*S3Client) PutObjectPreSignedWithSpecifiedBody

func (s3client *S3Client) PutObjectPreSignedWithSpecifiedBody(bucketName, key, value string, expire time.Duration) (url string, err error)

func (*S3Client) PutObjectPreSignedWithoutSpecifiedBody

func (s3client *S3Client) PutObjectPreSignedWithoutSpecifiedBody(bucketName, key, value string, expire time.Duration) (url string, err error)

func (*S3Client) PutObjectWithStorageClass

func (s3client *S3Client) PutObjectWithStorageClass(bucketName, key, value string, storageClass string) (err error)

func (*S3Client) TestAnonymousAccessResult

func (sc *S3Client) TestAnonymousAccessResult(policyGroup AccessPolicyGroup, resultCode int) (err error)

func (*S3Client) UploadPart

func (s3client *S3Client) UploadPart(bucketName, key string, value []byte, uploadId string, partNumber int64) (etag string, err error)

Jump to

Keyboard shortcuts

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