[
https://issues.apache.org/jira/browse/CB-52?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13606715#comment-13606715
]
Shazron Abdullah commented on CB-52:
------------------------------------
Ok, this is what I'm going to do. I'll add this to cordova-js. Some platforms
that don't support window.btoa (like WP7) won't get this feature of course.
Example code (the gist of it):
{code}
var target =
"http://username:[email protected]/some/path?name=value#anchor"
if (window.btoa) {
// parse the url using the Location object
var url = document.createElement('a');
url.href = target;
// check whether there are the username:password credentials in the url
var credentials = null;
if (url.href.indexOf(url.origin) != 0) { // credentials found
var protocol = url.protocol + "//";
var atIndex = url.href.indexOf("@");
credentials = url.href.substring(protocol.length, atIndex);
}
if (credentials) {
var authHeader = "Authorization";
var authHeaderValue = "Basic " + window.btoa(credentials);
// TODO: add this to the FileTransfer headers, etc
}
}
{code}
> API: FileTransfer - Basic Authentication
> ----------------------------------------
>
> Key: CB-52
> URL: https://issues.apache.org/jira/browse/CB-52
> Project: Apache Cordova
> Issue Type: New Feature
> Components: iOS
> Reporter: Shazron Abdullah
> Assignee: Shazron Abdullah
> Priority: Minor
> Fix For: 2.6.0
>
> Attachments: patch_commit_e6a2ffb1defb.patch
>
>
> reported at: https://github.com/phonegap/phonegap-iphone/issues/177
> by: https://github.com/berb
> (This feature request is platform-agnostic and has been posted here due to
> the comments in #phonegap)
> I'd appreciate an optional parameter for FileUploadOptions allowing to pass
> Basic Authentication credentials. Combined with HTTPS, Basic Authentication
> can introduce minimal security when upload files.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira