Remove reliance on global state
Review Request #9782 — Created March 15, 2018 and submitted
This patch is a cleanup of the API routes. The major change is that we
now have anAPI
type which contains the API methods. With this change,
the routes now have access to the API's configuration so we no longer
need a globalConfig
object!Additionally, some cleanup has been done to the routes that require a
repository with theapi.withRepository
middleware, which provides the
requested repository as the"repo"
context variable (instead of having
each route retrieve it and do error checking). Routes have been
re-written to have a simpler error-checking flow as well.
Ran unit tests.
Description | From | Last Updated |
---|---|---|
Do we need to fetch the config from out of this package? It seems better if this were unexported. |
david | |
Wrapping here doesn't really improve readability. |
david | |
I think I prefer having the table of path/method/handler that we iterate over to build all the routes. |
david | |
This is not a good error message, plus things should use log rather than println. Leftover debug output? |
david | |
Same here. |
david | |
Leftover debug output? |
david | |
Typo: Contenet |
david | |
This needs to be run through gofmt |
david |
- Summary:
-
Remove reliance on global state and prevent timing attacks in authRemove reliance on global state
- Description:
-
This patch is a cleanup of the API routes. The major change is that we
now have an API
type which contains the API methods. With this change,the routes now have access to the API's configuration so we no longer need a global Config
object!Additionally, some cleanup has been done to the routes that require a
repository with the api.withRepository
middleware, which provides therequested repository as the "repo"
context variable (instead of havingeach route retrieve it and do error checking). Routes have been re-written to have a simpler error-checking flow as well. - - Authentication has also been cleaned up a touch. We now prevent timing
- attacks when authentication by using constant time username and password - comparison. - Commit:
-
04b72aa6e85d7f359b73095492f469faa1d3a6b7dcb2f7d65089261819140f0b4764f99494a63ff7
Checks run (2 succeeded)
- Change Summary:
-
Addressed David's issues.
- Commit:
-
dcb2f7d65089261819140f0b4764f99494a63ff78125191a1503f9a4bbb89c62af685d2197b4b8ff
Checks run (2 succeeded)
- Commit:
-
8125191a1503f9a4bbb89c62af685d2197b4b8ffd9ade07a06326078aa18d88a3d163d0e8873461b