Closed pogilon closed 7 years ago
@connormanning mainly I am interested in how to configure the authentication server to make it work with greyhound. Thanks!
Hello @connormanning, I have been trying to configure an authentication server, but I don't see where or how greyhound will check for the cookie for a specific user and not a general cookie. Could you please let me know? Thanks!
See docs here. For authentication server functionality, your project needs to store a cookie that is identifiable to the current user, e.g. a login token. Then set that user-identifiable cookie name as your configuration value for auth.cookieName
to Greyhound. Then your authentication server will receive requests from Greyhound with the same cookie you're already using for auth to your application.
@connormanning thank you. It just was not very clear to me the cookie workflow from the docs. Does Greyhound pick the login token cookie which name is specified in ("auth.cookieName") from the user and then validates it in the auth server t check for access to a resource? Thanks. I will give it a try.
Greyhound will make requests to <your-auth-server>/<resource-requested>
, and will forward the cookie with the name auth.cookieName
in this request. The rest is up to your auth server - send a 200 or 4xx error with this information.
Thank you @connormanning. I am still trying to solve it. It looks like it is always authenticating the user, even if it should not. Need to see why the authentication feature is not working. Thanks.
I've verified against a sample auth server that just sends 200
if the resource is autzen
or 400
otherwise and it's working as intended:
var app = require('express')();
app.use('/:resource', function(req, res) {
res.status(req.params.resource == 'autzen' ? 200 : 400).send();
});
require('http').createServer(app).listen(8081);
...with Greyhound configuration:
{ "http": { "port": 8085 },
"auth": {
"path": "http://localhost:8081",
"cacheMinutes": { "good": 1, "bad": 1 }
}
}
I'd recommend building up from something trivial like this.
thank you so much @connormanning . I am trying to run this example but I am always getting the following error from greyhound. What do you think it could be? """ LOG Auth proxy err: { [Error: connect ECONNREFUSED 127.0.0.1:8081] code: 'ECONNREFUSED', errno: 'ECONNREFUSED', syscall: 'connect', address: '127.0.0.1', port: 8081 } 03:21:18:69 LOG Error handling: { code: 500, message: 'Authentication error' }
"""
@connormanning just so you know. The error was that I needed to map the network to the docker container too with ( sudo docker run --net="host") . So that my host and docker container 127.0.0.1:8081 were the same. Thanks for everything. I think I got it from here.
Hello @connormanning, could you please give more details about how to use the authentication functionality of greyhound? I am trying to add this feature in an EC2 instance. Thanks!