Giter Club home page Giter Club logo

spring-security-demo's Introduction

Http

Http is a protocol we use to send requests between computer over the internet.

Hypertext Transfer Protocol (HTTP) is an application-layer protocol for transmitting hypermedia documents, such as HTML. It was designed for communication between web browsers and web servers, but it can also be used for other purposes

HTTP Requests

Java Servlets

Java has a specification for web applications called javaEE and servlets are part of that specification. Servlet is a unit of code that will handle a HTTP request send to the servlet container. Servlet container is a implementation of JavaEE specification like Tomcat or Jetty.

Spring MVC

Spring can run on servlet container and comply with the servlet spec or with new Spring WebFlux if uses Netty server which does not implement the JavaEE.

HTTP Requests

Securing HTTP requests

On the server side when we process the HTTP request we want to know who sent the request and is he allowed to do the action.

To determine who is the user we first require him to login. Login is the authentication step, where user inputs his credentials. When credentials are checked user is logged in and each HTTP request will be authenticated.

With spring security authorization or checking of credentials is done in the ProviderManager class. ProviderManager will call all registered AuthenticationProviders these are DaoAuthenticationProvider for example, the one that is used if we create a UserDetailsService.

We can also set our own custom authentication manager if needed you can see that in the CustomAuthenticationProvider configuration

After we check users credentials we will need some information about the user with each request. This information can be his roles, username etc. This data we is called session data and we create this session object when user authenticates.

Since session data is stored on the backend we need to transfer this data to the client also. Since clients are creating HTTP requests on the client side they need to know what session data to send with each request. Here HTTP cookies come into play. Cookies are a simple map of key value pairs that are transferred with each HTTP request from the browser.

Now since our session object can grow it will slow down the communication between the client and server since each HTTP request will have to contain the session object. To reduce the amount of data we transfer we just send a session id and then server stores the map of session ids and actual session objects.

This type of security is called session based security and is the most common type in web applications.

Literature:

  1. Spring security guide

spring-security-demo's People

Contributors

brunomilicevic-croatia avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.