Custom authentication in Spring

前端 未结 3 584
被撕碎了的回忆
被撕碎了的回忆 2021-02-06 16:16

I have a question. In Struts, I have an Action that deals with user authentication, i.e., I took the user\'s credentials and used a DAO to validate user credentials. I want to m

3条回答
  •  北荒
    北荒 (楼主)
    2021-02-06 16:55

    You can write you own validation mechanism for Spring Security. It have to consists of following parts:

    • Auth Filter - reads data from request, then call Auth Provider with credentials token (instance of class Authentication)
    • Auth Provider - accepts this auth token (filter can create different tokents, and there can be different auth providers, for each token type), and try to authenticate (calling your service, at your case). After auth you may (or may not) call User Details Service or fill all user data right there
    • User Details Service - load signed in user details from somewhere (from jdbc, other service, etc)

提交回复
热议问题