Skip to content

Instantly share code, notes, and snippets.

@jzerbe
Created November 16, 2012 04:16
Show Gist options
  • Save jzerbe/4083996 to your computer and use it in GitHub Desktop.
Save jzerbe/4083996 to your computer and use it in GitHub Desktop.
Spring Security login form with HTML5 boilerplate
<!doctype html>
<!--
/*
* Jason Zerbe
* Copyright 2012
* Build-Id: EMPTY
*
* any comments before doctype will set IE9 to quirks mode
*/
-->
<!--[if lt IE 7]><html class="no-js lt-ie9 lt-ie8 lt-ie7"><![endif]-->
<!--[if IE 7]><html class="no-js lt-ie9 lt-ie8"><![endif]-->
<!--[if IE 8]><html class="no-js lt-ie9"><![endif]-->
<!--[if gt IE 8]><!--><html class="no-js"><!--<![endif]-->
<head>
<title>Login</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width" />
<meta name="description" content="log in to do stuff" />
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
<link rel="stylesheet" href="css/normalize.css" />
<link rel="stylesheet" href="css/main.css" />
<script src="js/vendor/modernizr-2.6.2.min.js"></script>
<link type="text/css" rel="stylesheet" href="login.css" />
</head>
<body>
<!--[if lt IE 8]>
<p class="chromeframe">You are using an <strong>outdated</strong> browser.
Please <a href="http://browsehappy.com/">upgrade your browser</a> or
<a href="http://www.google.com/chromeframe/?redirect=true">activate Google Chrome Frame</a>
to improve your experience.</p>
<![endif]-->
<div id="wrapper">
<form id="form_j_spring_security" method="post" action="./j_spring_security_check">
<label id="label_j_username" for="j_username">Username:</label>
<input id="input_j_username" name="j_username" type="text" />
<br />
<label id="label_j_password" for="j_password">Password:</label>
<input id="input_j_password" name="j_password" type="password" />
<br />
<input id="input_remember" name="_spring_security_remember_me" type="checkbox" checked="checked" />
<input id="input_submit_login" type="submit" value="Login" />
</form>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/vendor/jquery-1.8.2.min.js"><\/script>')</script>
<script src="js/plugins.js"></script>
<script src="js/main.js"></script>
</body>
</html>
@jzerbe
Copy link
Author

jzerbe commented Nov 16, 2012

Things that have to be so that the Spring Security login works:

  1. form POSTs to j_spring_security_check
  2. text input named j_username
  3. password input named j_password

@jzerbe
Copy link
Author

jzerbe commented Nov 17, 2012

official HTML5 BP has <!--[if lt IE 7]> to activate chromeframe, but I have found IE8 is kind of the cut-off for my purposes

@jzerbe
Copy link
Author

jzerbe commented Nov 30, 2012

to end the session, send user to ./j_spring_security_logout

@jzerbe
Copy link
Author

jzerbe commented Dec 5, 2012

include checkbox with element name _spring_security_remember_me to enable remember-me cookie. prevent head-to-wall banging.

@jzerbe
Copy link
Author

jzerbe commented Jun 17, 2013

Or append _spring_security_remember_me=on to your param string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment