web services - Should I include authenticated user within URL scheme? -


given web-service logged-in users, , resources each user. should url scheme include user-id or should association of http request user done via cookie or other means. e.g.

  1. get acme.com/{user-id}/books/{book-id} information included within url
  2. get acme.com/books/{book-id} user-id must obtained session/cookie/header

i 1. (fully specified url), as

  1. there's single url every single resource
  2. it allows authorized impersonation, e.g. authorized support user access users records when necessary.
  3. being self-describing, url can emailed, bookmarked, etc

i can see has problems regarding security - user-id's guessable. therefore proper, tested authorization scheme required.

what considered best-practice? missing anything?

it's use cases. 1 nice side affect of having user id there makes http caching easier on shared client shared cache. there's http varys header, doesn't work when pass authentication cookie. can make sharing of url tougher because url user has them point. can supplement redirect concept such if user gets url someone's else's user id, server can redirect/provide requesting users version of resource (possibly).

if allow anonymous access user id in path can become bit cumbersome/clunky.

most important thing keep in mind (since tagged rest) client should never have have handle user id outside of being part of obtuse url. service should providing url userid filled in user, way clients don't need concern having fill in userid or not , app matures , decide having user id or not having mistake clients still function.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -