-
Notifications
You must be signed in to change notification settings - Fork 630
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* tidy bsky auth * hook up new auth verifier * update auth throughout ozone * handle mod signing keys * add client proxy heads to pds * hook up rest of routes * simplify pipethrough & add some SSRF protection * tests * fix bad var * remove basic auth in ozone * wip * fix key parsing in pds * fix up all ozone tests * fix admin auth test * rename test * fix ozone test * clean up tokens in pds * fix up pds tests * fix up ozone tests * add pipethrough to write routes * reenable proxied admin test * add moderator accounts to ozone in dev-env * update did doc id values * null creds string -> `none` * fix fetchLabels auth check * ✨ Add a couple more proxied requests that we use in ozone ui * Add runit to the services/bsky Dockerfile (#2254) add runit to the services/bsky Dockerfile * Improve tag detection (#2260) * Allow tags to lead with and contain only numbers * Break tags on other whitespace characters * Export regexes from rich text detection * Add test * Add test * Disallow number-only tags * Avoid combining enclosing screen chars * Allow full-width number sign * Clarify tests * Fix punctuation edge case * Reorder * Simplify, add another test * Another test, comment * Version packages (#2261) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * 🐛 Increment attempt count after each attempt to push ozone event (#2239) * Ozone delegates email sending to actor's pds (#2272) * ozone delegates email sending to user's pds * lexicon: add content field to mod email event * test email sending via mod event * add dev dep for nodemailer in ozone * fix auth verifier method * build branch * build branch * fix url check * better error handling for get account infos * fix labeler service id * fix iss on auth headers * fix dev-env ozone did * fix tests & another jwt issuer * fix proxy auth * ozone: fix ip check * fix aud check on pds mod service auth * tidy * Update packages/pds/tests/proxied/admin.test.ts Co-authored-by: devin ivy <[email protected]> * fix pipethrough of headers * fix moderation status tests * fix auth on ozone routes * update iss on daemon --------- Co-authored-by: Foysal Ahamed <[email protected]> Co-authored-by: Jake Gold <[email protected]> Co-authored-by: Eric Bailey <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: devin ivy <[email protected]>
- Loading branch information
1 parent
2267f1e
commit 71f9cc9
Showing
80 changed files
with
869 additions
and
1,212 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 |
---|---|---|
|
@@ -3,7 +3,6 @@ on: | |
push: | ||
branches: | ||
- main | ||
- pds-proxy-headers | ||
env: | ||
REGISTRY: ghcr.io | ||
USERNAME: ${{ github.actor }} | ||
|
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 |
---|---|---|
|
@@ -3,7 +3,6 @@ on: | |
push: | ||
branches: | ||
- main | ||
- pds-proxy-headers | ||
env: | ||
REGISTRY: ghcr.io | ||
USERNAME: ${{ github.actor }} | ||
|
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,4 +1,2 @@ | ||
export const ADMIN_PASSWORD = 'admin-pass' | ||
export const MOD_PASSWORD = 'mod-pass' | ||
export const TRIAGE_PASSWORD = 'triage-pass' | ||
export const JWT_SECRET = 'jwt-secret' |
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 |
---|---|---|
|
@@ -93,6 +93,29 @@ export async function generateMockSetup(env: TestNetwork) { | |
) | ||
} | ||
|
||
// Create moderator accounts | ||
const triageRes = | ||
await clients.loggedout.api.com.atproto.server.createAccount({ | ||
email: '[email protected]', | ||
handle: 'triage.test', | ||
password: 'triage-pass', | ||
}) | ||
env.ozone.addAdminDid(triageRes.data.did) | ||
const modRes = await clients.loggedout.api.com.atproto.server.createAccount({ | ||
email: '[email protected]', | ||
handle: 'mod.test', | ||
password: 'mod-pass', | ||
}) | ||
env.ozone.addAdminDid(modRes.data.did) | ||
const adminRes = await clients.loggedout.api.com.atproto.server.createAccount( | ||
{ | ||
email: '[email protected]', | ||
handle: 'admin-mod.test', | ||
password: 'admin-mod-pass', | ||
}, | ||
) | ||
env.ozone.addAdminDid(adminRes.data.did) | ||
|
||
// Report one user | ||
const reporter = picka(users) | ||
await reporter.agent.api.com.atproto.moderation.createReport({ | ||
|
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,138 @@ | ||
import AtpAgent from '@atproto/api' | ||
import { InputSchema as TakeActionInput } from '@atproto/api/src/client/types/com/atproto/admin/emitModerationEvent' | ||
import { QueryParams as QueryStatusesParams } from '@atproto/api/src/client/types/com/atproto/admin/queryModerationStatuses' | ||
import { QueryParams as QueryEventsParams } from '@atproto/api/src/client/types/com/atproto/admin/queryModerationEvents' | ||
import { TestOzone } from './ozone' | ||
|
||
type ModLevel = 'admin' | 'moderator' | 'triage' | ||
|
||
export class ModeratorClient { | ||
agent: AtpAgent | ||
constructor(public ozone: TestOzone) { | ||
this.agent = ozone.getClient() | ||
} | ||
|
||
async getEvent(id: number, role?: ModLevel) { | ||
const result = await this.agent.api.com.atproto.admin.getModerationEvent( | ||
{ id }, | ||
{ | ||
headers: await this.ozone.modHeaders(role), | ||
}, | ||
) | ||
return result.data | ||
} | ||
|
||
async queryModerationStatuses(input: QueryStatusesParams, role?: ModLevel) { | ||
const result = | ||
await this.agent.api.com.atproto.admin.queryModerationStatuses(input, { | ||
headers: await this.ozone.modHeaders(role), | ||
}) | ||
return result.data | ||
} | ||
|
||
async queryModerationEvents(input: QueryEventsParams, role?: ModLevel) { | ||
const result = await this.agent.api.com.atproto.admin.queryModerationEvents( | ||
input, | ||
{ | ||
headers: await this.ozone.modHeaders(role), | ||
}, | ||
) | ||
return result.data | ||
} | ||
|
||
async emitModerationEvent( | ||
opts: { | ||
event: TakeActionInput['event'] | ||
subject: TakeActionInput['subject'] | ||
subjectBlobCids?: TakeActionInput['subjectBlobCids'] | ||
reason?: string | ||
createdBy?: string | ||
meta?: TakeActionInput['meta'] | ||
}, | ||
role?: ModLevel, | ||
) { | ||
const { | ||
event, | ||
subject, | ||
subjectBlobCids, | ||
reason = 'X', | ||
createdBy = 'did:example:admin', | ||
} = opts | ||
const result = await this.agent.api.com.atproto.admin.emitModerationEvent( | ||
{ event, subject, subjectBlobCids, createdBy, reason }, | ||
{ | ||
encoding: 'application/json', | ||
headers: await this.ozone.modHeaders(role), | ||
}, | ||
) | ||
return result.data | ||
} | ||
|
||
async reverseModerationAction( | ||
opts: { | ||
id: number | ||
subject: TakeActionInput['subject'] | ||
reason?: string | ||
createdBy?: string | ||
}, | ||
role?: ModLevel, | ||
) { | ||
const { subject, reason = 'X', createdBy = 'did:example:admin' } = opts | ||
const result = await this.agent.api.com.atproto.admin.emitModerationEvent( | ||
{ | ||
subject, | ||
event: { | ||
$type: 'com.atproto.admin.defs#modEventReverseTakedown', | ||
comment: reason, | ||
}, | ||
createdBy, | ||
}, | ||
{ | ||
encoding: 'application/json', | ||
headers: await this.ozone.modHeaders(role), | ||
}, | ||
) | ||
return result.data | ||
} | ||
|
||
async performTakedown( | ||
opts: { | ||
subject: TakeActionInput['subject'] | ||
subjectBlobCids?: TakeActionInput['subjectBlobCids'] | ||
durationInHours?: number | ||
reason?: string | ||
}, | ||
role?: ModLevel, | ||
) { | ||
const { durationInHours, ...rest } = opts | ||
return this.emitModerationEvent( | ||
{ | ||
event: { | ||
$type: 'com.atproto.admin.defs#modEventTakedown', | ||
durationInHours, | ||
}, | ||
...rest, | ||
}, | ||
role, | ||
) | ||
} | ||
|
||
async performReverseTakedown( | ||
opts: { | ||
subject: TakeActionInput['subject'] | ||
subjectBlobCids?: TakeActionInput['subjectBlobCids'] | ||
reason?: string | ||
}, | ||
role?: ModLevel, | ||
) { | ||
return this.emitModerationEvent( | ||
{ | ||
event: { | ||
$type: 'com.atproto.admin.defs#modEventReverseTakedown', | ||
}, | ||
...opts, | ||
}, | ||
role, | ||
) | ||
} | ||
} |
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.