basic-authentication

How to prevent browser to invoke basic auth popup and handle 401 error using Jquery?

耗尽温柔 提交于 2019-11-26 19:37:37
I need to send authorization request using basic auth. I have successfully implemented this using jquery. However when I get 401 error basic auth browser popup is opened and jquery ajax error callback is not called. nwinkler I was facing this issue recently, too. Since you can't change the browser's default behavior of showing the popup in case of a 401 ( basic or digest authentication), there are two ways to fix this: Change the server response to not return a 401 . Return a 200 code instead and handle this in your jQuery client. Change the method that you're using for authorization to a

What is the “realm” in basic authentication

二次信任 提交于 2019-11-26 19:25:10
I'm setting up basic authentication on a php site and found this page on the php manual showing the set up. What does "realm" mean here in the header? header('WWW-Authenticate: Basic realm="My Realm"'); Is it the page page being requested? Tim Cooper From RFC 1945 (HTTP/1.0) and RFC 2617 (HTTP Authentication referenced by HTTP/1.1) The realm attribute (case-insensitive) is required for all authentication schemes which issue a challenge. The realm value (case-sensitive), in combination with the canonical root URL of the server being accessed, defines the protection space. These realms allow the

How to clear basic authentication details in chrome

烈酒焚心 提交于 2019-11-26 19:19:24
I'm working on a site that uses basic authentication. Using Chrome I've logged in using the basic auth. I now want to remove the basic authentication details from the browser and try a different login. How do you clear the current basic authentication details when using Chrome? opsb It seems chrome will always show you the login prompt if you include a username in the url e.g. http://me@example.com This is not a real full solution, see Mike's comment below. You can open an incognito window Ctrl + Shift + n each time you are doing a test. The incognito window will not remember the username and

Why my Http client making 2 requests when I specify credentials?

半腔热情 提交于 2019-11-26 17:00:27
问题 I created RESTful webservice (WCF) where I check credentials on each request. One of my clients is Android app and everything seems to be great on server side. I get request and if it's got proper header - I process it, etc.. Now I created client app that uses this service. This is how I do GET: // Create the web request var request = WebRequest.Create(Context.ServiceURL + uri) as HttpWebRequest; if (request != null) { request.ContentType = "application/json"; // Add authentication to request

How do I make a JSONP call with JQuery with Basic Authentication?

笑着哭i 提交于 2019-11-26 16:43:22
问题 Using JQuery, how would I call a JSONP API that required basic authentication? Can I programatically handle this, or does the user have to interact and enter the username and password into the logon dialog? 回答1: The JSONP request does not use the XMLHttpRequest Object / System. Hence there is no way to do this directly. I tried several times the approach mentioned in FinnNk's answer, but finally gave up after reading this discussion on the JQuery mailing list. Update When I said "no way to do

HTTP Basic Authentication credentials passed in URL and encryption

前提是你 提交于 2019-11-26 15:42:00
I have a question about HTTPS and HTTP Authentication credentials. Suppose I secure a URL with HTTP Authentication: <Directory /var/www/webcallback> AuthType Basic AuthName "Restricted Area" AuthUserFile /var/www/passwd/passwords Require user gooduser </Directory> I then access that URL from a remote system via HTTPS, passing the credentials in the URL: https://gooduser:secretpassword@www.example.com/webcallback?foo=bar Will the username and password be automatically SSL encrypted? Is the same true for GETs and POSTs? I'm having a hard time locating a credible source with this information.

How to use http.client in Node.js if there is basic authorization

心不动则不痛 提交于 2019-11-26 15:04:04
问题 As per title, how do I do that? Here is my code: var http = require('http'); // to access this url I need to put basic auth. var client = http.createClient(80, 'www.example.com'); var request = client.request('GET', '/', { 'host': 'www.example.com' }); request.end(); request.on('response', function (response) { console.log('STATUS: ' + response.statusCode); console.log('HEADERS: ' + JSON.stringify(response.headers)); response.setEncoding('utf8'); response.on('data', function (chunk) { console

Adding Basic Authorization for Swagger-UI

隐身守侯 提交于 2019-11-26 14:28:07
问题 I have currently deployed a swagger project but I am having trouble adding some basic authorization to it. Currenty when you click on the "Try it out!" button you are required to log in to an account to access the results. I have an account that I want to automatically be used everytime someone tries to access the api. Bellow is my index.html for the project: <!DOCTYPE html> <html> <head> <title>Swagger UI</title> <link href='css/screen.css' media='screen' rel='stylesheet' type='text/css'/>

Basic Authentication With XMLHTTPRequest

◇◆丶佛笑我妖孽 提交于 2019-11-26 14:13:26
问题 I am attempting to use XMLHTTPRequest to get an update on twitter. var XMLReq = new XMLHttpRequest(); XMLReq.open("GET", "http://twitter.com/account/verify_credentials.json", false, "TestAct", "password"); XMLReq.send(null); However, using my sniffer I cannot see any authorization headers being passed through. Hence, I get a 401 error response from Twitter. The account and password are correctly entered. Anyone attempt this? Can anyone give me some pointers? Thank you. 回答1: You just need to

HttpClientBuilder basic auth

夙愿已清 提交于 2019-11-26 14:07:39
问题 Since HttpClient 4.3, I have been using the HttpClientBuilder. I am connecting to a REST service that has basic authentication. I am setting the credentials as follows: HttpClientBuilder builder = HttpClientBuilder.create(); // Get the client credentials String username = Config.get(Constants.CONFIG_USERNAME); String password = Config.get(Constants.CONFIG_PASSWORD); // If username and password was found, inject the credentials if (username != null && password != null) { CredentialsProvider