Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Giving What We Can related code #60

Open
wants to merge 1 commit into
base: wh-disable-rules-2025-01
Choose a base branch
from
Open
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
27 changes: 2 additions & 25 deletions cli/manifests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,7 @@ export const ACTION_MANIFEST: ActionDefinition[] = [
trigger: 'post-login',
triggerVersion: 'v3',
getData: async () => {
const defaultRoleNames = [
'User-Basic-Role',
'Parfit User',
'EA Funds User',
'Giving What We Can User',
]
const defaultRoleNames = ['User-Basic-Role', 'EA Funds User']
const Roles = await getAllRoles()
const defaultRoles = Roles.filter(isValidRole)
.filter((Role) => defaultRoleNames.includes(Role.name))
Expand All @@ -54,13 +49,7 @@ export const ACTION_MANIFEST: ActionDefinition[] = [
// Get token namespace
const namespace = process.env.TOKEN_NAMESPACE

const allowAllScopesApplicationNames = [
'EA Funds',
'Giving What We Can',
'Parfit Admin',
]

const scopesToIdTokenApplicationNames = ['Giving What We Can']
const allowAllScopesApplicationNames = ['EA Funds']

const Clients = await getAllClients()
const validClients = Clients.filter(isValidClient)
Expand All @@ -75,20 +64,8 @@ export const ACTION_MANIFEST: ActionDefinition[] = [
})
)

const addScopesToIdTokenApplications = Clients.filter(isValidClient)
.filter((Client) =>
scopesToIdTokenApplicationNames.includes(Client.name)
)
.map((Client) =>
getCommentValue({
applicationName: Client.name,
value: Client.client_id,
})
)

return {
allowAllScopesWhitelist,
addScopesToIdTokenApplications,
namespace,
}
},
Expand Down
9 changes: 0 additions & 9 deletions scripts/actions/src/manage-scopes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,4 @@ exports.onExecutePostLogin = async (
for (const scope of removedScopes) {
api.accessToken.removeScope(scope)
}

// Add scopes to id token
const finalScopes = requestedScopes.filter((s) => allowedScopes.includes(s))
const requiredApplications = TEMPLATE_DATA.addScopesToIdTokenApplications

if (requiredApplications.includes(clientId)) {
const namespace: string = TEMPLATE_DATA.namespace
api.idToken.setCustomClaim(`${namespace}/scope`, finalScopes.join(' '))
}
}