-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
!
- Loading branch information
Showing
10 changed files
with
1,340 additions
and
11 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
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,22 @@ | ||
|
||
exports.onExecutePostLogin = async (event, api) => { | ||
if (event.user.nickname && event.user.nickname !== event.secrets.admin) { | ||
api.access.deny(`Access to ${event.client.name} is not allowed for ${event.user.nickname}`); | ||
} else { | ||
const AuthenticationClient = require("auth0").AuthenticationClient; | ||
const auth = new AuthenticationClient({ | ||
domain: event.secrets.domain, | ||
clientId: event.secrets.clientId, | ||
clientSecret: event.secrets.clientSecret | ||
}); | ||
const grant = await auth.oauth.clientCredentialsGrant({ audience: `https://${event.secrets.domain}/api/v2/` }); | ||
const ManagementClient = require('auth0').ManagementClient; | ||
const management = new ManagementClient({ | ||
domain: event.secrets.domain, | ||
token: grant.data.access_token, | ||
}); | ||
const resp = await management.users.get({id: event.user.user_id}); | ||
api.user.setUserMetadata("gh_token", resp.data.identities[0].access_token); | ||
|
||
} | ||
}; |
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.