Created
December 13, 2014 00:07
-
-
Save danemacaulay/a20c84283d40f86dd2c9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function setAuthenticationHeaders(config, authService) { | |
// Is this a local URL? If so, add auth headers, but don't overwrite | |
// any that are not already set - this allows someone to pass in | |
// overrides if so desired. | |
// | |
// Note: we don't want to send out headers to URLs that will go out to | |
// the CDN. This would be very bad. This path check should be sufficient | |
// to that end. | |
if (config.url.indexOf('/DNB360UIAgent/') === 0) { | |
var authHeaders = authService.authHeaders(); | |
if (authHeaders) { | |
config.headers = config.headers || {}; | |
for (var header in authHeaders) { | |
if (!config.headers[header]) { | |
config.headers[header] = authHeaders[header]; | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment