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

Using Multiple Strategies to protect same resources #2116

Closed
zyos0 opened this issue Apr 29, 2019 · 4 comments
Closed

Using Multiple Strategies to protect same resources #2116

zyos0 opened this issue Apr 29, 2019 · 4 comments

Comments

@zyos0
Copy link

zyos0 commented Apr 29, 2019

I'm submitting a...


[ ] Regression 
[ ] Bug report
[ ] Feature request
[X] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Expected behavior

Be able to specifify multiple authtentication middlewares | authGuards to protect the same resources, let's say for example if a haver this controller but want to be able to authenticate for twitter and google


@UseGuards(AuthGuard(['google', 'twitter']))
async sayHello(){
return  "hello"
}

In this case the controller method should be accesible whether im logged in via twitter or google

@michaeljota
Copy link

According to passport#authenticate source, the strategy type should be typed as string[] | string. However, in the @nest/passport source, the strategy type is typed as string only. So I think this is just a type problem.

@zyos0
Copy link
Author

zyos0 commented Apr 29, 2019

i think this might be right, i just tried the following

`
@UseGuards(AuthGuard(['jwt', 'local'] as any))
async login(@Body() loginInfo) {
console.log(loginInfo);
}

using this i was able to access the resource by the first strategy that suceeded, perhaps it would be good to update that type into :string|String[].

can anyone confirm this?

@kamilmysliwiec
Copy link
Member

Let's track this here nestjs/passport#67

@lock
Copy link

lock bot commented Sep 23, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants