-
Notifications
You must be signed in to change notification settings - Fork 5
Feature/files api #540
base: master
Are you sure you want to change the base?
Feature/files api #540
Conversation
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.
Maybe not perfectly correct but you get the gists
d8912fd
to
6085c1d
Compare
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## master #540 +/- ##
==========================================
- Coverage 39.38% 39.00% -0.38%
==========================================
Files 13 13
Lines 3161 3325 +164
==========================================
+ Hits 1245 1297 +52
- Misses 1874 1981 +107
- Partials 42 47 +5
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
d301336
to
d4661c4
Compare
cmd/api/api_test.go
Outdated
WrongTokenAlgClaims = map[string]interface{}{ | ||
"iss": "Online JWT Builder", | ||
"iat": time.Now().Unix(), | ||
"exp": time.Now().Add(time.Hour * 2).Unix(), | ||
"aud": "4e9416a7-3515-447a-b848-d4ac7a57f", | ||
"sub": "[email protected]", | ||
"auth_time": "1632207224", | ||
"jti": "cc847f9c-7608-4b4f-9c6f-6e734813355f", | ||
} |
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.
Unused?
Looks OK, I notice one can have at most one key per issuer, meaning key rotation is not possible, but guess we won't have actual problems with that for now. |
I'm not sure exactly what use case this is meant to address, but I believe it would be nice to make it easier for Or would that be out of scope? |
cd5a83b
to
5832318
Compare
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 i understand correctly the only way to match users to files is if we issue the token ... not sure how that will work from a services standpoint, for this reason I would prefer if having a local key for generating the token is not the default but an option as we can have a list of controlled issuers that we allow to generate the tokens and we can check the users against that.
|
||
if Conf.API.MQ.Connection.IsClosed() { | ||
statusCocde = http.StatusServiceUnavailable | ||
statusCode = http.StatusServiceUnavailable |
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.
not sure i follow why we need MQ checks here,the API does not do anything with the broker.
c.JSON(200, files) | ||
} | ||
|
||
// getUserFromToken parses the token, validates it against the key and returns the key |
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.
i think the token check should be split, so that it is easier to integrate with sda download: see: https://github.com/neicnordic/sda-download/blob/main/pkg/auth/auth.go#L54-L90
Also it would be good to have a list of trusted issuers: https://github.com/neicnordic/sda-download/blob/main/pkg/auth/auth.go#L327-L344
@@ -511,3 +519,28 @@ func CopyHeader() bool { | |||
|
|||
return false | |||
} | |||
|
|||
// Function for reading the ega key in []byte | |||
func GetJwtKey(jwtpubkeypath string, jwtKeys map[string][]byte) error { |
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.
i think we can have /jwk
endpoint and serve our key there so it creates less hassle when changing the function for checking jwt signature.
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.
Yes, that makes sense actually. I might need to leave this function as a second option though, at least until we create an endpoint for serving the key
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's not in https://www.iana.org/assignments/well-known-uris/well-known-uris.xhtml, but .well-known/jwks.json
would be a good path for that, see e.g. https://auth0.com/docs/secure/tokens/json-web-tokens/json-web-key-sets.
c4d69c7
to
da758e6
Compare
cmd/api/api.go
Outdated
|
||
verifiedToken, err := jwt.Parse([]byte(tokenStr), jwt.WithKey(jwa.RS256, key)) | ||
if err != nil { | ||
log.Debugf("failed to verify token as RS256 signature of token %s, %s", tokenStr, err) |
Check failure
Code scanning / CodeQL
Clear-text logging of sensitive information
32cbba3
to
cce3390
Compare
46d6a8b
to
73254ab
Compare
73254ab
to
df1e393
Compare
df1e393
to
b3d17f4
Compare
fb5b12d
to
e46bce5
Compare
5cdd6c5
to
7325bae
Compare
The PR creates an endpoint in the API service for retrieving information about the files a user has submitted. The user is authenticated using the JWToken and currently the way to parse the token is only done through a public key file.