Support for Non-401 Error Codes from the validateFunc

Aperta
#245 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
javascript, node.js

Direzione di ricerca

Inizia leggendo la gestione di validateFunc nel plugin dei cookie e confrontala con il comportamento di validate di @hapi/basic descritto nell'issue. Il lavoro è completato quando la validazione può restituire un errore Boom diverso da 401, ad esempio 403 Forbidden, per un cookie non valido per la regione richiesta, con test che coprano lo stato della risposta.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

feature
Support plan
  • is this issue currently blocking your project? (yes/no): No
  • is this issue affecting a production system? (yes/no): No
Context
  • node version: v14.17.0
  • module version: 11.0.2
  • environment (e.g. node, browser, native): Node
  • used with (e.g. hapi application, another framework, standalone, ...): Hapi application (Hapi version = 20.2.1)
  • any other relevant information:
What problem are you trying to solve?

I have a system that involves multiple different "regions" of authorization, I want a cookie to only be valid for one of these "regions", and I have added validation checks into the validateFunc. I would love be able to respond to the client with a 403 Forbidden when the cookie provided is for a different "region" than that which it is trying to access.

Example:
I have "regions" 1 and 2, and an authorization cookie is used for region 1, but the user is making a request to GET /region/2 I would like to be able to throw boom.forbidden(), and it set the response code to 403 instead of the plugin only throwing 401 to the user.

Do you have a new or modified API suggestion to solve the problem?

I think a solution following a similar vein as to how @hapi/basic does it where if the validateFunc throws an error(/Boom error) it replaces the default boom.unauthorized()

From the @hapi/basic API documentation for the validate function:

  • Throwing an error from this function will replace default Boom.unauthorized error
Lingua principale
JavaScript
Stelle
229
Fork
99
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di hapijs/cookie

Tutte le issue di hapijs/cookie

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.