Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
passport-discord-auth
Advanced tools
Passport strategy for authenticating with Discord using the OAuth 2.0 API.
# Using npm
> npm install passport-discord-auth
# Using yarn or pnpm
> yarn/pnpm add passport-discord-auth
This library supports both typescript and javascript, with ES6 modules and CommonJS.
// ES6 modules
import { Strategy } from 'passport-discord-auth';
// CommonJS
const { Strategy } = require('passport-discord-auth');
passport.serializeUser((user, done) => {
done(null, user);
});
passport.deserializeUser((user, done) => {
done(null, user);
});
passport.use(
new Strategy(
{
clientId: 'CLIENT_ID',
clientSecret: 'CLIENT_SECRET',
callbackUrl: 'http://localhost:3000/auth/discord/callback',
scope: ['identify', 'guilds'],
},
// Do something with the profile
(accessToken, refreshToken, profile, done) => {
done(null, profile);
}
)
);
app.get('/auth/discord', passport.authenticate('discord'));
app.get(
'/auth/discord/callback',
passport.authenticate('discord', {
failureRedirect: '/auth/discord',
}),
(req, res) => {
res.redirect('/');
}
);
Example endpoint that returns the authenticated user:
app.get('/user', (req, res) => {
if (req.isAuthenticated()) {
res.json(req.user);
} else {
res.status(401).json({ message: 'Unauthorized' });
}
});
You can choose to import the Scope
enum and use it to specify the scopes you want to request from the user or you can use the string literals.
Example:
import { Scope } from 'passport-discord-auth';
// ...
passport.use(
new Strategy(
{
// ...
scope: [Scope.Identify, Scope.Guilds, Scope.Email],
}
// ...
)
);
Available scopes:
Scope.ActivitiesRead
or activities.read
- Allows your app to fetch data from a user's "Now Playing/Recently Played" list — not currently available for apps.Scope.ActivitiesWrite
or activities.write
- Allows your app to update a user's activity - not currently available for apps (NOT REQUIRED FOR GAMESDK ACTIVITY MANAGER).Scope.ApplicationBuildsRead
or applications.builds.read
- Allows your app to read build data for a user's applications.Scope.ApplicationBuildsUpload
or applications.builds.upload
- Allows your app to upload/update builds for a user's applications - requires Discord approval.Scope.ApplicationsCommands
or applications.commands
- Allows your app to use commands in a guild.Scope.ApplicationsCommandsUpdate
or applications.commands.update
- Allows your app to update its commands using a Bearer token - client credentials grant only.Scope.ApplicationsCommandsPermissionsUpdate
or applications.commands.permissions.update
- Allows your app to update permissions for its commands in a guild a user has permissions to.Scope.ApplicationsEntitlements
or applications.entitlements
- Allows your app to read entitlements for a user's applications.Scope.ApplicationsStoreUpdate
or applications.store.update
- Allows your app to read and update store data (SKUs, store listings, achievements, etc.) for a user's applications.Scope.Bot
or bot
- For oauth2 bots, this puts the bot in the user's selected guild by default.Scope.Connections
or connections
- Allows /users/@me/connections to return linked third-party accounts.Scope.DmRead
or dm_channels.read
- Allows your app to see information about the user's DMs and group DMs - requires Discord approval.Scope.Email
or email
- Enables /users/@me to return an email
.Scope.GdmJoin
or gdm.join
- Allows your app to join users to a group dm.Scope.Guilds
or guilds
- Allows /users/@me/guilds to return basic information about all of a user's guilds.Scope.GuildsJoin
or guilds.join
- Allows /guilds/{guild.id}/members/{user.id} to be used for joining users to a guild.Scope.GuildMembersRead
or guilds.members.read
- Allows /users/@me/guilds/{guild.id}/member to return a user's member information in a guild.Scope.Identify
or identify
- Allows /users/@me without email.Scope.MessagesRead
or messages.read
- For local rpc server api access, this allows you to read messages from all client channels (otherwise restricted to channels/guilds your app creates).Scope.RelationshipsRead
or relationships.read
- Allows your app to know a user's friends and implicit relationships - requires Discord approval.Scope.RoleConnectionsWrite
or role_connections.write
- Allows your app to update a user's connection and metadata for the app.Scope.Rpc
or rpc
- For local rpc server access, this allows you to control a user's local Discord client - requires Discord approval.Scope.RpcActivitiesUpdate
or rpc.activities.update
- For local rpc server access, this allows you to update a user's activity - requires Discord approval.Scope.RpcNotificationsRead
or rpc.notifications.read
- For local rpc server access, this allows you to receive notifications pushed out to the user - requires Discord approval.Scope.RpcVoiceRead
or rpc.voice.read
- For local rpc server access, this allows you to read a user's voice settings and listen for voice events - requires Discord approval.Scope.RpcVoiceWrite
or rpc.voice.write
- For local rpc server access, this allows you to update a user's voice settings - requires Discord approval.Scope.Voice
or voice
- Allows your app to connect to voice on user's behalf and see all the voice members - requires Discord approval.Scope.WebhookIncoming
or webhook.incoming
- This generates a webhook that is returned in the oauth token response for authorization code grants.FAQs
An updated passport authentication strategy for Discord.
The npm package passport-discord-auth receives a total of 105 weekly downloads. As such, passport-discord-auth popularity was classified as not popular.
We found that passport-discord-auth demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.