-
Notifications
You must be signed in to change notification settings - Fork 561
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: ensure environment variable precedence for auth tokens
- Loading branch information
1 parent
596232f
commit 24417d6
Showing
3 changed files
with
47 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package main | ||
|
||
// !!! This import needs to be the first import, please do not change this !!! | ||
import _ "github.com/snyk/go-application-framework/pkg/networking/fips_enable" | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/snyk/go-application-framework/pkg/auth" | ||
"github.com/snyk/go-application-framework/pkg/configuration" | ||
) | ||
|
||
func defaultOAuthFF(config configuration.Configuration) configuration.DefaultValueFunction { | ||
return func(existingValue interface{}) interface{} { | ||
if _, ok := os.LookupEnv(auth.CONFIG_KEY_OAUTH_TOKEN); ok { | ||
return true | ||
} | ||
|
||
keysThatMightDisableOAuth := config.GetAllKeysThatContainValues(configuration.AUTHENTICATION_BEARER_TOKEN) | ||
alternativeTokenKeys := config.GetAllKeysThatContainValues(configuration.AUTHENTICATION_TOKEN) | ||
keysThatMightDisableOAuth = append(keysThatMightDisableOAuth, alternativeTokenKeys...) | ||
|
||
for _, key := range keysThatMightDisableOAuth { | ||
keyType := config.GetKeyType(key) | ||
if keyType == configuration.EnvVarKeyType { | ||
return false | ||
} | ||
} | ||
|
||
return true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters