-
Notifications
You must be signed in to change notification settings - Fork 126
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
Integration with glue #151
Comments
@no-more great question, really sorry that is unclear from our Docs. (only one other person has requested |
I don't see any straightforward way to do this using Glue. |
@nelsonic a glue usage out of the box seems complicated to me. At least it will need a very careful design since everyone is using a different database or have different need (I decorate my auth objects with scopes for instance).
with However I see 2 enhancements we could easely make here:
|
Hi, thanks for your fast answers, yes I'm currently using glue and try to put every plugin configuration within it. I'm quite new to nodejs & hapi, I'm just trying to build a boilerplate for my next project so I'm trying to find best practices, that's why I'm trying to use glue which seems to be the new way to do things in hapi. Thanks. |
The only time I've seen functions in manifest would be here https://github.com/hapijs/rejoice |
Hi, I was considering using this plugin for my hapijs project, but as I'm using Glue and I read here that it's not supported, I don't know if I can plug it easily… (I started using Glue because the official hapijs tutorial teaches to use it…) |
@Miguel-Herrero glue is nice but fewer than 8% of Hapi projects use it... |
Oh, I didn't know that @nelsonic Thanks for the info. I guess a hapijs app is more configurable without Glue? |
@Miguel-Herrero |
I'd love to see |
For what it's worth, I'd love to see glue support as well. I'm using it at work and on a personal project. If I find some free time and this still isn't a high priority, I may take a stab at this. For the time being, I'm taking the advice of @vdeturckheim and have simply wrapped this in my own plugin like so:
and then I can load this in my
|
@avanslaars I tried using your idea with For testing I'm just using |
@sean-hill It is working in my app. It's a WIP, so I haven't done anything with my // Create the token
const jwt = require('jsonwebtoken')
const JWT_SECRET_KEY = require('lg/lib/always').JWT_SECRET_KEY
// Code that handles OAuth, saving user in DB, etc...
const theToken = jwt.sign({name:'sample'}, JWT_SECRET_KEY)
return reply.redirect('/dashboard').state('token', theToken, {
path: '/',
ttl: 2592e5
}) Sample route that uses auth server.route([{
method: 'GET',
path: '/dashboard',
config: {
auth: 'jwt'
},
handler: function (request, reply) {
reply.view('dashboard')
}
} If I have the cookie in place, this route works and if I delete the cookie, I get a 401. I hope this helps. |
@avanslaars thanks. I got it working :) |
@avanslaars thanks for the answer. Your solution is working for me. But it throws error when test cases are executed. It throws.
And auth plugin code is as you shown above. If auth plugin is removed, above error vanishes, and registering auth plugin throws it. Running main server file does not throw this error, it works fine. Running only test cases throws this error. |
@saurabhghewari I've been able to get this plugin to work well with unit tests. Here is a link to my repo. I have an |
Thank you for your reply. I solved it. removed the next() from the private method of plugin in which JWT2 plugin is being registered. |
@nelsonic I believe this issue is closed with @avanslaars example. |
Yes for sure!!! |
@sean-hill looks like it! Do you think we should add a link in our Readme FAQ section to @avanslaars example so others looking for how to use |
@nelsonic I think that would be great idea. |
@avanslaars I did the same than you but I get this error: "Authentication strategy jwt uses unknown scheme: jwt" (n) |
@Mikjail I guess you are getting this error because, some where in the project the auth scheme is used before the plugin is registered. The registration sequence matters while registering the plugins. Sequence should be:-
Hope you get this. |
@Mikjail did you fix the error. i alse get the same error. can you help me? |
@supun19 can you post some code here so that I can help you out. |
@Mikjail thank you your reply I am using this framework https://github.com/jedireza/aqua this is a manifest.json `'use strict'; const criteria = { const manifest = { const store = new Confidence.Store(manifest); exports.get = function (key) {
}; exports.meta = function (key) {
}; this is a auth.js `'use strict'; const internals = {}; const people = { // our "users database" // bring your own validation function
}; internals.applyStrategy = function (server, next) {
}; exports.register = function (server, options, next) {
}; exports.register.attributes = { this is a route const internals = {}; internals.applyRoutes = function (server, next) {
}; exports.register = function (server, options, next) {
}; exports.register.attributes = { |
@saurabhghewari can you help me, please. I am stuck in this. |
Hi Supun19, Sorry for the late reply. |
@saurabhghewari thank you |
Did that solve your problem? |
@saurabhghewari thank you for your reply |
Hello,
Sorry for this newbie question but I couldn't figure out how to register and configure this plugin with glue manifest. I don't know what to put in options, I don't even know it this is possible with glue?
Thanks.
The text was updated successfully, but these errors were encountered: