Created
March 18, 2010 03:52
-
-
Save silentrob/336028 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
system.use("info.webtoolkit.Base64"); | |
var username = "admin"; | |
var password = "password"; | |
var auth = "Basic " + Base64.encode(username + ":"+ password); | |
checkAuth = function() { | |
if (!this.request.headers.hasOwnProperty('Authorization') || (this.request.headers.hasOwnProperty('Authorization') && (auth != this.request.headers['Authorization']))) { | |
this.response.headers['WWW-Authenticate'] = 'Basic realm="SmartAPI"'; | |
this.response.code = 401; | |
this.response.body = "Not Authorized\n"; | |
throw this.response; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment