Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Spring Security - Third Edition

You're reading from  Spring Security - Third Edition

Product type Book
Published in Nov 2017
Publisher Packt
ISBN-13 9781787129511
Pages 542 pages
Edition 3rd Edition
Languages
Authors (3):
Mick Knutson Mick Knutson
Profile icon Mick Knutson
Peter Mularien Peter Mularien
Profile icon Peter Mularien
ROBERT WILLIAM WINCH ROBERT WILLIAM WINCH
View More author details

Table of Contents (19) Chapters

Preface 1. Anatomy of an Unsafe Application 2. Getting Started with Spring Security 3. Custom Authentication 4. JDBC-Based Authentication 5. Authentication with Spring Data 6. LDAP Directory Services 7. Remember-Me Services 8. Client Certificate Authentication with TLS 9. Opening up to OAuth 2 10. Single Sign-On with the Central Authentication Service 11. Fine-Grained Access Control 12. Access Control Lists 13. Custom Authorization 14. Session Management 15. Additional Spring Security Features 16. Migration to Spring Security 4.2 17. Microservice Security with OAuth 2 and JSON Web Tokens 18. Additional Reference Material

Displaying active sessions for a user

You've probably seen how many websites allow a user to view and forcibly log out sessions for their account. We can easily use this forcible logout functionality to do the same. We have already provided UserSessionController, which obtains the active sessions for the currently logged in user. You can see the implementation as follows:

    //src/main/java/com/packtpub/springsecurity/web/controllers/
UserSessionController.java

@Controller
public class UserSessionController {
private final SessionRegistry sessionRegistry;
@Autowired
public UserSessionController(SessionRegistry sessionRegistry) {
this.sessionRegistry = sessionRegistry;
}
@GetMapping("/user/sessions/")
public String sessions(Authentication authentication, ModelMap model) {
List<SessionInformation> sessions = sessionRegistry...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}