basic-authentication

How to allow “/api/**” through my basic auth config and into my oauth config in Spring Security

大兔子大兔子 提交于 2019-11-29 17:04:25
I have an app that uses both Basic Auth and OAuth2. Some URLs are authorized using Basic Auth and "/api/**" is authorized using OAuth2. Currently, I have two Java config files ( WebSecurityConfigurerAdapter and ResourceServerConfigurerAdapter ) Each of the config files define a public void configure(HttpSecurity http) method. The trouble I'm having is that I need an elegant way to tell my app whether to use basic auth or oauth2 given the url request. Currently I'm using requestMatchers to make this happen: @EnableWebSecurity public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

HTTP basic authentication using sockets in python

守給你的承諾、 提交于 2019-11-29 15:18:06
问题 How to connect to a server using basic http auth thru sockets in python .I don't want to use urllib/urllib2 etc as my program does some low level socket I/O operations 回答1: Probably the easiest place to start is using makefile() to get a simpler file-like interface to the socket. import socket, base64 host= 'www.example.com' path= '/' username= 'fred' password= 'bloggs' token= base64.encodestring('%s:%s' % (username, password)).strip() lines= [ 'GET %s HTTP/1.1' % path, 'Host: %s' % host,

asp mvc 3 ActionFilter for basic authentication

£可爱£侵袭症+ 提交于 2019-11-29 15:08:46
问题 I have an ASP MVC3 restful service that uses basic authentication. After searching stack overflow, I created the following code. public class BasicAuthentication : ActionFilterAttribute { public override void OnActionExecuting(ActionExecutingContext filterContext) { var req = filterContext.HttpContext.Request; if (String.IsNullOrEmpty(req.Headers["Authorization"])) { filterContext.Result = new HttpNotFoundResult(); } else { var credentials = System.Text.ASCIIEncoding.ASCII .GetString(Convert

RestTemplate basic or digest Authentication with the current httpclient (4.x)

懵懂的女人 提交于 2019-11-29 14:04:01
问题 I'm trying to do Digest mostly (or Basic) Authentication using RestTemplate and httpclient (4.x) . Since I couldn't find any relevant examples of how to actually do this, I have attempted various ways to hook the various httpclient artifacts, with no luck - essentially, no Authentication header is sent at all. My current implementation is: DefaultHttpClient newHttpClient = new DefaultHttpClient(); Credentials credentials = new UsernamePasswordCredentials( username, password ); AuthScope

Set Basic HTTP Authentication in Casablanca

别等时光非礼了梦想. 提交于 2019-11-29 13:33:56
问题 I'm trying to modify the Casablanca tutorial to include basic HTTP authentication to access the Prosper API: auto fileStream = std::make_shared<ostream>(); // Open stream to output file. auto requestTask = fstream::open_ostream(U("results.html")).then([=](ostream outFile) { *fileStream = outFile; // Create http_client to send the request. http_client_config config; credentials creds( "username", "password" ); config.set_credentials( creds ); http_client client( U( "https://api.prosper.com/" )

setRequestHeader does not work in JSONP using jQuery

自古美人都是妖i 提交于 2019-11-29 13:19:54
I am building an iPhone app using jQuery Mobile, jQuery 1.7.2, and PhoneGap trying to get a JSONP from ASP.NET RESTful web service using this code, problem that I need to authenticate first and get a token, then send it back again. here is my function: var setToken = function () { var serverToken = ''; $.support.cors = true; jQuery('body').ajaxSend(function (evt, xhr) { xhr.setRequestHeader("Authorization", "Basic " + $.base64.encode(username + ":" + password)); xhr.setRequestHeader('X-Accept', 'application/json'); }); $.getJSON(url + "?jsoncallback=?", null, function (res) { console.log(res);

Basic authentication with header - Javascript XMLHttpRequest

Deadly 提交于 2019-11-29 12:47:24
I am trying to access Adyen test API that requires basic authentication credentials. https://docs.adyen.com/developers/ecommerce-integration My credentials work when accessing the API page through browser. But I get an 401 Unauthorized response when trying to access the API with XMLHttpRequest POST request. Javascript Code var url = "https://pal-test.adyen.com/pal/servlet/Payment/v25/authorise"; var username = "ws@Company.CompanyName"; var password = "J}5fJ6+?e6&lh/Zb0>r5y2W5t"; var base64Credentials = btoa(username+":"+password); var xhttp = new XMLHttpRequest(); xhttp.open("POST", url, true)

How to logout user for basic HTTP authentication

↘锁芯ラ 提交于 2019-11-29 12:05:07
Is there a solution to logout a user (make a browser clear its cached credentials and ask user to login credential once again) for basic HTTP authentication? I've already looked through the following questions: logout with basic authentication without closing webbrowser like banking sites will display HTTP authentication logout via PHP Yes, but it's not very smooth. You have a special script URL (eg /logout ; like a login script it must be in the root of the webapp to ensure the auth gets set to the right path), which, instead of requiring a valid username/password to proceed, requires an

Why my server ignores the authentication headers from an ajax request?

最后都变了- 提交于 2019-11-29 11:43:47
From JavaScript I used: xhr.setRequestHeader("Authorization", make_base_auth(username,password)); However the HTTP request doesn't have an Authorization header: OPTIONS /restService/index?_=1362589672203 HTTP/1.1 Host: myappinheroku.herokuapp.com User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:19.0) Gecko/20100101 Firefox/19.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: es-MX,es-ES;q=0.8,es-AR;q=0.7,es;q=0.5,en-US;q=0.3,en;q=0.2 Accept-Encoding: gzip, deflate Origin: http://127.0.0.1:8081 Access-Control-Request-Method: GET Access-Control-Request-Headers

How can I use Basic HTTP Authentication in PHP?

一个人想着一个人 提交于 2019-11-29 11:42:47
问题 I'm trying to use Basic HTTP Authentication and followed the example on the PHP manual page. But it doesn't work for me. The variable $_SERVER['PHP_AUTH_USER'] doesn't seem to be set. When a user try to log in, the user is prompted whith a new login-dialog. The server is running PHP 5.3.3 and I have tried with Google Chrome and Internet Explorer. Here is the simple example that I used: <?php if (!isset($_SERVER['PHP_AUTH_USER'])) { header('WWW-Authenticate: Basic realm="Jonas Realm"'); header