Skip to content

The boilerplate project is outdated and does not work well with the new version #101

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

Closed
evelyne24 opened this issue Jun 18, 2019 · 3 comments

Comments

@evelyne24
Copy link

evelyne24 commented Jun 18, 2019

After your update, 2.2.0, if someone is using your boilerplate project, it will stop working because there is an incompatibility with typescript-rest-swagger and multiple authenticators. I've added the stack trace in this other bug #91. Can you please update the documentation with a relevant example on how to use the securityDefinitions in swagger.config.json and the Swagger UI with Bearer Authorization?

I have this in swagger.config.json:

"securityDefinitions": {
	"Bearer": {
		"type": "apiKey",
		"in": "header",
		"name": "Authorization"
	}
}

This produces the following Swagger UI authorization:

Screenshot 2019-06-18 at 10 01 43

However, when I try any request in Swagger UI, the Authorization Header is not added: curl -X GET "http://localhost:8080/users/1/accounts?includeExpired=true" -H "accept: application/json"

I then updated to 2.2.0 and tried to add Server.registerAuthenticator(new MyCustomTokenAuth(), 'MyAuth'); and on my controller, I use @Security('ROLE_USER', 'MyAuth') but it seems that typescript-rest-swagger refuses to generate the swagger file with the following error:

node_modules/typescript-rest-swagger/dist/metadata/controllerGenerator.js:93
            scopes: d.arguments[1] ? d.arguments[1].elements.map(function (e) { return e.text; }) : undefined                                                
TypeError: Cannot read property 'map' of undefined

Could you update your boilerplate example and the documentation to provide a clear example on how to achieve this? Thanks.

@thiagobustamante
Copy link
Owner

Done. I opened a PR to typescript-rest-boilerplate:

vrudikov/typescript-rest-boilerplate#10

@evelyne24
Copy link
Author

Hi. I see the update but this doesn't answer the Swagger UI Authorization question. Does it work with the new version 2.2.0 or not yet? And if it's supposed to work, can you include an example? This is a very common use case. Also, there's a comment that the update is actually breaking.

@thiagobustamante
Copy link
Owner

thiagobustamante commented Jun 24, 2019

Hi @evelyne24,

Yes, it works with version 2.2.0 (+), but you need the latest version of typescript-rest-swagger (1.0.3 at least).

I send a PR to typescript-rest-boilerplate showing an working example: vrudikov/typescript-rest-boilerplate#12

In that example, I added two authenticators. Both of them using jwt with the secret: some-jwt-secret

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