-
Notifications
You must be signed in to change notification settings - Fork 12
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
Feat: Add authentication for the test report page #67
Conversation
A few things we need to address:
{
"appID-a": ["read", "write"],
"appID-b": ["read"],
"appID-c": ["admin"],
"admin": ["admin"](A special case for someone who can perform CRUD on any app that reports using Fern),
}
|
main.go
Outdated
|
||
authConfig := config.GetAuth() | ||
if err := auth.UpdateJWKS(authConfig.KeysEndpoint); err != nil { | ||
log.Fatalf("error getting JWKs: %v", err) | ||
} | ||
router.Use(auth.JWTAuthMiddleware(authConfig.KeysEndpoint)) | ||
router.Use(cors.New(cors.Config{ |
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.
Does this fail if the user doesn't provide an endpoint?
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.
If so, how can local testing be done? This would make the product exclusively tied to OAuth.
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.
We probably need to set an env variable through which we can disable OAuth? or @bsekar is there a better way to do integration and acceptance tests?
pkg/auth/middleware_test.go
Outdated
ghttp.RespondWithJSONEncoded(http.StatusOK, map[string]interface{}{ | ||
"keys": []interface{}{ | ||
map[string]interface{}{ | ||
"kty": "RSA", | ||
"alg": "RS256", | ||
"kid": "mAMF03ZNwGBz54bjNJLGtlTC9oP8zJSLrpkfBIH1R-E", | ||
"use": "sig", | ||
"e": "AQAB", | ||
"n": "2uCExuw6kt86vt28clwQ8d0C1UHMUFUbBlthwiOpTTQYkFSbBUQKBJ16P9pnBrVwVr6-s1-84SKGnJnK6EX6IuiTKJQeEurV67ivoahtZXFBk02fBWd8LrkmDdCE59EsVB8zmHycYMCjm133n1THXjcpjQXKHWmTr3D7mP0jgGZWSdxTgGuWbglX5_OhqEZy7LNQQQYwBnGTsBxCm9Fr6g9b_dWz7l_pXpuVuaesMhL7zahwwCBE6d-tpcN_jhujTT6UhRB63uQsehchAot1BWNdBRsOtQtt4OW9EGqUD8ebVtAt8wchRi6wjCva9MLXQQNWehQftSTRqHZ8HNIOsw", | ||
}, | ||
}, | ||
}), | ||
), | ||
) |
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.
It would be cleaner to use the JWK struct here, instead of map[string]interface{}
inline.
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.
This was changed in the refactor.
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.
@bsekar probably needs your review most here
main.go
Outdated
|
||
authConfig := config.GetAuth() | ||
if err := auth.UpdateJWKS(authConfig.KeysEndpoint); err != nil { | ||
log.Fatalf("error getting JWKs: %v", err) | ||
} | ||
router.Use(auth.JWTAuthMiddleware(authConfig.KeysEndpoint)) | ||
router.Use(cors.New(cors.Config{ |
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.
We probably need to set an env variable through which we can disable OAuth? or @bsekar is there a better way to do integration and acceptance tests?
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.
Added comments, please review and address.
d5e9202
to
1e021d5
Compare
1e021d5
to
4975baa
Compare
- Fix other lint issues Signed-off-by: Anoop Gopalakrishnan <[email protected]>
main.go
Outdated
if _, err := jwksCache.Refresh(ctx, authConfig.JSONWebKeysEndpoint); err != nil { | ||
log.Fatalf("URL is not a valid JWKS: %v", err) | ||
} | ||
fmt.Println("JWKS cache initialized and refreshed") |
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.
Use log.info instead of fmt.Println ?
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.
This is outdated. This is no longer in main.go
…pe claim matches the caller.
…r readability. Updated tests.
Good work @marius-williams ! |
Thank you @anoop2811 ! |
Implement Fern Auth
Description:
This pull request introduces authentication functionalities to fern. This is made possible by using the middleware functionality of the Gin framework to intercept all API calls and perform JWT validation using JWKS.
Changes Included: