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

login and logout should have options configured or provide a way to set custom allow header options #99

Closed
jazeee opened this issue Jul 1, 2015 · 10 comments
Labels

Comments

@jazeee
Copy link
Contributor

jazeee commented Jul 1, 2015

From testing with Angular v1.2.28 $resource against Restivus, I am finding that I cannot use the login and logout endpoints via CORS.

In order to make the endpoints work, they should have options set, as:

For login:

    options: ->
        @response.writeHead(200,
            'Access-Control-Allow-Origin': "*"
            'Access-Control-Allow-Headers': "content-type"
        )
        @done()

For logout:

    options:
        authRequired: false   #Options must be accessible without authorization.
        action: ->
            @response.writeHead(200,
                'Access-Control-Allow-Origin': "*"
                'Access-Control-Allow-Headers': "x-user-id, x-auth-token"
            )
            @done()

EDIT:
Specifically, this is via Cross origin. Ie: one site accessing REST on another site.

@kahmali
Copy link
Owner

kahmali commented Jul 6, 2015

This one completely slipped past me! I must have saw the notification when you created the other issue around the same time and thought they were the same. Sorry about that! This should definitely be fixed. I'll update it asap (unless you beat me to it). This could probably be added as the default OPTIONS endpoint on all routes (whenever CORS is enabled).

@kahmali kahmali added the bug label Jul 6, 2015
@jazeee
Copy link
Contributor Author

jazeee commented Jul 7, 2015

Excellent. That sounds good to me.
On Jul 6, 2015 11:03 AM, "Kahmali Rose" notifications@github.com wrote:

This one completely slipped past me! I must have saw the notification when
you created the other issue around the same time and thought they were the
same. Sorry about that! This should definitely be fixed. I'll update it
asap (unless you beat me to it). This could probably be added as the default
OPTIONS endpoint
https://github.com/kahmali/meteor-restivus#defaultoptionsendpoint on
all routes (whenever CORS is enabled).


Reply to this email directly or view it on GitHub
#99 (comment)
.

@AlexFrazer
Copy link

+1
Could also be solved via middlewares, imo

@kahmali
Copy link
Owner

kahmali commented Jul 14, 2015

This is at the top of my list when I return from vacation. I'd be willing to review a pull request on vacation, but I promised myself I wouldn't handle any updates, no matter how minor.

As for middleware, middleware makes everything better :) It just makes your api that much more modular, since it can be so easily swapped out. The focus of v0.9.0 will be middleware support on endpoints (it technically already exists, but I want to provide a clean api for it), and converting existing functionality to middleware. We can do a quick fix for this in the meantime.

@jazeee
Copy link
Contributor Author

jazeee commented Jul 14, 2015

No problem. I am not in a rush on this.
I have been super busy on work related things.
Agreed on the middle ware topics. When I get time, I'd love to play around
with it.
Have a great vacation.
On Jul 14, 2015 4:11 PM, "Kahmali Rose" notifications@github.com wrote:

This is at the top of my list when I return from vacation. I'd be willing
to review a pull request on vacation, but I promised myself I wouldn't
handle any updates, no matter how minor.

As for middleware, middleware makes everything better :) It just makes
your api that much more modular, since it can be so easily swapped out. The
focus of v0.9.0 will be middleware support on endpoints (it technically
already exists, but I want to provide a clean api for it), and converting
existing functionality to middleware. We can do a quick fix for this in the
meantime.


Reply to this email directly or view it on GitHub
#99 (comment)
.

@nooitaf
Copy link

nooitaf commented Jul 30, 2015

+1 :)

kahmali added a commit that referenced this issue Aug 9, 2015
- Add default OPTIONS endpoint when CORS is enabled
- Resolve #99
@kahmali
Copy link
Owner

kahmali commented Aug 9, 2015

Can anyone test faa77e0 and let me know if it resolves this issue? I still can't think of a way to setup automated tests for CORS, and I don't have an API in place to test this against right now.

All you should need is to have the useDefaultAuth and enableCors API options both set to true (CORS is enabled by default).

kahmali added a commit that referenced this issue Aug 9, 2015
- Add default OPTIONS endpoint when CORS is enabled
- Resolve #99
@kahmali
Copy link
Owner

kahmali commented Aug 14, 2015

I think I've fixed this issue. I know @jazeee is busy right now. Is anyone else able to test this out and let me know if it works so I can publish it? @AlexFrazer? @nooitaf? I hope to make some major modifications to restivus soon, and I'll have to pull this in without fully testing if it comes to that. All existing tests pass, so at least it doesn't appear to break anything.

Any help is greatly appreciated. Thanks!

@jazeee
Copy link
Contributor Author

jazeee commented Aug 18, 2015

I think the changes look good. I see no issue.

@kahmali
Copy link
Owner

kahmali commented Aug 18, 2015

v0.8.4 has been published with this update

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

No branches or pull requests

4 participants