Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions auth0/actions/require-xlair-org.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const crypto = require("crypto");

const ORGANIZATION = "xlair-dev";
const AUTH0_DOMAIN = "dev-2dn3mvmvr8tccoss.us.auth0.com";

Expand All @@ -15,6 +17,9 @@ const describeError = (error) => {
].join(" ");
};

const fingerprint = (token) =>
crypto.createHash("sha256").update(token).digest("hex").slice(0, 16);

const getIdentityProviderAccessToken = async (event) => {
console.log(
`stage=start management_client_id=${event.secrets.AUTH0_MANAGEMENT_CLIENT_ID}`,
Expand Down Expand Up @@ -80,7 +85,9 @@ const getIdentityProviderAccessToken = async (event) => {
({ provider }) => provider === "github",
);
console.log(
`stage=idp-token github_identity=${Boolean(githubIdentity)} access_token=${Boolean(githubIdentity?.access_token)}`,
`stage=idp-token github_identity=${Boolean(githubIdentity)} ` +
`access_token=${Boolean(githubIdentity?.access_token)} ` +
`fingerprint=${githubIdentity?.access_token ? fingerprint(githubIdentity.access_token) : "none"}`,
);
return githubIdentity?.access_token;
};
Expand Down Expand Up @@ -112,8 +119,8 @@ exports.onExecutePostLogin = async (event, api) => {
},
},
);
} catch (_error) {
console.log("GitHub organization membership response could not be parsed");
} catch (error) {
console.log(`stage=github-membership exception ${describeError(error)}`);
deny(api);
return;
}
Expand Down
1 change: 1 addition & 0 deletions auth0/tenant.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ connections:
actions:
- name: Require XLAIR GitHub organization membership
code: ./actions/require-xlair-org.js
# Pin the runtime because this Action relies on the Node.js built-in Fetch API.
runtime: node22
deployed: true
status: built
Expand Down
Loading