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

Basic Auth #38

Open
Urbiwanus opened this issue Apr 24, 2015 · 4 comments
Open

Basic Auth #38

Urbiwanus opened this issue Apr 24, 2015 · 4 comments

Comments

@Urbiwanus
Copy link

URLS with basic auth. are not working right

like https://username:password@domain/mainfest.json

Found one issue in the bootstrap.js
xhr.setRequestHeader("Authorization", "Basic ...);

is missing.

Also the cordova file loader does not set the right headers for downloading

authHeaderValue = function(username, password) {
    var tok = username + ':' + password;
    var hash = btoa(tok);
    return "Basic " + hash;
};

options.headers = {'Authorization': authHeaderValue('Bob', '1234') };

@Urbiwanus
Copy link
Author

I found a woring solution

following changes work for me

I changed every XMLHttpRequest ( bootstrap.js ,CordovaAppLoader.js, CordovaPromise.js ) to

            var xhr = new XMLHttpRequest();
            var parser = document.createElement('a');  // Poor mans url parser
            parser.href = url;
        xhr.responseType = "blob";
            xhr.open('GET', url, true, parser.username, parser.password);  // New XmlhttpRequest 

            //Check if username is present ( default empty string )
            if (parser.username.length > 0) {
                xhr.setRequestHeader("Authorization", "Basic " + btoa(parser.username + ':' + parser.password));
            }

If its ok , i would send a PR

Regards

P.s I m not sure if i missed something could only test on Android yet

@Urbiwanus
Copy link
Author

Unfortunately the poor mans url parser does not work on ios

i switched to http://blog.stevenlevithan.com/archives/parseuri for parsing the urls

@pablomaurer
Copy link

+1

@micky2be
Copy link

Whenever you got something on your side send a PR.
So we will be able to test it on our side too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants