mirror of
https://github.com/github/codeql.git
synced 2026-04-25 08:45:14 +02:00
Add fixed proposition for NodeJS
This commit is contained in:
@@ -33,6 +33,10 @@
|
||||
<code>username</code> and <code>password</code>, which can be set externally without hard-coding
|
||||
credentials in the source code.
|
||||
</p>
|
||||
|
||||
For example, in a NodeJS environment :
|
||||
<sample src="examples/HardcodedCredentialsHttpRequestFixed.js"/>
|
||||
|
||||
</example>
|
||||
|
||||
<example>
|
||||
|
||||
@@ -11,8 +11,8 @@ headers.append('Authorization', 'Basic' + base64.encode(username + ":" + passwor
|
||||
|
||||
fetch(url, {method:'GET',
|
||||
headers: headers,
|
||||
//credentials: 'user:passwd'
|
||||
credentials: `${user}:${passwd}`
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(json => console.log(json));
|
||||
//.done();
|
||||
.done();
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
let base64 = require('base-64');
|
||||
|
||||
let url = 'http://example.org/auth';
|
||||
let username = process.env.USERNAME;
|
||||
let password = process.env.PASSWORD;
|
||||
|
||||
let headers = new Headers();
|
||||
|
||||
//headers.append('Content-Type', 'text/json');
|
||||
headers.append('Authorization', 'Basic' + base64.encode(username + ":" + password));
|
||||
|
||||
fetch(url, {method:'GET',
|
||||
headers: headers,
|
||||
credentials: `${user}:${passwd}`
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(json => console.log(json));
|
||||
.done();
|
||||
Reference in New Issue
Block a user