Skip to content

Move jwt logic from controller to middleware #77

@Flanderzz

Description

@Flanderzz

So currently in our project we are doing this really redundant thing where we get the JWT from the header, take the UserID from it and replace it then do validation on it.

This is redundant, not needed and can be done with a single middleware function/custom filter.

class JWTParseFilter implements Filter{ 
	public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse,
                         FilterChain filterChain) {
			// try to get UserId from JWT
			// replace UserID in JWT with what ever ID is there
			// send it down
			// catch any errors
	}
}

Metadata

Metadata

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions