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

Refs #217 api level basic auth #219

Merged
merged 1 commit into from
Oct 15, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,12 @@ function processRequest(req, res, next) {
options.path += apiConfig.auth.key.param + '=' + apiKey;
}

// Basic Auth support
if (apiConfig.auth == 'basicAuth') {
options.headers['Authorization'] = 'Basic ' + new Buffer(reqQuery.apiUsername + ':' + reqQuery.apiPassword).toString('base64');
console.log(options.headers['Authorization'] );
}

//
// Perform signature routine - force defaults on required configuration items.
//
Expand Down
Binary file added dump.rdb
Binary file not shown.
6 changes: 4 additions & 2 deletions public/javascripts/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,11 @@
var params = $(this).serializeArray(),
apiKey = { name: 'apiKey', value: $('input[name=key]').val() },
apiSecret = { name: 'apiSecret', value: $('input[name=secret]').val() },
apiName = { name: 'apiName', value: $('input[name=apiName]').val() };
apiName = { name: 'apiName', value: $('input[name=apiName]').val() },
apiUsername = { name: 'apiUsername', value: $('input[name=username]').val() },
apiPassword = { name: 'apiPassword', value: $('input[name=password]').val() };;

params.push(apiKey, apiSecret, apiName);
params.push(apiKey, apiSecret, apiName, apiUsername, apiPassword);

//Accounts for array values
for (i in params) {
Expand Down
10 changes: 9 additions & 1 deletion views/api.jade
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,22 @@ block content
- if (oAuthVersion)
label(for='key') Client ID
- var secure ='authrequired'
input(id='key', name='key', value=defaultKey, style='color=#EEEEEE')
- else if (apiInfo.auth == 'basicAuth')
label(for='username') User name
input(id='username', name='username', value=defaultKey, style='color=#EEEEEE')
- else
label(for='key') API Key
- var secure =''
input(id='key', name='key', value=defaultKey, style='color=#EEEEEE')
input(id='key', name='key', value=defaultKey, style='color=#EEEEEE')
div
- if (oAuthVersion)
label(for='secret') Client Secret
input(id='secret', name='secret', value=defaultSecret, style='color=#EEEEEE')
- else if (apiInfo.auth == 'basicAuth')
label(for='password') Password
input(id='password', name='password', type='password', value=defaultKey, style='color=#EEEEEE')

- if (apiInfo.auth.signature)
label(for='secret') Shared Secret
input(id='secret', name='secret', value=defaultSecret, style='color=#EEEEEE')
Expand Down