DZone
Performance Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Performance Zone > Auto-Generating Spring Security Tutorial: Memory Realms

Auto-Generating Spring Security Tutorial: Memory Realms

Here is a look at some of the tools available for generating Spring security configurations.

Martin Farrell user avatar by
Martin Farrell
·
Oct. 11, 16 · Performance Zone · Tutorial
Like (6)
Save
Tweet
3.89K Views

Join the DZone community and get the full member experience.

Join For Free

I created a demo spring boot application under github.com/farrelmr/parkrunpbreboot.

parkrunpbreboot1

The application is simple and allows your to predict your 5km running time based on previous parkrun performances. For those who don't know what a parkrun is, it's a free 5km timed run held weekly in an increasing number of places.

Security Requirements

The site has the following links and security requirements:

http://localhost:8080/Accessible to all
http://localhost:8080/webjarsStatic Resources – Accessible to all
http://localhost:8080/about.htmlStatic page – Accessible to all
http://localhost:8080/login.htmlAccessible to all
http://localhost:8080/admin/Admin User
http://localhost:8080/rest

Accessible to all

We also have a requirement to use a memory realm with the structure –

USERPASSWORDROLES
adminadminadmin

Getting Started

The first thing we need to do is uncomment spring security in the maven pom –

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>

We can now begin to create our SecurityConfiguration using:

http://www.glenware.com/spring-security-generator

springsecuritygenerator

Memory Realm with Basic Authentication

The first step is to configure the memory realm. The other security options are Default JDBC, and LDAP, and will be covered in later tutorials

basicauthenticationspringsec

The code is available on gist.

We can then copy the generated code to com.glenware.springboot.SecurityConfig, and test the application. The whole application is secured, with the password admin/admin.

We now get the default login page:

Image title

Fine Tuning

We can now fine tune the requirements:

screen-shot-2016-10-09-at-21-17-08

Again, the code is available on gist.

This allows free access to the site, except for the admin sections as required. We also now have a formatted login page.

Conclusions

The above tutorial shows how a menu driven application can automatically and simply provide your spring security. The next areas of work are to improve JDBC and REST functionality.

Spring Security Spring Framework Memory (storage engine)

Published at DZone with permission of Martin Farrell, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Understand Source Code — Deep Into the Codebase, Locally and in Production
  • Monolith vs Microservices Architecture: To Split or Not to Split?
  • Kotlin vs Java: Which One Is the Best?
  • No Code Expectations vs Reality

Comments

Performance Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo