Skip to content

Instantly share code, notes, and snippets.

@wiverson
Last active August 22, 2021 17:54
Show Gist options
  • Save wiverson/66b73829f4a517861fca2c8be19549af to your computer and use it in GitHub Desktop.
Save wiverson/66b73829f4a517861fca2c8be19549af to your computer and use it in GitHub Desktop.

Spring Security Guts

What Spring Security is and how its core features like authentication, authorization or common exploit protection work. Also, a comprehensive FAQ.

@Controller
public class MyController {
  @GetMaping("/login")
  public String login(Model model, CsrfToken token) {
    // the token will be injected automatically
    return "/templates/login";
  }
}

Add CSRF To HTML Automatically

https://dev.to/nicholas_moen/what-i-learned-while-using-django-with-htmx-and-alpine-js-24jg

<script>
  document.body.addEventListener(
    'htmx:configRequest', (event) => {
      event.detail.headers['X-CSRFToken'] = '{{ csrf_token }}';
  })
</script>

Spring Security and JWT

Database-Backed Spring Security

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