Update Apache SSL configuration and enhance security features across multiple files. Changed X-Frame-Options to SAMEORIGIN for better security, added optional Content Security Policy headers for testing, and improved password handling with HaveIBeenPwned checks during user registration and password reset. Implemented passkey login functionality in the authentication flow, including UI updates for user experience. Enhanced image upload processing with size limits and validation, and added rate limiting for various API endpoints to prevent abuse.
Some checks failed
Code Analysis (JS/Vue) / analyze (push) Failing after 51s
Some checks failed
Code Analysis (JS/Vue) / analyze (push) Failing after 51s
This commit is contained in:
34
server/utils/webauthn-encoding.js
Normal file
34
server/utils/webauthn-encoding.js
Normal file
@@ -0,0 +1,34 @@
|
||||
export function toBase64Url(buf) {
|
||||
if (buf == null) return ''
|
||||
if (typeof buf === 'string') return buf
|
||||
const b = Buffer.isBuffer(buf) ? buf : Buffer.from(buf)
|
||||
// Node supports 'base64url' on recent versions; keep fallback for safety.
|
||||
try {
|
||||
return b.toString('base64url')
|
||||
} catch {
|
||||
return b
|
||||
.toString('base64')
|
||||
.replace(/\+/g, '-')
|
||||
.replace(/\//g, '_')
|
||||
.replace(/=+$/g, '')
|
||||
}
|
||||
}
|
||||
|
||||
export function fromBase64Url(s) {
|
||||
if (!s) return Buffer.alloc(0)
|
||||
// Node supports 'base64url' on recent versions; keep fallback for safety.
|
||||
try {
|
||||
return Buffer.from(String(s), 'base64url')
|
||||
} catch {
|
||||
let v = String(s).replace(/-/g, '+').replace(/_/g, '/')
|
||||
while (v.length % 4) v += '='
|
||||
return Buffer.from(v, 'base64')
|
||||
}
|
||||
}
|
||||
|
||||
export function parseClientDataJSON(clientDataJSONB64Url) {
|
||||
const json = fromBase64Url(clientDataJSONB64Url).toString('utf8')
|
||||
return JSON.parse(json)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user