Feature request: Dynamic override from database
See original GitHub issuePassing the secret as querystring is not safe, I think maybe it’s better to load the configurations from database.
// First, create a provider
let provider = new Provider({
provider: 'twitter',
override: 'myapp',
config: {
"key": "...",
"secret": "...",
"callback": "/hi"
}
})
provider.save()
// Then
app.use('/grant', grant({
"defaults": {
"protocol": "http",
"host": "localhost:3000",
"transport": "session",
"state": true
},
"google": {
"key": "...",
"secret": "...",
"scope": ["openid"],
"nonce": true,
"custom_params": {"access_type": "offline"},
"callback": "/hello"
},
"twitter": {
"key": "...",
"secret": "...",
"callback": "/hi"
}
}, async function(provider, override){
// Load from database.
let doc = await Provider.findOne({
provider,
override
})
return doc.config
}))
/connect/twitter/myapp
will load the config from database.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:8 (6 by maintainers)
Top Results From Across the Web
Feature request: dynamic change database at runtime #1726
Example: I have a hasura/graphql-engine instance running and connected to postgresUrl. The Postgres instance at postgresUrl contains the ...
Read more >Keep up with dynamic data changes using dynamic parameters
Deploy your workbooks with dynamic parameters and never again think about manually updating your parameters with the latest data.
Read more >The Key to Dynamic Parameters & Some Good Use Cases
Dynamic Parameters are the most requested feature in the history of the ideas forums…and there is a reason for that.
Read more >Feature Request: Dynamic Field Names/Labels - Zoho Cares
Example: Lets say I have two clients using the same Zoho Creator Form to input employee names. The Form has a hidden field...
Read more >Feature Toggles (aka Feature Flags) - Martin Fowler
An alternative approach to a environment-specific configuration overrides is to allow a toggle's On/Off state to be overridden on a per-request basis by...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That’s an interesting idea, I’ll have to think about it.
In the meantime you can probably set your dynamic configuration directly on the
query
object that’s attached to therequest
argument:Then if you navigate to
http://localhost:3000/connect/twitter/foo
you’ll be able to login using the credentials set in the middleware before Grant.I have tested it only with Express, but it should work with Koa too.
Dynamic input state overrides landed in v4.7.0
The documentation and examples about it are a bit scarce at the moment, but here is the relevant commit in the readme.
In summary now you can use the request/response lifecycle state of your HTTP framework of choice to set dynamic overrides before entering the Grant routes. This dynamic configuration works outside of the
dynamic
configuration key, meaning you can override anything using the request/response lifecycle state. Thedynamic
option controls only allowed keys to override over HTTP via GET/POST request.