
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
grant-profile
Advanced tools
User profile middleware for Grant
grant-profile accepts your Grant configuration
In addition to that a profile_url
key can be specified for any provider. This can be used for custom providers, or simply to override the profile_url
for existing one. Note that in some cases a custom logic might be needed for the internal HTTP client.
Not all of the supported providers in Grant are tested here, or have the correct profile URL set. Check out the configuration for current status.
For Express and Koa grant-profile needs to be mounted after Grant, and before any of the callback URLs defined in your Grant configuration.
Additionally a profile
key is attached to your session containing the user profile data.
var express = require('express')
var session = require('express-session')
var grant = require('grant-express') // or require('grant').express()
var profile = require('grant-profile').express()
var config = require('./config.json')
express()
.use(session({secret: 'grant', saveUninitialized: true, resave: true}))
.use(grant(config))
.use(profile(config))
.use('/hi', (req, res) => {
var {response, profile} = req.session.grant
res.end(JSON.stringify({response, profile}, null, 2))
})
.listen(3000)
var Koa = require('koa')
var session = require('koa-session')
var grant = require('grant-koa') // or require('grant').koa()
var profile = require('grant-profile').koa()
var config = require('./config.json')
var app = new Koa()
app.keys = ['grant']
app.use(session(app))
app.use(grant(config))
app.use(profile(config))
app.use((ctx, next) => {
if (ctx.path === '/hi') {
var {response, profile} = ctx.session.grant
ctx.body = JSON.stringify({response, profile}, null, 2)
}
})
app.listen(3000)
var Hapi = require('hapi')
var yar = require('yar')
var grant = require('grant-hapi') // or require('grant').hapi()
var profile = require('grant-profile').hapi()
var config = require('./config.json')
var server = new Hapi.Server({host: 'localhost', port: 3000})
server.route({method: 'GET', path: '/hi', handler: (req, res) => {
var {response, profile} = req.yar.get('grant')
return res.response(JSON.stringify({response, profile}, null, 2))
.header('content-type', 'text/plain')
}})
server.register([
{plugin: grant(), options: config},
{plugin: profile(), options: config},
{plugin: yar, options: {cookieOptions: {password: '01234567890123456789012345678912', isSecure: false}}},
])
.then(() => server.start())
Used in the above examples.
{
"defaults": {
"protocol": "http",
"host": "localhost:3000",
"transport": "session",
"state": true,
"nonce": true,
"callback": "/hi"
},
"google": {"key": "..", "secret": "..", "scope": ["openid", "profile", "email"]},
"twitter": {"key": "..", "secret": ".."}
}
FAQs
User profile plugin for Grant
The npm package grant-profile receives a total of 6,012 weekly downloads. As such, grant-profile popularity was classified as popular.
We found that grant-profile demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.