Rest token authentication with HTTP header

前端 未结 2 747
终归单人心
终归单人心 2021-01-06 16:58

This is an existing system with a login screen, now I expose some services as REST service. I build an authentication-token login system for this Rest(jersey) service. User

2条回答
  •  佛祖请我去吃肉
    2021-01-06 17:03

    1/2- I'd suggest POSTing the username/password to the server, which can then return the token in the body. Makes most sense to me: you're not actually storing much on the server, so PUT would be wrong, and a query parameter doesn't make sense at all. Headers are supposed to be somewhat consistent across requests, so they don't make sense either. When actually communicating using the token, feel free to use a query parameter or header. Doesn't really matter.

    3- I'd pick a slightly longer hashing algorithm (sha256?)

提交回复
热议问题