-
Notifications
You must be signed in to change notification settings - Fork 227
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
Add jwtauth middleware #662
Conversation
fn/common/api.go
Outdated
@@ -4,7 +4,9 @@ import ( | |||
"crypto/tls" | |||
"net/http" | |||
"os" | |||
"fmt" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please apply gofmt
to this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok thanks, done !
Hi, Arda! Yes, we need "Bearer" at the beginning of Authorization header. functions/fn/commands/routes.go Line 265 in c3d25a9
Regard to client side, how about having JWT_AUTH_KEY in the configuration file? e.g. ~/.ironfconfig.yml when the user has ~/.ironfconfig.yml override the former. |
Hi, @c0ze. I think I had misunderstood about what you asked. As for two token clash, middleware authenticates /v1/* access using with “JWT_AUTH_KEY” env variable. In addition What do you think about removing IRON_TOKEN? I also sent a message in Slack :) |
@kunihiko-t thanks for the feedback ! Hmm, yes in that case it won't clash, so that's good news ! I am still looking for a good way to test this... Yeah, I think IRON_TOKEN was somekind of experimental feature which we can remove. |
@kunihiko-t I modified FullStackTest to test jwt authentication (with valid and invalid tokens). Now I'm looking for some kind of integration testing with the fn tool. |
hello @vasilev @kunihiko-t , I added integration tests to this PR. I would appreciate if you could take a look ! This is necessary for #663 because I am planning to use a similar testing harness, so would like to merge this in first. Thank you ! |
Hello, @c0ze. I've tried to run some test with I think
According to this document, multiple lines represent AND condition Regarding test with server tag, So I think following files should have
But If we change those files, functions/api/server/server_auth_test.go Line 59 in 9315060
Thanks :) |
Thank you for the review ! Instead of writing a big review, can you please mention individual problems inline with the changes ? I think it is the usual github review procedure. I will give you an example. |
api/server/server_test.go
Outdated
@@ -1,3 +1,6 @@ | |||
// +build full_stack | |||
// +build server | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for example, like this,
According to this document, multiple lines represent AND condition
https://golang.org/pkg/go/build/#hdr-Build_Constraints
It is easier to follow context this way.
Thank you !
About test tags, actually, I think I will remove |
@kunihiko-t I removed |
there is a leftover file at
probably the teardown function is not being called somewhere (or overwritten ? but it is not possible in Go I think) I'm not sure what's going on, hmmm ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for tests. Code looks good to me.
@c0ze It works! Thanks! functions/api/server/server_test.go Line 131 in b562394
) and it has server tag. Therefore it is called when we run make test-tag TAG=server .
When we run with |
@kunihiko-t I see, thank you for the analysis. However, I don't agree with your proposal. Instead, I will try to find why it is being created in the first place, when tests are called without |
ok, I found it. It was being created in one of the datastore tests. |
This adds JWT authentication for all API routes, adding as a middleware.
One problem, when doing a route call, two tokens will clash. @kunihiko-t any ideas for this ? Maybe we can set a specific Realm ? Bearer ?
todos :