Set cookies for cross origin requests

Cross site approach To allow receiving & sending cookies by a CORS request successfully, do the following. Back-end (server): Set the HTTP header Access-Control-Allow-Credentials value to true. Also, make sure the HTTP headers Access-Control-Allow-Origin and Access-Control-Allow-Headers are set and not with a wildcard *. For more info on setting CORS in express js read the … Read more

PHP Sessions across sub domains

I do not know if the problem still exists, but I just ran into the same problem and solved it setting a session name before calling session_set_cookie_params(): $some_name = session_name(“some_name”); session_set_cookie_params(0, “https://stackoverflow.com/”, ‘.example.com’); session_start(); I have changed nothing in my php.ini but now everything is working fine.

How to implement REST token-based authentication with JAX-RS and Jersey

How token-based authentication works In token-based authentication, the client exchanges hard credentials (such as username and password) for a piece of data called token. For each request, instead of sending the hard credentials, the client will send the token to the server to perform authentication and then authorization. In a few words, an authentication scheme … Read more

Performing user authentication in Java EE / JSF using j_security_check

I suppose you want form based authentication using deployment descriptors and j_security_check. You can also do this in JSF by just using the same predefinied field names j_username and j_password as demonstrated in the tutorial. E.g. <form action=”j_security_check” method=”post”> <h:outputLabel for=”j_username” value=”Username” /> <h:inputText id=”j_username” /> <br /> <h:outputLabel for=”j_password” value=”Password” /> <h:inputSecret id=”j_password” /> … Read more

Validate a username and password against Active Directory?

If you work on .NET 3.5 or newer, you can use the System.DirectoryServices.AccountManagement namespace and easily verify your credentials: // create a “principal context” – e.g. your domain (could be machine, too) using(PrincipalContext pc = new PrincipalContext(ContextType.Domain, “YOURDOMAIN”)) { // validate the credentials bool isValid = pc.ValidateCredentials(“myuser”, “mypassword”); } It’s simple, it’s reliable, it’s 100% … Read more