alloc / alloc/saus

Authorized routes

Đang mở
#56 2 bình luận 0 reaction 0 người được giao Xem trên GitHub
enhancement roadmap
Ngôn ngữ chính
TypeScript
Star
38
Fork
1
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

### ⚠️ The example in this OP is outdated. See https://github.com/alloc/saus/issues/56#issuecomment-1143963756

---

Add an `authorizeRoutes` route hook, used like so:
```ts
// ./src/node/routes.ts
import { authorizeRoutes, Redirect } from 'saus'

// The route pattern is optional. If none is provided, all routes are authenticated.
authorizeRoutes('*', async (headers, url) => {
if (verify(headers)) {
return true
}
// Redirect the request, or return false to act like this route doesn't exist.
return new Redirect('/login')
})

const verify = (headers) => {
// TODO: verify a Cookie header or JWT token, etc
}
```

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.