@coffre/conformance 0.5.1 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{idp-Dyaj6k5N.js → idp-B8u4UPA4.js} +373 -22
- package/dist/idp.d.ts +80 -2
- package/dist/idp.js +2 -2
- package/dist/main.js +217 -32
- package/package.json +4 -4
- package/src/checks/access.ts +13 -4
- package/src/checks/canaries.ts +1 -1
- package/src/checks/cli.ts +1 -1
- package/src/checks/environments.ts +11 -8
- package/src/checks/pages.ts +147 -0
- package/src/checks/people.ts +6 -5
- package/src/chrome.ts +9 -3
- package/src/harness.ts +15 -7
- package/src/idp/github-app.ts +259 -0
- package/src/idp/github.ts +38 -7
- package/src/idp/idp.ts +17 -2
- package/src/idp/index.ts +1 -0
- package/src/idp/people.ts +2 -2
- package/src/suite.ts +2 -1
package/src/idp/idp.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { exportJWK, generateKeyPair, SignJWT, type JWK, type CryptoKey } from 'j
|
|
|
3
3
|
|
|
4
4
|
import { AuthorizationServer } from './authorize.ts';
|
|
5
5
|
import { FakeGitHub } from './github.ts';
|
|
6
|
+
import { FakeGitHubApp } from './github-app.ts';
|
|
6
7
|
import type { Route } from './http.ts';
|
|
7
8
|
import { OidcProvider } from './oidc.ts';
|
|
8
9
|
import { WorkloadIssuer } from './workloads.ts';
|
|
@@ -34,6 +35,8 @@ export interface DevIdpOptions {
|
|
|
34
35
|
clients?: readonly DevIdpClient[];
|
|
35
36
|
/** Skip the persona page when the request carries a login hint. For tests. */
|
|
36
37
|
autoApprove?: boolean;
|
|
38
|
+
/** The fake GitHub App's private key, PKCS #1 PEM: made at start unless given. */
|
|
39
|
+
githubAppKey?: string;
|
|
37
40
|
}
|
|
38
41
|
|
|
39
42
|
/** Built in, so local dev needs no registration step. */
|
|
@@ -48,7 +51,7 @@ export const DEFAULT_CLIENT = Object.freeze({
|
|
|
48
51
|
* For Cloudflare Access, it generates a keypair, serves a JWKS at the same
|
|
49
52
|
* `cdn-cgi` path Access uses, and mints Access-shaped tokens. It is also an
|
|
50
53
|
* OpenID Connect provider (under `/oauth`) signing with the same key, and an
|
|
51
|
-
* imitation of GitHub's OAuth apps and REST API (under `/github`). The
|
|
54
|
+
* imitation of GitHub's OAuth apps, a GitHub App and REST API (under `/github`). The
|
|
52
55
|
* point is that the code under test runs its real remote code paths against
|
|
53
56
|
* real HTTP endpoints -- local mode is a different implementation of the same
|
|
54
57
|
* interface, never a branch that skips verification.
|
|
@@ -77,17 +80,28 @@ export class DevIdp {
|
|
|
77
80
|
/** A CI platform's ID tokens, under `/workloads`, for trust bindings. */
|
|
78
81
|
readonly workloads = new WorkloadIssuer(() => this.origin);
|
|
79
82
|
|
|
83
|
+
/** A deployment's GitHub App, under `/github/api` beside the fake GitHub. */
|
|
84
|
+
readonly githubApp: FakeGitHubApp;
|
|
85
|
+
|
|
80
86
|
constructor(options: DevIdpOptions = {}) {
|
|
81
87
|
this.autoApprove = options.autoApprove ?? false;
|
|
88
|
+
this.githubApp = new FakeGitHubApp(() => this.origin, options.githubAppKey);
|
|
82
89
|
this.#clients.set(DEFAULT_CLIENT.clientId, {
|
|
83
90
|
...DEFAULT_CLIENT,
|
|
84
91
|
redirectUris: [],
|
|
85
92
|
anyLoopbackRedirect: true,
|
|
86
93
|
});
|
|
87
94
|
for (const client of options.clients ?? []) this.registerClient(client);
|
|
95
|
+
// The GitHub App's own OAuth client, which signs people in as the fake GitHub's do.
|
|
96
|
+
this.#clients.set(this.githubApp.clientId, {
|
|
97
|
+
clientId: this.githubApp.clientId,
|
|
98
|
+
clientSecret: this.githubApp.clientSecret,
|
|
99
|
+
redirectUris: [],
|
|
100
|
+
anyLoopbackRedirect: true,
|
|
101
|
+
});
|
|
88
102
|
|
|
89
103
|
const authz = new AuthorizationServer(this);
|
|
90
|
-
this.#routes = [...new OidcProvider(this, authz).routes(), ...new FakeGitHub(this, authz).routes(), ...this.workloads.routes()];
|
|
104
|
+
this.#routes = [...new OidcProvider(this, authz).routes(), ...new FakeGitHub(this, authz).routes(), ...this.githubApp.routes(), ...this.workloads.routes()];
|
|
91
105
|
}
|
|
92
106
|
|
|
93
107
|
get origin(): string {
|
|
@@ -110,6 +124,7 @@ export class DevIdp {
|
|
|
110
124
|
this.privateKey = privateKey;
|
|
111
125
|
this.publicJwk = { ...(await exportJWK(publicKey)), kid: this.kid, alg: 'RS256', use: 'sig' };
|
|
112
126
|
await this.workloads.start();
|
|
127
|
+
await this.githubApp.start();
|
|
113
128
|
|
|
114
129
|
this.#server = createServer((req, res) => {
|
|
115
130
|
// Dev-only: stands in for `cloudflared access login`. Cloudflare Access
|
package/src/idp/index.ts
CHANGED
|
@@ -3,4 +3,5 @@
|
|
|
3
3
|
// it; the dev loop and the tests use it too.
|
|
4
4
|
export { DEFAULT_CLIENT, DevIdp, type DevIdpClient, type DevIdpOptions, type RegisteredClient } from './idp.ts';
|
|
5
5
|
export { PERSONAS, type GitHubAccount, type GitHubAccountPatch, type Persona } from './people.ts';
|
|
6
|
+
export { fakeInstallations, FakeGitHubApp, type FakeInstallation, type FakeRepository } from './github-app.ts';
|
|
6
7
|
export { GITHUB_RUN, WorkloadIssuer } from './workloads.ts';
|
package/src/idp/people.ts
CHANGED
|
@@ -13,8 +13,8 @@ export interface Persona {
|
|
|
13
13
|
* lands on a seeded account.
|
|
14
14
|
*/
|
|
15
15
|
export const PERSONAS: readonly Persona[] = Object.freeze([
|
|
16
|
-
{ email: 'admin@acme.example', name: 'Ada Admin', note: '
|
|
17
|
-
{ email: 'lead@acme.example', name: 'Lea Lead', note: 'owner' },
|
|
16
|
+
{ email: 'admin@acme.example', name: 'Ada Admin', note: 'owner of coffre' },
|
|
17
|
+
{ email: 'lead@acme.example', name: 'Lea Lead', note: 'owner of market' },
|
|
18
18
|
{ email: 'dev@acme.example', name: 'Devon Dev', note: 'developer on dev' },
|
|
19
19
|
{ email: 'auditor@acme.example', name: 'Audrey Auditor', note: 'auditor' },
|
|
20
20
|
{ email: 'accessmgr@acme.example', name: 'Max Access', note: 'access manager' },
|
package/src/suite.ts
CHANGED
|
@@ -16,7 +16,7 @@ import { editedGeneration, forgedCredential, forgedIdentity, forgedApproval } fr
|
|
|
16
16
|
import { canaryScan } from './checks/canaries.ts';
|
|
17
17
|
import { Cli, cliLogin, manageByCli, verifyAsOwner, verifyAsUser, verifyInterrupted, verifyKeys, verifyLeftovers, verifyWithToken } from './checks/cli.ts';
|
|
18
18
|
import { pageLoad, personas, setUp, setUpLive, signInAdmin } from './checks/people.ts';
|
|
19
|
-
import { pagesInBrowser, signinErrorOnce } from './checks/pages.ts';
|
|
19
|
+
import { pagesInBrowser, pastedValues, signinErrorOnce } from './checks/pages.ts';
|
|
20
20
|
import { browserBundle, headers, health } from './checks/surface.ts';
|
|
21
21
|
import { cliSignsIn, exchangesLimited, runSignsIn, runsRefused, runUnbound, spentOnce, tokensUnlogged, trustRun } from './checks/workloads.ts';
|
|
22
22
|
|
|
@@ -30,6 +30,7 @@ export async function conform(deployment: Deployment, options: { bulkLimit: numb
|
|
|
30
30
|
await report.check('security headers', { admin }, ({ admin }) => headers(deployment, admin));
|
|
31
31
|
const canaries = await report.check('setup', { admin }, ({ admin }) => setUp(admin));
|
|
32
32
|
await report.check('pages in a browser', { admin, canaries }, ({ admin }) => pagesInBrowser(deployment, admin, options.browser));
|
|
33
|
+
await report.check('pasted values', { admin }, ({ admin }) => pastedValues(deployment, admin, options.browser));
|
|
33
34
|
await report.check('sign-in error, once', { admin }, ({ admin }) => signinErrorOnce(deployment, admin, options.browser));
|
|
34
35
|
const people = await report.check('personas', { admin, canaries }, ({ admin }) => personas(deployment, admin));
|
|
35
36
|
const all = { people, canaries };
|