Skip to content
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

Authentication Information #42

Closed
pogilon opened this issue Jun 26, 2017 · 9 comments
Closed

Authentication Information #42

pogilon opened this issue Jun 26, 2017 · 9 comments

Comments

@pogilon
Copy link

pogilon commented Jun 26, 2017

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!

@pogilon
Copy link
Author

pogilon commented Jun 26, 2017

@connormanning mainly I am interested in how to configure the authentication server to make it work with greyhound. Thanks!

@pogilon
Copy link
Author

pogilon commented Jun 29, 2017

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!

@connormanning
Copy link
Collaborator

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.

@pogilon
Copy link
Author

pogilon commented Jun 29, 2017

@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.

@connormanning
Copy link
Collaborator

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.

@pogilon
Copy link
Author

pogilon commented Jul 15, 2017

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.

@connormanning
Copy link
Collaborator

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.

@pogilon
Copy link
Author

pogilon commented Jul 21, 2017

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' }

"""

@pogilon
Copy link
Author

pogilon commented Jul 21, 2017

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants