Skip to content

Commit

Permalink
Merge pull request #219 from mashery/api_basic_auth_fix
Browse files Browse the repository at this point in the history
Refs #217 api level basic auth
  • Loading branch information
phairow committed Oct 15, 2014
2 parents 34c15ba + 51fd600 commit dcacf8d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
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

0 comments on commit dcacf8d

Please sign in to comment.