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.
get acme.com/{user-id}/books/{book-id}
information included within urlget acme.com/books/{book-id}
user-id must obtained session/cookie/header
i 1. (fully specified url), as
- there's single url every single resource
- it allows authorized impersonation, e.g. authorized support user access users records when necessary.
- 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
Post a Comment