What You'll Learn

@Override
    protected void configure(HttpSecurity http) throws Exception {
        http
        .authorizeRequests(authorizeRequests ->
            authorizeRequests
                .mvcMatchers("/dashboard").authenticated()
                .mvcMatchers("/user/**").hasAnyRole("USER","ADMIN")
                .mvcMatchers("/admin/**").hasRole("ADMIN")
                .mvcMatchers("/styles/**").permitAll()
                .mvcMatchers("/signup").permitAll()
                .anyRequest().denyAll()
        )
        .formLogin(formLogin ->
            formLogin
                .permitAll()
        ).logout(logout ->
             logout
                .permitAll())
        .headers().contentSecurityPolicy(csp ->
            csp.policyDirectives("default-src 'self'; object-src 'self'")        
        );       
    }
  //In your HTML
  <script>
      function alertMe(){
      	window.alert("hi");
      }
  </script>
  <div onclick="alertMe()"/>

Should be replaced by:

  //In your HTML
 <div id="clickable-div"/>

 //In your external js file
 function alertMe(){
         window.alert("hi");
 }
 document.addEventListener('DOMContentLoaded', function () {
   document.getElementById('clickable-div')
     .addEventListener('click', alertMe);
 });

   //In the HTML
   <script>
   		function alertMe(){
   		 window.alert("hi");
   		}
   		document.addEventListener('DOMContentLoaded', function () {
     document.getElementById('game-container')
       .addEventListener('click', alertMeExternally);
   	});
   </script>

becomes the ‘string to hash' of:

   function alertMe(){window.alert("hi");}document.addEventListener('DOMContentLoaded',function(){document.getElementById('game-container').addEventListener('click', alertMe);});

which you must also use in your <script> tag (replacing the formatted one in the first snippet):

<script>function alertMe(){window.alert("hi");}document.addEventListener('DOMContentLoaded',function(){document.getElementById('game-container').addEventListener('click', alertMe);});</script>