basic-authentication

Testing HTTP Basic Auth in Rails 2.2+

坚强是说给别人听的谎言 提交于 2019-11-30 08:10:05
问题 As part of an API I am building, there is a user authentication method which upon success, returns a payload of useful user information, API token, etc. In writing functional tests for the controller that handles this, I am running in to an issue testing HTTP Basic auth; I have found numerous blogs that mention the following code should be used to spoof headers for an authentication attempt: @request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Basic.encode_credentials

Login Form For Http Basic Auth

大城市里の小女人 提交于 2019-11-30 08:08:48
问题 I am running a Perl application named bitlfu.For login it is using something like Apache HTTP Basic Auth but not a form.I want to make form for the login with username and password field. I have tried JavaScript and PHP with no results till now. So I need help! PS: this kind of url works http://user:password@host.com 回答1: I think a simple JavaScript like: document.location='http://' + user + ':' + pass + '@mydomain.tld'; should do the work. So basically, you have to create a form, with a user

HTTP Client based on NodeJS: How to authenticate a request?

十年热恋 提交于 2019-11-30 07:57:17
This is the code I have to make a simple GET request: var options = { host: 'localhost', port: 8000, path: '/restricted' }; request = http.get(options, function(res){ var body = ""; res.on('data', function(data) { body += data; }); res.on('end', function() { console.log(body); }) res.on('error', function(e) { console.log("Got error: " + e.message); }); }); But that path "/restricted" requires a simple basic HTTP authentication. How do I add the credentials to authenticate? I couldn't find anything related to basic http authentication in NodeJS' manual . Thanks in advance. You need to add the

Apache authentication: Redirect on failure, reliably?

一世执手 提交于 2019-11-30 07:19:44
I've set my ErrorDocument 401 to point to my website's account creation page, but not all browsers seem to honor this redirect (Safari). Also, other browsers (Firefox, Chrome) never quit asking for the password and show the ErrorDocument. This causes a good number of users to give up trying after many password attempts without seeing the account creation page. Is there any way to make the redirect more reliable, without trashing basic authentication altogether? The simple answer to your question is no, you can't make this more reliable without implementing custom authentication. The only way

How to debug urllib2 request that uses a basic authentication handler

血红的双手。 提交于 2019-11-30 07:05:56
问题 I'm making a request using urllib2 and the HTTPBasicAuthHandler like so: import urllib2 theurl = 'http://someurl.com' username = 'username' password = 'password' passman = urllib2.HTTPPasswordMgrWithDefaultRealm() passman.add_password(None, theurl, username, password) authhandler = urllib2.HTTPBasicAuthHandler(passman) opener = urllib2.build_opener(authhandler) urllib2.install_opener(opener) params = "foo=bar" response = urllib2.urlopen('http://someurl.com/somescript.cgi', params) print

HTTP basic authentication not working in python 3.4

随声附和 提交于 2019-11-30 07:01:15
I am trying to login to a REST API using HTTP Basic Authentication but it is not working and giving the error HTTP error 400: Bad Request Here is my code: import urllib.parse import urllib.request import urllib.response # create an authorization handler #auth_handler = urllib.request.HTTPPasswordMgrWithDefaultRealm() auth_handler = urllib.request.HTTPBasicAuthHandler() # Add the username and password. # If we knew the realm, we could use it instead of None. userName = "username" passWord = "pass" top_level_url = "http URL" auth_handler.add_password(None, top_level_url, userName,passWord) #

What is the cause and solution to SVN: Could not authenticate to server: rejected Basic challenge?

假如想象 提交于 2019-11-30 06:03:51
If you search around the web you will see this question asked a lot but there are no clear answers. Here is my particular case. I am using Versions SVN client on a mac but I get the same problem when using the command line. I have personal repo credentials to someone else's repo and it is working on my one machine where I set it up 6 months ago. I copied my .ssh folder from my user directory to a different machine, installed versions on that machine, and set up by login credentials, only it is failing with the following message: authorization failed: Could not authenticate to server: rejected

Getting Basic Authentication to work with ColdFusion

无人久伴 提交于 2019-11-30 05:59:46
问题 I am trying to send an authenticated POST request using ColdFusion, but for some reason, the server is rejecting the request as unauthorized. I have verified that the credentials are correct. <cfhttp url="https://api.juspay.in/order/create" method="POST" username="320EABE1225D45E6B13DF5D3D2BBDB80" password=""> <cfhttpparam name="amount" type="formField" value="10"> <cfhttpparam name="order_id" type="formField" value="cfhttp_test_order_001"> <cfhttpparam name="customer_id" type="formField"

Adding HTTP Basic Authentication Header to Backbone.js Sync Function Prevents Model from Being Updated on Save()

不打扰是莪最后的温柔 提交于 2019-11-30 05:34:05
问题 I'm working on a web application that is powered by a restful API written with Python's CherryPy framework. I started out writing the user interface with a combination of jQuery and server side templates, but eventually switched to Backbone.js because the jQuery was getting out of hand. Unfortunately, I'm having some problems getting my models to sync with the server. Here's a quick example from my code: $(function() { var User = Backbone.Model.extend({ defaults: { id: null, username: null,

Spring Security with basic auth redirecting to /error for invalid credentials

断了今生、忘了曾经 提交于 2019-11-30 05:16:08
问题 I have a spring boot application running with spring security using basic auth. When proper basic auth credentials are supplied, everything is good, but for incorrect auth credentials, spring comes up with a HttpRequestMethodNotSupportedException: Request method 'POST' not supported exception. According to the logs, the authentication failure has been identified by spring, but that's not what comes out. 2015-08-12 09:33:10.922 INFO 16988 --- [nio-8080-exec-4] o.s.b.a.audit.listener