diff options
author | Jaime Martinez <jmartinez@gitlab.com> | 2020-11-26 07:25:47 +0300 |
---|---|---|
committer | Jaime Martinez <jmartinez@gitlab.com> | 2020-12-17 06:24:23 +0300 |
commit | cd780a18d7c07a8af72cf75dc7b6819cdb5026bd (patch) | |
tree | e75234a19119a675d7de66ade10974ac9050e427 /app.go | |
parent | 21066de52d7f7af759bdf2395694c935110da1bb (diff) |
Encrypt and sign OAuth code
Add AES GCM encryption/decryption to auth
Add signing key to Auth
Abstract key generation and Auth init to their own funcs.
Cleanup and DRY unit tests.
Use same code parameter in auth redirect
Cleanup auth and add tests for enc/dec oauth code
Add acceptance test for fix
Apply suggestion from review
Add missing test and apply feedback
Fix unit test
Simplify acceptance test
Diffstat (limited to 'app.go')
-rw-r--r-- | app.go | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -483,10 +483,7 @@ func runApp(config appConfig) { a.Artifact = artifact.New(config.ArtifactsServer, config.ArtifactsServerTimeout, config.Domain) } - if config.ClientID != "" { - a.Auth = auth.New(config.Domain, config.StoreSecret, config.ClientID, config.ClientSecret, - config.RedirectURI, config.GitLabServer) - } + a.setAuth(config) a.Handlers = handlers.New(a.Auth, a.Artifact) @@ -524,6 +521,19 @@ func runApp(config appConfig) { a.Run() } +func (a *theApp) setAuth(config appConfig) { + if config.ClientID == "" { + return + } + + var err error + a.Auth, err = auth.New(config.Domain, config.StoreSecret, config.ClientID, config.ClientSecret, + config.RedirectURI, config.GitLabServer) + if err != nil { + log.WithError(err).Fatal("could not initialize auth package") + } +} + // fatal will log a fatal error and exit. func fatal(err error, message string) { log.WithError(err).Fatal(message) |