Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

184
Visualizações
Why is it bad practice to have an auto-increment primary key as a URL identifier?

I've read that it's bad practice to have the following url https://www.example.com/posts/{post_id} where post_id corresponds to the post's primary key (see below).

I don't care that users know how many posts there are and my I'm handling authorization on the backend so that a user can only access their posts (so even if a bad actor knows someone's post_id, they won't have access to it). I'm using Postgres and also don't envision moving databases.

CREATE TABLE posts (
  PRIMARY KEY (post_id),
  post_id bigint GENERATED ALWAYS AS IDENTITY
);
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

You seem to have taken care of the obvious difficulties, but I would still advise something less interpretable.

After all, if someone knows that "n" is valid in the URL, then they can try to get in using any value from 0 - n. Giving such hints seems like an unnecessary hint to those who have less than honorable intentions.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda