loopback-next icon indicating copy to clipboard operation
loopback-next copied to clipboard

[authentication] API call for anonymous requests returns error

Open ashdns opened this issue 8 years ago • 7 comments

I integrated authentication component according to instructions. Now when I'm trying to call an endpoint which doesn't have @ authentication(), it returns 500 error: Unhandled error in GET /testx: 500 Authentication metadata not found

`import {get} from '@loopback/rest';

export class UserController {

@get('/testx')
testx() {
    return "anonymous";
}

}`

My packages: "dependencies": { "@ loopback/authentication": ">=4.0.0-alpha.19", "@ loopback/context": ">=4.0.0-alpha.21", "@ loopback/core": ">=4.0.0-alpha.23", "@ loopback/rest": ">=4.0.0-alpha.12", "@ types/passport": "^0.4.1", "@ types/passport-http": "^0.3.3", "passport": "^0.4.0", "passport-http": "^0.3.0" },

ashdns avatar Dec 11 '17 04:12 ashdns

If you can provide a simple repo to reproduce the problem, it will help us troubleshoot the issue more effectively. Thanks.

raymondfeng avatar Dec 11 '17 05:12 raymondfeng

Thanks for your reply. I just sent you an invitation to my repo. Please check out develop branch.

ashdns avatar Dec 11 '17 06:12 ashdns

I'm trying to authenticate users with http header token which was simple to implement in lb3. However with lb4 I'm a bit confused.

ashdns avatar Dec 11 '17 10:12 ashdns

@arash01 Hello, I can try to help with the issue here. Could you send me an invitation as well? Thanks.

shimks avatar Dec 11 '17 15:12 shimks

I noticed that verify function in src/providers/auth-strategy.ts is empty. Could you confirm if this is the source of the problem?

shimks avatar Dec 11 '17 16:12 shimks

@arash01 Please reference to the PR above and try the fix in it. Let us know if this fixes the problem.

shimks avatar Dec 11 '17 17:12 shimks

Thanks, it solved the issue

ashdns avatar Dec 12 '17 01:12 ashdns