w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Should HTTP Basic Authentication be used for client or user API authentication?
By authenticate the client you probably mean the usage of API Key, this mechanism is used to track the concrete application/client. The second thing is that it gives you the possibility to disable the application by disabling the key, for example when client's author removes his account from the service. If you want to make your API public then it is a good idea. But you need to remember that it gives you no real protection, everybody can download the client and extract that key.

Categories : Api

Configure IIS Windows Authentication to return HTTP 403 instead of HTTP 401 for permission denied with an authenticated user
What did not work I tried just about every IIS configuration permutation with no luck. I goofed around with the Windows authentication provider settings, like NTLM, Negotiate, and Negotiate:Kerberos. None of them seemed to do the trick. This isn't too much of a surprise since the browsers are deciding to try authentication again, even though they probably shouldn't. 401 Unauthorized The request requires user authentication. The response MUST include a WWW-Authenticate header field (section 14.47) containing a challenge applicable to the requested resource. The client MAY repeat the request with a suitable Authorization header field (section 14.8). If the request already included Authorization credentials, then the 401 response indicates that authorization has been refu

Categories : Asp Net

android-async-http library get http response header from Response Handler
@Zapnologica, it seems, that author of library provided changes based on this pull request: https://github.com/loopj/android-async-http/pull/170 But it is not released yet, at least latest available .jar version of library is 1.4.3 and it does not include these changes, unfortunately. The only option we may try to use is cloning/forking git repo and including its sources into your project. UPDATE: Seems library will soon be added to maven central repo, but at least now I was able to add 1.4.4 SNAPSHOT build using gradle for my project with such config changes: repositories { ... //android-async-client repo maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } } And then in dependencies section: compile 'com.loopj.android:android-async-http:1.

Categories : Android

Overriding the authentication failure handler - Symfony2
I see you're trying to pass the login_path to your authentication failure handler... ... you should inject @router, adapt the __construct method and generate the url with the route name ( not pattern ) used by your firewall inside the auth failure handler. then redirect the user there... login_path: your_login_route_name # <- not a pattern like /login this way changing the name of the firewall will not break your application! if you don't even want to break the application when changing the route name you can make this configurable aswell: config.yml parameters: login.route_name: my_login_route_name routing.yml %login.route_name%: pattern: /login security.yml security: firewalls: your_firewall_name: failure_handler: auth.fail

Categories : PHP

Sometimes the Game Center authentication handler is never called
I had this experience during testing on one of our games on the sandbox server, there really was no notification or authentication handler call sometimes, then it would just work a half hour later. We summised that it was due to Apple's server end as we never encountered this problem outside of the Game Center sandbox. Sorry that the explanation is a little vague and there's nothing concrete that you can do. But it's not your code. It's on the end that you cannot control.

Categories : IOS

symfony 2 how to display the error after login with custom authentication handler
You probably want to display a message to the user. You can display a flash message and redirect the user. $request->getSession()->setFlash('error', $exception->getMessage()); If you look at the FosUserBundle they display a message direcly in the template https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/views/Security/login.html.twig https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Controller/SecurityController.php Hope it's helpful Best regard

Categories : Authentication

http handler does no work in MVC IIS 8.0
Just in case you want to use the Mvc Routing here is an implementation of the custom route handler for ManagedFusion.Web.CaptchaImageHandler. public class CaptchaRouteHandler:IRouteHandler { public System.Web.IHttpHandler GetHttpHandler(RequestContext requestContext) { return new ManagedFusion.Web.CaptchaImageHandler(); } } Then, your route definition in RouteConfig.RegisterRoutes define the custom route: public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.Add( "Captcha Route", new Route( "captcha.ashx", new CaptchaRouteHandler())); routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", def

Categories : Asp Net

FileServer handler with some other HTTP handlers
You need to use the http.StripPrefix handler: http.Handle("/files/", http.StripPrefix("/files/", http.FileServer(http.Dir(".")))) See here: http://golang.org/pkg/net/http/#example_FileServer_stripPrefix

Categories : Go

Doesn`t run http handler in asp.net application
If you're in classic mode, then asp.net won't get called by IIS unless IIS knows the file type that should get mapped. In your IIS control panel, you should be able to configure the file types handled by ASP.NET. Otherwise, it's going to assume that a file type is for a physical file, which it can't find on the file system.

Categories : C#

Custom HTTP handler not working in .NET
Although it is very unclear to understand what you are trying to do, please note that SharePoint provide this feature out-of-the-box. For example, if you PDF is located at : http://yourserver/documents/somedocument.pdf You can get a forced download of the file using: http://youserver/_layouts/download.aspx?SourceUrl=/documents/somedocument.pdf

Categories : Dotnet

http handler not showing image
You should use that if (context.Request.QueryString["Name"] != null) { querySqlStr = "SELECT Photo from UserProfile where UserName= @username" ; } conn = new SqlConnection(connString); SqlCommand command = new SqlCommand(querySqlStr, conn);. command.Parameters.Add("@username",context.Request.QueryString["Name"]); But as you have it must be with single quotes querySqlStr = "SELECT Photo from UserProfile where UserName='" + context.Request.QueryString["Name"] + "'"; As i said in my comment DO NOT USE string concatenation. You will gain many things. But i think your problem is that you are trying to put in ImageUrl byte[]. It just need path. See this http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.image.imageurl.aspx If you want to loa

Categories : C#

How to Reference HTTP Handler from UserControl
I couldn't understand what exactly you need here. But You can load image from user control using below code. using System.Web; using System.Web.UI; using System.IO; namespace WebApplication1 { public class ImageHandler : Page, IHttpHandler { public new void ProcessRequest(HttpContext context) { context.Response.Clear(); ChartCtl chartCtl = (ChartCtl)LoadControl(ResolveClientUrl("ChartCtl.ascx")); MemoryStream ms = new MemoryStream(); ms = chartCtl.renderChart(ms); context.Response.Clear(); context.Response.ContentType = "image/jpeg"; context.Response.BinaryWrite(ReadFully(ms)); context.Response.End(); } public static byte[] ReadFully(Stream input)

Categories : C#

How to pass type into an http handler
use a closure. in app/c change Index to: func Index(db *sql.DB) func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) { // do stuff with db here fmt.Fprintf(w, "Hello world!") } } then in your main function use it like so: r.HandleFunc("/", c.Index(db)) The Index function returns an anonymous function that fits the the HandleFunc type and also closes over the value of the db that was passed in giving your handler access to that variable.

Categories : Go

Background thread created in http handler
Yes. They're all part of the same application domain that dies with the worker process. With a normal Thread if not marked as IsBackground it will basically hold the process open until it completes. If you have overlapping worker processes enabled (true by default) this isn't a problem for new requests coming in as a new process will start, but if you have it turned off it will wait until the existing one quits, basically halting the site. So really if you want them to live longer you either have to increase timeouts or have them handled by some external process using IPC etc.

Categories : C#

How to write the response to a file in HTTP Handler
Well, the documentation is pretty straight forward about this: The [SaveAs] call specifies that the request be saved as a text file in a directory where the ASP.NET process identity has been granted write permissions, and that any header information included in the request is included in the file. You can thus simply save the entire HttpRequest (including the headers in a file). You can simply determine the path and a boolean indicating whether you want to incude the headers as well: context.Request.SaveAs(@"c://myLogFile.log",true)

Categories : C#

ActiveReports HTTP handler shared hosting
In case you are facing issues related to permissions, then I would suggest you to run the application on MediumTrust. Please refer to the following documentation link that will guide you through: http://helpcentral.componentone.com/nethelp/AR7Help/OnlineEn/arMediumTrustSupport.html On further searching, I found the following link wherein a similar issue has been discussed on the godaddy’s support page. This might be informative for you: http://support.godaddy.com/groups/web-hosting/forum/topic/request-to-add-arcacheitem-handler-to-iis/

Categories : Asp Net

not working loader complete handler if url has only http://abc.com
This is possibly a security sandbox issue. See here for a similar issue and resolution - http://www.kirupa.com/forum/showthread.php?357992-www-works-without-www-doesn-t-problem-with-URLRequest#post_2587691

Categories : Actionscript

Using Goroutines for background work inside an http handler
Go multiplexes goroutines onto the available threads which is determined by the GOMAXPROCS environment setting. As a result if this is set to 1 then a single goroutine can hog the single thread Go has available to it until it yields control back to the Go runtime. More than likely doSomeBackgroundWork is hogging all the time on a single thread which is preventing the http handler from getting scheduled. There are a number of ways to fix this. First, as a general rule when using goroutines, you should set GOMAXPROCS to the number of CPUs your system has or to whichever is bigger. Second, you can yield control in a goroutine by doing any of the following: runtime.Gosched() ch <- foo foo := <-ch select { ... } mutex.Lock() mutex.Unlock() All of these will yield back to the Go ru

Categories : Go

curl http handler for solarium solr error
As already mentioned, it looks like the cURL extension is not installed on his system, so either install it if possible, or in case it's just disabled, enable it, or simply use a different adapter. https://github.com/basdenooijer/solarium#requirements Requirements Solarium only supports PHP 5.3 and up. It's highly recommended to have Curl enabled in your PHP environment. However if you don't have Curl available you can switch from using Curl (the default) to another client adapter. The other adapters don't support all the features of the Curl adapter. HTTP Adapter https://github.com/basdenooijer/solarium/blob/master/examples/6.1.4-http-adapter.php ... // create a client instance $client = new SolariumClient($config); // set the adapter to http $client->setAdapter('Solari

Categories : PHP

Calling ASP.Net HTTP handler on click of checkbox in Rad Grid
$(document).ready(function () { $("#<%=RadGrid1.ClientID%> input[id*="HeaderCheckBox1"]:checkbox").click(function () { // write code http handler alert("Checked"); }); Then write code for calling the http handler for more info go through following link http://brijbhushan.net/2011/05/29/call-httphandler-from-jquery-pass-data-and-retrieve-in-json-format/

Categories : Javascript

Angular: Default handler for unhandled http errors
Assuming that you know which errors needs to be suppressed and which one need to be propagate. Also since the Response interceptor is a function that returns promise itself You can catch the response for failure case and instead of propagating it up the stack you can return something such as empty response. If you look at the sample example in angular documentation for interceptor $provide.factory('myHttpInterceptor', function($q, dependency1, dependency2) { return function(promise) { return promise.then(function(response) { // do something on success }, function(response) { // do something on error if (canRecover(response)) { return responseOrNewPromise; // This can suppress the error. } re

Categories : Javascript

How can I safely handle POST parameters in an HTTP Handler using C#?
There is nothing wrong with omitting parameters to an endpoint. As the developer you are in charge of enforcing what the client is allowed send to you. If you expect a parameter and it's missing, throw an error (e.g. HttpException). If you are creating or updating data (i.e. inserting or updating records in a database) the best method would be a POST or PUT. Edit - Here is an example of how you can handle the input: public void ProcessRequest(HttpContext context) { //Maybe you require a value? if (string.IsNullOrEmpty(context.Request["something"])) { throw new HttpException(400, "You need to send a value!"); } //Maybe you require a certain value? if (context.Request["something"] != "beerIsGood") { throw new HttpException(400, "You need to send the

Categories : C#

node.js http-proxy how to set timeout and a handler on request
You may want to try this : proxy.on('error', function(err, preq, pres){ pres.writeHead(500, { 'Content-Type': 'text/plain' }); pres.write("An error happened at server. Please contact your administrator."); pres.end(); });

Categories : Node Js

Get the Http response status using 'httpClient(postRequest,Handler)' method
Is there any way to use the first method, and still be able to get the the Response status? No. Here's what you do HttpResponse response = httpclient.execute(request); ResponseHandler handler = ...; String JSONResult = handler.handleResponse(response); StatusLine status = response.getStatusLine(); Now you have access to the status from the HttpResponse object and are able to process the response with a ResponseHandler to get the json result. The point of the different methods is that you don't really care about the status, only the handled response.

Categories : Java

How to get label's text by HTTP handler (.ashx) in repeater control
If you are not married to the idea of using an HTTP Handler, then I suggest making a method in your .aspx page's code-behind that does the same logic your handler is doing minus the content-type stuff, like this: protected string GetName(int pro_id) { return DBHelpername.name(pro_id); } Now in your markup you can use this method, like this: <asp:Label ID="Label1" runat="server" Text='<%# GetName((int)Eval("id")) %>'> </asp:Label>

Categories : Asp Net

set up gerrit with http authentication
Gerrit it expecting the authentication to be provided. It does not allow anonymous access when you use HTTP authentication. For this to work you need to authenticate at the root and your Location block should look like this: <Location "/"> AuthType Basic AuthName "Gerrit Code Review" AuthBasicProvider file AuthUserFile /usr/local/apache/passwd/passwords Require valid-user </Location>

Categories : Apache

CasperJS HTTP Authentication
I believe you need to call casper.setHttpAuth() before you load the page. It also looks like you forgot to call casper.exit() at the end of casper.run(). var x = require('casper').selectXPath; var casper = require('casper').create({ verbose: false, logLevel: 'debug' }); casper.options.viewportSize = {width: 1366, height: 667}; casper.start(); casper.setHttpAuth('here_i_type_username', 'here_password'); casper.thenOpen('https://mysite.com/a/dashboard', function() { this.test.assertUrlMatch(/^https://mysite.com/a/dashboard$/); }); casper.run(function() { this.test.renderResults(true); this.exit(); });

Categories : Testing

Setting up HTTP authentication in a dev box
Here's a rough example to do HTTP auth in nginx and then proxy the connection to the original source: location /couchdb { auth_basic "Restricted"; auth_basic_user_file htpasswd; rewrite /couchdb/(.*) /$1 break; # Optional, depends on what you're proxying to proxy_pass http://localhost:5984; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } The above is from the couchdb docs, but the general idea is applicable to any HTTP-based app you want to protect. You'd need to repeat this config block for every distinct app. Note the rewrite in the above setup lets you work with apps that don't expect to live anywhere but the URL root. It is not required. Also note that if you want to have a single page wh

Categories : Http

gSOAP HTTP Authentication
I have used tcpdump to catch the package sent between web service server and client and I found that there is no http header sent when the client call the function of the web service. So I have done some search in the documentation of gSOAP and found this sentence: A client may use the http:// prefix. When absent, no HTTP header is sent and no HTTP-based information will be communicated to the service. It solves my problem...

Categories : C++

HTTP authentication: how to debug .htpasswd?
Are you actually using the ModSecurity (mod_security) application firewall module? (That's what the tag indicates, but...?) If so -- or in any case -- first rule out the simpler problem: Review your host's httpd-error.log (or similarly named) log file, and make sure that your situation is not due to an Apache auth misconfiguration or related problem. E.g. you might see authentication failure for "/": Password Mismatch (or for whatever path in your case). There is a good amount of advice on SO if you search on htaccess and htpassword, or look at posts tagged with .htaccess, htpasswd, or authentication. If you're using Apache httpd version 2.4.4, note that there is a known bug in the htpasswd utility released with it. See this SO answer elsewhere for workarounds relative to it. Good

Categories : Apache

HTTP Authentication headers with no "realm"
WWW-Authenticate: Negotiate WWW-Authenticate: NTLM The problem is that your webserver is requesting NTLM authentication, so it wont accept BasicAuth. Use NTML authentication while sending request or change your webserver config to allow Basic authentication. Dont use BasicAuth because it sends user/pwd in plaintext over the network. Minimum safe is DigestAuth or NTLM or GSSNegotiate auth.

Categories : Python

How to perform authentication using just the HTTP GET method?
In step 3, rather than thinking of a "public key", think of a "session token". Specifically, A redirects to B with http://b.application.com?token=123-3-2-1-3-2-2-1-2-32-3-5-2-4-5245 Tokens should be unique and short-living. B then contacts A directly and asks about the identity behind the session token: http://a.application.com/userservice/getuser/123-3-2-1-3-2-2-1-2-32-3-5-2-4-5245 Because B contacts A directly, there is no way for users to forge invalid tokens - a random token just points to non-existing session at A.

Categories : Authentication

How to set timeout for rails HTTP authentication?
If a user leaves the site, or closes their browser, etc, and you would like them to stay logged in: In your SessionsController: def create member = Member.find_by_user_name(params[:user_name]) if member && member.authenticate(params[:password]) session[:member_id] = member.id if params["remember_me"] == "1" cookies[:digest] = {:value => member.password_digest, :expires => Time.now + 720000} else cookies[:digest] = nil end redirect_to (url_to_go_to_after_login), :notice => "Logged in!" else redirect_to (login_url), :alert => "Invalid email or password" end end How to log out a user: def destroy session[:member_id] = nil cookies[:digest] = nil redirect_to url_to_go_to_after_logout, :n

Categories : Ruby On Rails

Zend 2.2 trouble for HTTP Authentication
If you want to set an HTTP auth for an entire module, here's what to do (at least how I did it) : In Module.php : public function onBootstrap(MvcEvent $e){ $sharedEvents=$e->getApplication()->getEventManager()->getSharedManager(); $sharedEvents->attach(__NAMESPACE__,MvcEvent::EVENT_DISPATCH, array($this, 'authHttp')); } public function authHttp(MvcEvent $e){ $serviceManager = $e->getApplication()->getServiceManager(); $request=$e->getRequest(); $response=$e->getResponse(); if(!( $request instanceof endHttpRequest && $response instanceof endHttpResponse )){ return; // we're not in HTTP context - CLI application? } // Your adapter wi

Categories : Http

How to define a handler for http errors when loading view content using ngView in AngularJs
Maybe you can use the $routeChangeError event. This event will be emitted i.a. if the template can't be loaded.

Categories : Javascript

Setting a custom cookie in the HTTP headers inside a SOAP Message handler
We also needed to get a JSESSIONID recent - and to pass it back in subsequent requests. Using various different answers (mostly from StackOverflow and an example of an SSO client on the IBM site) we extended SOAPHandler to do it: import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.Set; import java.util.List; import javax.xml.ws.handler.MessageContext; import javax.xml.ws.handler.soap.SOAPHandler; import javax.xml.ws.handler.soap.SOAPMessageContext; import com.sun.istack.internal.Nullable; public class SoapMessageHandler implements SOAPHandler<SOAPMessageContext> { private String sessionCookie = ""; @Override public void close(MessageContext arg0) { } @SuppressWarnings({ "rawtypes", "unchecked" }) @Override publi

Categories : Java

Can Basic HTTP authentication use a default username?
There is no way for an HTTP server to specify a default username to an HTTP client, in any authentication scheme, and there is no way for an HTTP server to ask an HTTP client to ignore the username field when prompting for credentials. All you can do is configure the HTTP server to ignore usernames (which is a bad idea), and then tell your users not to type them in when prompted.

Categories : Http

OpenStreetMap: HTTP Basic Authentication with Python 3
Solved by using Requests. On Debian the package name is "python3-requests". Here is my script: #!/usr/bin/env python3 import requests url = 'http://api.openstreetmap.org/api/0.6/notes' username = input('username > ') password = input('password > ') def send_note(lat, lon, text): data = dict(lat=lat, lon=lon, text=text) requests.post(url, data=data, auth=(username, password)) lat = input('lat > ') lon = input('lon > ') text = input('text > ') send_note(lat, lon, text) Ciao!

Categories : Python

Apache Http Digest Authentication using Java
Try this code from Apache : public static void main(String[] args) throws Exception { HttpClient client = new HttpClient(); client.getState().setCredentials( new AuthScope("myhost", 80, "myrealm"), new UsernamePasswordCredentials("username", "password")); // Suppose the site supports several authetication schemes: NTLM and Basic // Basic authetication is considered inherently insecure. Hence, NTLM authentication // is used per default // This is to make HttpClient pick the Basic authentication scheme over NTLM & Digest List authPrefs = new ArrayList(3); authPrefs.add(AuthPolicy.BASIC); authPrefs.add(AuthPolicy.NTLM); authPrefs.add(

Categories : Java

HTTP Error 407 Proxy authentication required
I had the same problem. The following worked for me. Authenticator.setDefault(new Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication("username","password".toCharArray()); } });

Categories : Java



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.