I'm trying to set the storage class of an uploaded image to an AWS S3 bucket. I have it working except for adding the storage class to the request. The S3 Post Object Documentation states there can be a form input field named "x-amz-storage-class" but adding it, or any other field, throws an AWS error indicating that there are too many input fields for the post. I tried adding it to the object policy but that causes an Policy error: "Policy Condition failed: [“eq”, “$x-amz-storage-class”, “ONEZONE_IA”]". I'm using JSP and the form's input fields are shown below. Any help would be appreciated.
<input type="hidden" name="key" value="<%= imageFileName %>">
<input type="hidden" name="AWSAccessKeyId" value="<%= S3AccessKeyId %>">
<input type="hidden" name="acl" value="private">
<input type="hidden" name="success_action_redirect" value="<%= s3SuccessAction %>">
<input type="hidden" name="policy" value="<%= encPolicy %>" >
<input type="hidden" name="signature" value="<%= signature %>" >
<input type="hidden" name="Content-Type" value="image/jpeg">
<input type="hidden" name="x-amz-storage-class" value="ONEZONE_IA"> ***** CAUSES ERROR ****
Errors:
Invalid according to Policy: Policy Condition failed: [“eq”, “$x-amz-storage-class”, “STANDARD_IA”]
<Error>
<Code>AccessDenied</Code>
<Message>
Invalid according to Policy: Extra input fields: x-amz-storage-class
</Message>
<RequestId>1104FC046523752C</RequestId>
<HostId>
m0xPpMKJqBG6kZsdQfl/RY92dHprnvtGtrijHLqVtieM51ew+Mkp0mXGbTwKM7OsoUq6ZZUVIc0=
</HostId>
</Error>
I have this working now. The policy has fields that must match the fields on the form. "x-amz-storage-class" has to be added to both the form fields and policy. My guess is the encoded policy is signed for security reasons which makes it secure and the form fields must match the policy fields to ensure they weren't changed. Why both are needed is beyond me. Corrected code is below:
<fieldset>
<input type="hidden" name="key" value="<%= imageFileName %>">
<input type="hidden" name="AWSAccessKeyId" value="<%= S3AccessKeyId %>">
<input type="hidden" name="acl" value="private">
<input type="hidden" name="success_action_redirect" value="<%= s3SuccessAction %>">
<input type="hidden" name="policy" value="<%= encPolicy %>" >
<input type="hidden" name="signature" value="<%= signature %>" >
<input type="hidden" name="Content-Type" value="image/jpeg">
<input type="hidden" name="x-amz-storage-class" value="ONEZONE_IA">
public static String encodeS3Policy(String s3SuccessAction, String bucket) throws Exception
{
String policy =
"{\"expiration\": \"2040-01-01T00:00:00Z\"," +
"\"conditions\": [" +
"{\"bucket\": \"" + bucket + "\"}," +
"[\"starts-with\", \"$key\", \"\"]," +
"{\"acl\": \"private\"}," +
"{\"success_action_redirect\": \"" + s3SuccessAction + "\"}," +
"[\"starts-with\", \"$Content-Type\", \"\"]," +
"{\"x-amz-storage-class\": \"ONEZONE_IA\"}," +
"[\"content-length-range\", 0, 10485760]" + // 10 MB max file up load
"]" +
"}";
policy.replaceAll("\n","").replaceAll("\r","");
// Encode the policy
String encPolicy = Base64.getEncoder().encodeToString(policy.getBytes("UTF-8"));
return encPolicy;
}
For completeness and because its not obvious, the storage class values are:
Default: STANDARD
STANDARD | REDUCED_REDUNDANCY | GLACIER | STANDARD_IA | ONEZONE_IA | INTELLIGENT_TIERING | DEEP_ARCHIVE
Here is the AWS S3 Post Object documentation
Related
I am developing an application in VUEJS using quasar framework to develop IOS/ANDROID app.
I want to open external webpage in my cordova application.
I have following form that i am using to post data to external payment gateway.
<form action="https://myUrl.com" method="post" id="myForm">
<input type="hidden" name="MERCHANTID" v-model="paymentDataPost.MERCHANTID" >
<input type="hidden" name="APPID" v-model="paymentDataPost.APPID" />
<input type="hidden" name="APPNAME" v-model="paymentDataPost.APPNAME"/>
<input type="hidden" name="TXNID" v-model="paymentDataPost.TXNID"/>
<input type="hidden" name="TXNDATE" v-model="paymentDataPost.TXNDATE"/>
<input type="hidden" name="TXNCRNCY" v-model="paymentDataPost.TXNCRNCY"/>
<input type="hidden" name="TXNAMT" v-model="paymentDataPost.TXNAMT"/>
<input type="hidden" name="REFERENCEID" v-model="paymentDataPost.REFERENCEID"/>
<input type="hidden" name="REMARKS" v-model="paymentDataPost.REMARKS"/>
<input type="hidden" name="PARTICULARS" v-model="paymentDataPost.PARTICULARS"/>
<input type="hidden" name="TOKEN" v-model="paymentDataPost.TOKEN"/>
<br>
</form>
And I was submitting this form in my methods after confirmation.
document.getElementById('myForm').submit()
This code works fine in web browser. When I tested my application in IOS platform, external website was not opening from my application.
So, I did some research and got to know about cordova-plugin-inappbrowser. Then I changed my above code to below one.
methods: {
async confirm () {
var myForm = '<form action="https://uat.connectips.com:7443/connectipswebgw/loginpage" method="post" id="myForm">' +
'<input type="hidden" name="MERCHANTID" v-model="paymentDataPost.MERCHANTID" >' +
'<input type="hidden" name="APPID" v-model="paymentDataPost.APPID" />' +
'<input type="hidden" name="APPNAME" v-model="paymentDataPost.APPNAME"/>' +
'<input type="hidden" name="TXNID" v-model="paymentDataPost.TXNID"/>' +
'<input type="hidden" name="TXNDATE" v-model="paymentDataPost.TXNDATE"/>' +
'<input type="hidden" name="TXNCRNCY" v-model="paymentDataPost.TXNCRNCY"/>' +
'<input type="hidden" name="TXNAMT" v-model="paymentDataPost.TXNAMT"/>' +
'<input type="hidden" name="REFERENCEID" v-model="paymentDataPost.REFERENCEID"/>' +
'<input type="hidden" name="REMARKS" v-model="paymentDataPost.REMARKS"/>' +
'<input type="hidden" name="PARTICULARS" v-model="paymentDataPost.PARTICULARS"/>' +
'<input type="hidden" name="TOKEN" v-model="paymentDataPost.TOKEN"/>' +
'<br>' +
'</form>' +
'<script type="text/javascript">document.getElementById("myForm").submit()<script/>'
var pageContentUrl = 'data:text/html;base64,' + btoa(myForm)
window.open(pageContentUrl,
'_blank',
'hidden=no,location=no,clearsessioncache=yes,clearcache=yes'
)
}
}
New window opens, but url is blank, and post data is not available as well.
Any help is very much appreciated.
Regards,
As mentioned in this question's title, when using the boto3.client('s3').generate_presigned_post to generate an upload URL as per here and injecting the response of the function into the following form:
<form class="s3-upload" action="URL_VALUE" method="post" enctype="multipart/form-data">
<input type="hidden" name="key" value="VALUE"/>
<input type="hidden" name="AWSAccessKeyId" value="VALUE"/>
<input type="hidden" name="policy" value="VALUE"/>
<input type="hidden" name="signature" value="VALUE"/>
<input type="hidden" name="success_action_redirect" value="VALUE"/>
<input type="file" name="file" class="upload-input">
<p class="drag-text">Drag your file here or click in this area.</p>
<button id="uploadS3" type="submit" title="">Upload</button>
</form>
I receive the following error from AWS: The AWS Access Key Id you provided does not exist in our records.
The application runs inside a docker on AWS Fargate and has an AWS role attached to it. This must probably have something to do with the solution because the whole functionality works fine on my local machine. Furthermore, all other AWS related operations with S3 (also with SQS) work fine with that AWS Fargate/AWS role setting. I'm looking forward to any suggestions about what to do.
I am trying to generate a recurring payment using our test accounts and I am getting response on status url as well which is mentioned below.
Implemented as per Instructions which are mentioned on page number: 12 & 35
Here is the code which we are posting to Skrill:
<form action="https://pay.skrill.com" target="_blank" class="skrill-form">
<input type="hidden" name="pay_to_email" value="email#gmail.com">
<input type="hidden" name="currency" value="EUR">
<input type="hidden" name="return_url" value="http://domain/dev-test-page-2/">
<input type="hidden" name="return_url_text" value="Return to main website">
<input type="hidden" name="return_url_target" value="4">
<input type="hidden" name="cancel_url" value="http://domain/dev-test-page-2/">
<input type="hidden" name="cancel_url_target" value="4">
<input type="hidden" name="status_url"
value="http://domain/wp-admin/admin-ajax.php?action=skrill_response">
<input type="hidden" name="status_url2" value="mailto:email#gamil.com">
<input type="hidden" name="logo_url" value="https://domain/wp-content/uploads/2018/07/logo.png">
<input type="hidden" name="rec_amount" value="2">
<input type="hidden" name="rec_start_date" value="17/01/2019">
<input type="hidden" name="rec_end_date" value="27/01/2019">
<input type="hidden" name="rec_period" value="2">
<input type="hidden" name="rec_cycle" value="day">
<input type="hidden" name="rec_grace_period" value="2">
<input type="hidden" name="rec_status_url"
value="http://domain/wp-admin/admin-ajax.php?action=skrill_rec_status_url">
<input type="hidden" name="rec_status_url2"
value="http://domain/wp-admin/admin-ajax.php?action=skrill_rec_status_url">
<input type="text" name="amount" value="1">
<input type="submit" value="Pay" class="btn">
</form>
Response:
[action] => skrill_response
[transaction_id] => 2605308006
[mb_amount] => 39
[amount] => 39
[md5sig] => 72EE69AA174B377A6E488129CA4F5063
[merchant_id] => 111682769
[payment_type] => WLT
[mb_transaction_id] => 2605308006
[mb_currency] => EUR
[pay_from_email] => email#gmail.com
[pay_to_email] => email#gmail.com
[currency] => EUR
[customer_id] => 111683528
[status] => 2
We are not getting any response on rec_status_url. Further, we have also tried to access the recurring transaction status of above test transaction as per mentioned instructions in PDF in return I received an email that my account temporarily locked.
Am I skipping some of essential parameters?
Query string as per instructions to access the status of a recursion:
https://www.skrill.com/app/query.pl?action=status_rec&email=email#gmail.com&password=123456&trn_id=2605308006
Response:
401 Your account is currently locked. Please contact our Merchant Team at:merchantservices#skrill.com
Implemented as per Instructions which are mentioned on page number: 30
Have you solved your issue?
Most probably you merchant account is not enabled from Skrill's side to receive recurring payments. Please ask their support to enable it for you.
Also i would highly recommend you to user server-to-server request to generate 'session' for your payments, not leaving your payment parameters/data on the user's front-end(html form).
As far as i am aware about rec_status_url, it should be called only in when customer was subscribed and there was at least one sub/recurring payment, then if he cancels the plan, you should receive correct http post message.
About query.pl?action=status_rec - all MQI/API queries should contain your MQI/API password as md5 hash value - not plain text password.
Make sure that "MQI" service is enabled for your account(My Account->Settings->Developer Settings)
Cheers,
i am working with angular5 , i need to integrate PayUMoney payment gateway in my application , for that i added following form and test with "https://test.payu.in/_payment" domain.
Error :
Error Reason Transaction failed due to incorrectly calculated hash
parameter.
Corrective Action Please ensure that the hash used in transaction
request is calculated using the correct formula. Please note the
correct formula for calculating the value of hash:
sha512(key|txnid|amount|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5||||||SALT)
Based on above formula and applying for this transaction, hash should
be calculated as mentioned below : hash =
sha512(gtKFFx|ba7816bf8f01cfea414140de5da|500|merit application
fees|bhagvat lande|landebm#gmail.com|||||||||||eCwWELxi) = Array
As seen above, correct hash value should have been - Array
But the hash posted in the transaction request from your end was -
e95bd46ce3cf4b3c32a63ba5f51934ef8506e0e47027512f41bff125be02cd14
My Component with Form
<form #f method="post" id="payu-payment-form" action="https://test.payu.in/_payment">
<input type="hidden" name="hash" value="e95bd46ce3cf4b3c32a63ba5f51934ef8506e0e47027512f41bff125be02cd14"/>
<input type="hidden" name="key" value="gtKFFx" />
<input type="hidden" name="txnid" value="ba7816bf8f01cfea414140de5da" />
<input type="hidden" name="amount" value="500" />
<input type="hidden" name="productinfo" value="merit application fees" />
<input type="hidden" name="firstname" value="bhagvat lande" />
<input type="hidden" name="email" value="******#gmail.com" />
<input type="hidden" name="phone" value="+91**********" />
<input type="hidden" name="surl" value="http://localhost:4200/#/payment/payment-success" />
<input type="hidden" name="furl" value="http://localhost:4200/#/payment/payment-error" />
<input type="hidden" name="service_provider" value="" />
<button class="btn btn-info" type="submit" (click)="f.submit()" value="submit" formtarget="_blank"> <i class="fa fa-money"></i> Proceed To Pay</button>
</form>
in above form i just generate one dummy hash key(SHA-256) and put their.
Questions :
how to integrate PayUmoney payment gateway in ANgular2/4/5 ?
they provided formula on their documentation for generation hash key , it tooks all other forms fields and generate hash key (SHA-256) , is their any way to create hash key at client side and how to use that ?
thanks
I am having some difficulty with one of our service providers login forms. The other sites are working fine but for some reason I can't get past their login form.
The website login for is like this:
<form accept-charset="UTF-8" action="/sessions" class="new_user_session" id="new_user_session" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓" /><input name="authenticity_token" type="hidden" value="kaLEkPesQfeheronzGTdfnVAzpuUiC+VmjVXBu540n8=" /></div>
<fieldset class="big">
<div class="form-row">
<div class="form-label">
<label for="user_session_email">Email</label>
</div>
<div class="form-field">
<input id="user_session_email" name="user_session[email]" size="30" type="text" />
</div>
</div>
<div class="form-row">
<div class="form-label">
<label for="user_session_password">Password</label>
</div>
<div class="form-field">
<input id="user_session_password" name="user_session[password]" size="30" type="password" />
</div>
<div class="form-comment"><p>Forgot your password?</p></div>
</div>
<div class="form-row optional">
<div class="form-field">
<label for="user_session_remember_me"><input name="user_session[remember_me]" type="hidden" value="0" /><input id="user_session_remember_me" name="user_session[remember_me]" type="checkbox" value="1" /> Remember me for 2 weeks</label>
</div>
</div>
</fieldset>
I have tried to login using the same code as other the other sites but it doesn't work.
# Create a new mechanize object
agent = Mechanize.new
# Load the dial9 website
page = agent.get("http://webapplication.co.uk")
# Select the first form
form = agent.page.forms.first
form.username = 'username
form.password = 'password'
# Submit the form
page = form.submit form.buttons.first
I have also tried a different way of logging in as suggested in other SO questions/answers:
email = 'user#domain.com'
password = 'password
# Create a new mechanize object
agent = Mechanize.new
# Load the postmarkapp website
page = agent.get("https://domain.com")
# Select the first form
form = agent.page.forms.first
form.field_with(:email => "user_session_email").value = email
form.field_with(:password => "user_session_password").value = password
# Submit the form
page = form.submit form.buttons.first
Using this method of authentication I get the following output when running the rake task:
undefined method `email' for [hidden:0x3fef2ab2b994 type: hidden name: utf8 value: ✓]:Mechanize::Form::Hidden
Upon closer inspection the above error seems to be due to the fact that there is a field immediately after the form is started:
<form accept-charset="UTF-8" action="/sessions" class="new_user_session" id="new_user_session" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓" /><input name="authenticity_token" type="hidden" value="kaLEkPesQfeheronzGTdfnVAzpuUiC+VmjVXBu540n8=" /></div>
Am I missing something? If so, what? Any pointers are appreciated!
Try changing
form.field_with(:email => "user_session_email").value = email
form.field_with(:password => "user_session_password").value = password
to
form.field_with(:name => "user_session[email]").value = email
form.field_with(:name => "user_session[password]").value = password