forked from bluesky-social/atproto
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore(ci): update setup-node & checkout actions to v4 * refactor(oauth): rename internal types to avoid conflicting types fix(oauth): support building from parcel feat(oauth): add runtime lock support to prevent concurrent session updates feat(oauth): improve metadata validation fix(oauth): allow use of handle as login hint fix: proper parsing of authorization header feat(oauth): add email 2fa support feat(oauth): adapt auth UI to match app UI * fix(oauth): improve parsing of digest algo * fix(oauth-provider): dead code cleanup * fix(oauth-provider): avoid inconsistent use of "id" prop in InputCheckbox * style(oauth-provider): use if/else instead of switch * feat(oauth-provider): stronger validation of customization data Invalid oauth customization would cause the server to crash at startup. * docs(oauth-client): explain why the abortRequest method is not mandatory * fix(oauth-client): cancel fetch response body when not used * docs: typo Co-authored-by: devin ivy <[email protected]> * feat(oauth-provider:metadata): add client_id_metadata_document_supported metadata * fix(oauth-provider): require the content-type to be set on client metadata response * feat(common): add obfuscation utilities fix(pds): show user did in logs fix(ozone): show user did in logs * tidy * fix(simple-store): avoid leaking context when calling hooks * fix: use patch level changeset * chore(oauth-types): add changeset regarding client_id_metadata_document_supported * chore: add changeset for bsky & ozone * unify loggerMiddleware instantiation * tidy --------- Co-authored-by: devin ivy <[email protected]>
- Loading branch information
1 parent
b899505
commit acc9093
Showing
132 changed files
with
3,576 additions
and
1,594 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@atproto/oauth-types": patch | ||
--- | ||
|
||
Add client_id_metadata_document_supported in metadata |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@atproto/jwk-jose": patch | ||
"@atproto/jwk": patch | ||
--- | ||
|
||
Allow build from Parcel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
"@atproto-labs/handle-resolver-node": patch | ||
"@atproto-labs/identity-resolver": patch | ||
"@atproto-labs/handle-resolver": patch | ||
"@atproto-labs/did-resolver": patch | ||
"@atproto-labs/simple-store": patch | ||
--- | ||
|
||
Use distinct type names to prevent conflicts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@atproto/pds": patch | ||
--- | ||
|
||
Use new version of @atproto/oauth-provider with improved UI. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@atproto/oauth-client-node": patch | ||
--- | ||
|
||
Create NodeJS OAuth SDK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
"@atproto/ozone": patch | ||
"@atproto/bsync": patch | ||
"@atproto/bsky": patch | ||
"@atproto/pds": patch | ||
--- | ||
|
||
Obfuscate request headers in logs using utils from @atproto/common |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@atproto/oauth-provider": patch | ||
--- | ||
|
||
Add 2FA support |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@atproto/oauth-client-browser": patch | ||
"@atproto/oauth-client-node": patch | ||
"@atproto/oauth-client": patch | ||
--- | ||
|
||
Add event emitting capability to OAuthClient |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@atproto/pds": patch | ||
--- | ||
|
||
Improve parsing of Authorization header |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@atproto/dev-env": patch | ||
--- | ||
|
||
Adapt to changes from @atproto/oauth-provider |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@atproto-labs/simple-store": patch | ||
--- | ||
|
||
Expose reason for deletion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@atproto/common": patch | ||
--- | ||
|
||
Add obfuscation utilities |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
export * from '@atproto/common-web' | ||
export * from './buffers' | ||
export * from './dates' | ||
export * from './env' | ||
export * from './fs' | ||
export * from './ipld' | ||
export * from './ipld-multi' | ||
export * from './logger' | ||
export * from './obfuscate' | ||
export * from './streams' | ||
export * from './buffers' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
export function obfuscateEmail(email: string) { | ||
const [local, domain] = email.split('@') | ||
return `${obfuscateWord(local)}@${obfuscateWord(domain)}` | ||
} | ||
|
||
export function obfuscateWord(word: string) { | ||
return `${word.charAt(0)}***${word.charAt(word.length - 1)}` | ||
} | ||
|
||
export function obfuscateHeaders(headers: Record<string, string>) { | ||
const obfuscatedHeaders: Record<string, string> = {} | ||
for (const key in headers) { | ||
if (key.toLowerCase() === 'authorization') { | ||
obfuscatedHeaders[key] = obfuscateAuthHeader(headers[key]) | ||
} else if (key.toLowerCase() === 'dpop') { | ||
obfuscatedHeaders[key] = obfuscateJwt(headers[key]) || 'Invalid' | ||
} else { | ||
obfuscatedHeaders[key] = headers[key] | ||
} | ||
} | ||
return obfuscatedHeaders | ||
} | ||
|
||
export function obfuscateAuthHeader(authHeader: string): string { | ||
// This is a hot path (runs on every request). Avoid using split() or regex. | ||
|
||
const spaceIdx = authHeader.indexOf(' ') | ||
if (spaceIdx === -1) return 'Invalid' | ||
|
||
const type = authHeader.slice(0, spaceIdx) | ||
switch (type.toLowerCase()) { | ||
case 'bearer': | ||
case 'dpop': | ||
return `${type} ${obfuscateBearer(authHeader.slice(spaceIdx + 1))}` | ||
case 'basic': | ||
return `${type} ${obfuscateBasic(authHeader.slice(spaceIdx + 1)) || 'Invalid'}` | ||
default: | ||
return `Invalid` | ||
} | ||
} | ||
|
||
export function obfuscateBasic(token: string): null | string { | ||
if (!token) return null | ||
const buffer = Buffer.from(token, 'base64') | ||
if (!buffer.length) return null // Buffer.from will silently ignore invalid base64 chars | ||
const authHeader = buffer.toString('utf8') | ||
const colIdx = authHeader.indexOf(':') | ||
if (colIdx === -1) return null | ||
const username = authHeader.slice(0, colIdx) | ||
return `${username}:***` | ||
} | ||
|
||
export function obfuscateBearer(token: string): string { | ||
return obfuscateJwt(token) || obfuscateToken(token) | ||
} | ||
|
||
export function obfuscateToken(token: string): string { | ||
if (token.length >= 12) return obfuscateWord(token) | ||
return token ? '***' : '' | ||
} | ||
|
||
export function obfuscateJwt(token: string): null | string { | ||
const firstDot = token.indexOf('.') | ||
if (firstDot === -1) return null | ||
|
||
const secondDot = token.indexOf('.', firstDot + 1) | ||
if (secondDot === -1) return null | ||
|
||
// Expected to be missing | ||
const thirdDot = token.indexOf('.', secondDot + 1) | ||
if (thirdDot !== -1) return null | ||
|
||
try { | ||
const payloadEnc = token.slice(firstDot + 1, secondDot) | ||
const payloadJson = Buffer.from(payloadEnc, 'base64').toString('utf8') | ||
const payload = JSON.parse(payloadJson) | ||
if (typeof payload.sub === 'string') return payload.sub | ||
} catch { | ||
// Invalid JWT | ||
return null | ||
} | ||
|
||
// Strip the signature | ||
return token.slice(0, secondDot) + '.obfuscated' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.