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

how to generate share url permanent? #5180

Closed
timchenxiaoyu opened this issue Nov 14, 2017 · 16 comments
Closed

how to generate share url permanent? #5180

timchenxiaoyu opened this issue Nov 14, 2017 · 16 comments

Comments

@timchenxiaoyu
Copy link

now ,the url only 7 minute valid,how to change this?

@nitisht
Copy link
Contributor

nitisht commented Nov 14, 2017

@timchenxiaoyu Presigned URLs are valid only for a maximum of 7 days. This is mandated by S3 Spec (Ref: http:https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-query-string-auth.html).

For permanent sharing you can consider buckets policies - https://docs.minio.io/docs/minio-client-complete-guide#policy

@nitisht nitisht self-assigned this Nov 14, 2017
@nitisht nitisht added this to the Next Release milestone Nov 14, 2017
@deekoder
Copy link
Contributor

Please lets us know if you have any other questions.

@timchenxiaoyu
Copy link
Author

even I set buckets policies, I cannot still get permanent url,how to solve this?

@nitisht
Copy link
Contributor

nitisht commented Nov 15, 2017

Once you set the policy on a bucket like

mc policy public myminio/bucketname

You can use the URL: miniohost:9000/bucketname/object to access the object

@timchenxiaoyu
Copy link
Author

timchenxiaoyu commented Nov 15, 2017

#mc policy public minio/test

Access permission for minio/test is set to public

#wget http:https://10.39.0.45:9000/test/types-of-mounts.png

it's ok now .ths.
I send url wget http:https://10.39.0.45:9000/minio/test/types-of-mounts.png before,so i'm wrong

@nitisht
Copy link
Contributor

nitisht commented Nov 15, 2017

You need to remove minio, so the URL should be

http:https://10.39.0.45:9000/test/types-of-mounts.png

@timchenxiaoyu
Copy link
Author

yes, you are right ,ths

@FoxUSA
Copy link

FoxUSA commented Feb 8, 2018

@nitisht
I don't know if this is a counter example or a different method. If I use the s3.getSignedUrl I can generate urls that are longer than 7 days.
JS Code

var urlParams= {"Bucket":"opennote","Key":"ovoay3yj5uky.png","Expires":77760000}
s3.getSignedUrl("getObject",urlParams,function(err,data){console.dir(err);console.dir(data)})

This gives a signature of ?AWSAccessKeyId=tests&Expires=1595816882&Signature=HQbjEiQUrqW87ShZSjVVOeHnz0o%3D
Which is valid for 900 days from now.

S3 and Minio accepts this signature and display the object

Why does it work?

@harshavardhana
Copy link
Member

S3 and Minio accepts this.
Why does it work?

This is a presigned URL but it is not permanent @FoxUSA

@FoxUSA
Copy link

FoxUSA commented Feb 8, 2018

@harshavardhana
Its way over 7 days. I could set it to 90,000 days or 999,999,999 days. So it essentially is permanent.

Signature

?AWSAccessKeyId=tests&Expires=86401517971856&Signature=OcP7k9X%2FSa4ZS6Ql65p0FOsyNfs%3D

Epoch time sets that signature to expire in the year 2739925.

@harshavardhana
Copy link
Member

Its way over 7 days. I could set it to 90,000 days or 999,999,999 days. So it essentially is permanent.

Signature

?AWSAccessKeyId=tests&Expires=86401517971856&Signature=OcP7k9X%2FSa4ZS6Ql65p0FOsyNfs%3D
Epoch time sets that signature to expire in the year 2739925.

Yes only in AWS Signature v2 (legacy), AWS Signature v4 has limited it to maximum of 7 days.

@Arkemlar
Copy link

It would be good if somebody point out in docs that polycy prefix should not start with slash / when you type it in via web intrerface, got fooled by that slash hard before checked policies via mc.

@harshavardhana
Copy link
Member

It would be good if somebody point out in docs that polycy prefix should not start with slash / when you type it in via web intrerface, got fooled by that slash hard before checked policies via mc.

UI is being revamped you won't be allowed to type incorrect values.

@woodgear
Copy link

woodgear commented Aug 6, 2019

how should i do this via sdk(js)?

mc policy public myminio/bucketname

@kannappanr
Copy link
Contributor

@woodgear Here is the policy

 {
  "Statement": [
   {
    "Action": [
     "s3:GetBucketLocation",
     "s3:ListBucket",
     "s3:ListBucketMultipartUploads"
    ],
    "Effect": "Allow",
    "Principal": {
     "AWS": "*"
    },
    "Resource": "arn:aws:s3:::mybucketname",
    "Sid": ""
   },
   {
    "Action": [
     "s3:AbortMultipartUpload",
     "s3:DeleteObject",
     "s3:GetObject",
     "s3:ListMultipartUploadParts",
     "s3:PutObject"
    ],
    "Effect": "Allow",
    "Principal": {
     "AWS": "*"
    },
    "Resource": "arn:aws:s3:::mybucketname/*",
    "Sid": ""
   }
  ],
  "Version": "2012-10-17"
 }

Replace mybucketname with the appropriate bucket name

@modbender
Copy link

All I did create a new location in nginx something like /bucketname and in the block add root to the local path for the bucket folder.

@minio minio locked as resolved and limited conversation to collaborators Nov 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

9 participants