rest - Security Attacks possible on TokenBased Authentication? -


i have designed web application uses simple implementation of jwt token's provide authentication/authorization.

my implementation :

  1. there 2 types of urls's public , secure.
  2. public urls generate token username/password.
  3. i have added filter on secure url check authorization header , jwt token.

    @bean     public filterregistrationbean jwtfilter()  {      final filterregistrationbean registrationbean = new       filterregistrationbean();      registrationbean.setfilter(new jwtfilter());      registrationbean.addurlpatterns("/secure/*");       return registrationbean; 

    }

  4. filter validate token. haven't added expiration date yet.

    final httpservletrequest request = (httpservletrequest) req; final httpservletresponse response = (httpservletresponse) res; final string authheader = request.getheader("authorization");  if ("options".equals(request.getmethod())) {     response.setstatus(httpservletresponse.sc_ok);      chain.dofilter(req, res); } else {      if (authheader == null || !authheader.startswith("bearer ")) {         throw new servletexception("missing or invalid authorization header");     }      final string token = authheader.substring(7);      try {         final claims claims = jwts.parser().setsigningkey(secretkey.tostring).parseclaimsjws(token).getbody();         request.setattribute("claims", claims);     } catch (final signatureexception e) {         throw new servletexception("invalid token");     }      chain.dofilter(req, res); } 

this providing authentication , immune csrf.no 1 can create valid token without secret key.

are there other attacks possible on token base authentication service have missed?


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

php - Cannot override Laravel Spark authentication with own implementation -

Qt QGraphicsScene is not accessable from QGraphicsView (on Qt 5.6.1) -