mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-12 12:59:57 +00:00
Add basic authentication support for tm-http-request (#8109)
This commit is contained in:
parent
40801f3c29
commit
ea173ec83d
@ -48,7 +48,11 @@ exports.startup = function() {
|
|||||||
headers: getPropertiesWithPrefix(params,"header-"),
|
headers: getPropertiesWithPrefix(params,"header-"),
|
||||||
passwordHeaders: getPropertiesWithPrefix(params,"password-header-"),
|
passwordHeaders: getPropertiesWithPrefix(params,"password-header-"),
|
||||||
queryStrings: getPropertiesWithPrefix(params,"query-"),
|
queryStrings: getPropertiesWithPrefix(params,"query-"),
|
||||||
passwordQueryStrings: getPropertiesWithPrefix(params,"password-query-")
|
passwordQueryStrings: getPropertiesWithPrefix(params,"password-query-"),
|
||||||
|
basicAuthUsername: params["basic-auth-username"],
|
||||||
|
basicAuthUsernameFromStore: params["basic-auth-username-from-store"],
|
||||||
|
basicAuthPassword: params["basic-auth-password"],
|
||||||
|
basicAuthPasswordFromStore: params["basic-auth-password-from-store"]
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
$tw.rootWidget.addEventListener("tm-http-cancel-all-requests",function(event) {
|
$tw.rootWidget.addEventListener("tm-http-cancel-all-requests",function(event) {
|
||||||
|
@ -100,6 +100,10 @@ headers: hashmap of header name to header value to be sent with the request
|
|||||||
passwordHeaders: hashmap of header name to password store name to be sent with the request
|
passwordHeaders: hashmap of header name to password store name to be sent with the request
|
||||||
queryStrings: hashmap of query string parameter name to parameter value to be sent with the request
|
queryStrings: hashmap of query string parameter name to parameter value to be sent with the request
|
||||||
passwordQueryStrings: hashmap of query string parameter name to password store name to be sent with the request
|
passwordQueryStrings: hashmap of query string parameter name to password store name to be sent with the request
|
||||||
|
basicAuthUsername: plain username for basic authentication
|
||||||
|
basicAuthUsernameFromStore: name of password store entry containing username
|
||||||
|
basicAuthPassword: plain password for basic authentication
|
||||||
|
basicAuthPasswordFromStore: name of password store entry containing password
|
||||||
*/
|
*/
|
||||||
function HttpClientRequest(options) {
|
function HttpClientRequest(options) {
|
||||||
var self = this;
|
var self = this;
|
||||||
@ -129,6 +133,11 @@ function HttpClientRequest(options) {
|
|||||||
$tw.utils.each(options.passwordHeaders,function(value,name) {
|
$tw.utils.each(options.passwordHeaders,function(value,name) {
|
||||||
self.requestHeaders[name] = $tw.utils.getPassword(value) || "";
|
self.requestHeaders[name] = $tw.utils.getPassword(value) || "";
|
||||||
});
|
});
|
||||||
|
this.basicAuthUsername = options.basicAuthUsername || (options.basicAuthUsernameFromStore && $tw.utils.getPassword(options.basicAuthUsernameFromStore)) || "";
|
||||||
|
this.basicAuthPassword = options.basicAuthPassword || (options.basicAuthPasswordFromStore && $tw.utils.getPassword(options.basicAuthPasswordFromStore)) || "";
|
||||||
|
if(this.basicAuthUsername && this.basicAuthPassword) {
|
||||||
|
this.requestHeaders.Authorization = "Basic " + $tw.utils.base64Encode(this.basicAuthUsername + ":" + this.basicAuthPassword);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpClientRequest.prototype.send = function(callback) {
|
HttpClientRequest.prototype.send = function(callback) {
|
||||||
|
@ -24,6 +24,10 @@ The following parameters are used:
|
|||||||
|header-* |Headers with string values |
|
|header-* |Headers with string values |
|
||||||
|password-header-* |Headers with values taken from the password store |
|
|password-header-* |Headers with values taken from the password store |
|
||||||
|password-query-* |Query string parameters with values taken from the password store |
|
|password-query-* |Query string parameters with values taken from the password store |
|
||||||
|
|basic-auth-username |<<.from-version "5.3.4">> Optional username for HTTP basic authentication |
|
||||||
|
|basic-auth-username-from-store |<<.from-version "5.3.4">> Optional username for HTTP basic authentication, specified as the name of the entry in the password store containing the username |
|
||||||
|
|basic-auth-password |<<.from-version "5.3.4">> Optional password for HTTP basic authentication |
|
||||||
|
|basic-auth-password-from-store |<<.from-version "5.3.4">> Optional password for HTTP basic authentication, specified as the name of the entry in the password store containing the password |
|
||||||
|var-* |Variables to be passed to the completion and progress handlers (without the "var-" prefix) |
|
|var-* |Variables to be passed to the completion and progress handlers (without the "var-" prefix) |
|
||||||
|bind-status |Title of tiddler to which the status of the request ("pending", "complete", "error") should be bound |
|
|bind-status |Title of tiddler to which the status of the request ("pending", "complete", "error") should be bound |
|
||||||
|bind-progress |Title of tiddler to which the progress of the request (0 to 100) should be bound |
|
|bind-progress |Title of tiddler to which the progress of the request (0 to 100) should be bound |
|
||||||
|
Loading…
Reference in New Issue
Block a user