Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8953591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:07:55+00:00 2026-06-15T14:07:55+00:00

I have a multi-tenant database with the composite key clientId – docId The routing

  • 0

I have a multi-tenant database with the composite key

clientId - docId

The routing looks like this

/api/controller/clientId/docId

For authentication I use a “global” username such as an email + password, sent in the http-header of every request via https. The username maps explicitly to a client and is available on the backend.

What’s the way to do it properly with rest and have best security?

  1. Route like above and just verify that the clientId according to the username is the same than in the routing

or

  1. Change the routing as below and get the clientId from a database before saving a record?

    /api/controller/docId

This may be an obvious question, but I’m worried about potential security issues. Or is it just a no-brainer to go with the shorter routing?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T14:07:56+00:00Added an answer on June 15, 2026 at 2:07 pm

    I think /api/controller/docId is probably the best idea or a use a single surrogate key to represent ClientId and docId (my preference).

    Unless you ever need to allow clients to view other clients resources I would hide it from the URI scheme, at worst it could be considered information leakage at best it is redundant as you have authenticated the client and know who they are anyway. It is also an overhead i.e. you still must check the client id in the url is mapped to the username and password of the request so you need to retrieve the client id on each request anyway.

    If you looked at how other multi tenanted environments work e.g. Sales Force’s you can see that they must infer the client via the security mechanism or are lucky enough to have a unique id for every object/resource.

    An approach I have seen is to put the client identifier (usually a surrogate key of somekind, avoid exposing other users db id’s!) at the root of the URL e.g. /api/{clientId}/controller/docId. In a multi tenanted environment every resource is probably/by definition unique to that client.

    A reason sometimes given for this approach is that having a unique url per customer assists with caching… /api/{clientId}/controller/docId or /api/controller/{clientId}/docId

    A brief note over basic authentication

    Nothing wrong with your approach but consider… you could retrieve the client Id whilst validating the password and user name and add that as a claim on the IPrinciple. At least that is then available in the code without any further db look ups to find it (within the life of that request).

    Going a step further… consider a two step authentication mechanism where a token is issued (following correct username and password) with the client Id actually in the token as a claim. This way, subsequent requests with the token mean you won’t need to call back the the db for every request to authenticate and retrieve information. Take a look at OAuth bearer tokens http://self-issued.info/docs/draft-ietf-oauth-v2-bearer.html (be sure to sign them) or some of the other approaches…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a full multi-tenant database with TenantID's on all the tenanted databases. This
I need to develop a multi-tenant website like sample1.mysite.com sample2.mysite.com Hold on! No, this
In a multi-tenant application I have a table with TenantId column. This table is
We have a multi-tenant database - i.e. common database used by multiple clients, hence
I am working on setting up a multi-tenant, seperate database application and have made
I am building a multi-tenant application using EF 4, I have a shared database
I have a multi-tenant MySQL database. For most things I use a tenant-id column
We have a multi-tenant system with a separate database per tenant (but with the
I have a multi-step order form built in this manner: Step 1: Choose category
I have a multi-tenant application and I'm experimenting with using the i18n gem to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.