Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AssumeRole support for rotating credentials #1265

Merged
merged 1 commit into from
Apr 13, 2020

Conversation

harshavardhana
Copy link
Member

No description provided.

@harshavardhana harshavardhana changed the title add AssumeRole support [wipadd AssumeRole support Apr 8, 2020
@harshavardhana harshavardhana changed the title [wipadd AssumeRole support [wip] add AssumeRole support Apr 8, 2020
@harshavardhana harshavardhana force-pushed the fix-assume-role branch 2 times, most recently from fee3556 to 0bdb7ab Compare April 11, 2020 01:03
@harshavardhana harshavardhana changed the title [wip] add AssumeRole support Add AssumeRole support for rotating credentials Apr 11, 2020
@harshavardhana harshavardhana force-pushed the fix-assume-role branch 5 times, most recently from 4ff7491 to 30c09f7 Compare April 11, 2020 02:12
@harshavardhana
Copy link
Member Author

package main

import (
	"fmt"
	"log"

	"github.com/minio/minio-go/v6/pkg/credentials"
)

func main() {
	// Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY, my-testfile, my-bucketname and
	// my-objectname are dummy values, please replace them with original values.

	// Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
	// This boolean value is the last argument for New().

	// New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
	// determined based on the Endpoint value.
	creds, err := credentials.NewSTSAssumeRole("http://localhost:9000", credentials.STSAssumeRoleOptions{
		AccessKey: "harsha",
		SecretKey: "harsha123",
		Location:  "us-east-1",
	})
	if err != nil {
		log.Fatalln(err)
	}

	v, err := creds.Get()
	if err != nil {
		log.Fatalln(err)
	}

	fmt.Println(v)
	// mclnt, err := madmin.NewWithOptions("localhost:9000", &madmin.Options{
	// 	Creds:  creds,
	// 	Secure: false,
	// })
	// if err != nil {
	// 	log.Fatalln(err)
	// }

	// sinfo, err := mclnt.StorageInfo(context.Background())
	// if err != nil {
	// 	log.Fatalln(err)
	// }
	// fmt.Println(sinfo)
}

@Alevsk is the way to use this change.

Alevsk
Alevsk previously approved these changes Apr 11, 2020
Copy link
Member

@vadmeste vadmeste left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments.

@harshavardhana your test code doesn't seem to work with MinIO master (2020/04/13 14:53:02 400 Bad Request), is this expected ?

core_test.go Outdated Show resolved Hide resolved
api-compose-object.go Outdated Show resolved Hide resolved
.travis.yml Outdated Show resolved Hide resolved
@harshavardhana

This comment has been minimized.

pkg/signer/request-signature-streaming.go Outdated Show resolved Hide resolved
pkg/signer/request-signature-streaming.go Outdated Show resolved Hide resolved
@harshavardhana
Copy link
Member Author

Runs perfectly fine

~ go run /tmp/test.go 
{SC07LRYOTERWAOPEV7BN MIAr+eW2q1ygzJP+AyP0IfhnHRD5nhQuYKckOEsD eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhY2Nlc3NLZXkiOiJTQzA3TFJZT1RFUldBT1BFVjdCTiIsImV4cCI6MzYwMDAwMDAwMDAwMCwicG9saWN5IjoicmV0In0.Q8pBOUStGLHYcUJY5zXMgtS6QkzlSvwtxC5zAMiWefENAOoshe7uehPYKFRtHvEPMcqovlbKUIrCG9YGKze1Yg S3v4}

@vadmeste

@vadmeste

This comment has been minimized.

Copy link
Member

@vadmeste vadmeste left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM & tested

@harshavardhana

This comment has been minimized.

pkg/credentials/assume_role.go Show resolved Hide resolved
@harshavardhana harshavardhana merged commit 8bb083d into minio:master Apr 13, 2020
@harshavardhana harshavardhana deleted the fix-assume-role branch April 13, 2020 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants