-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from obelisk/improve_header_auth
Improve the Header Authentication Method
- Loading branch information
Showing
4 changed files
with
122 additions
and
7 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
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,30 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
|
||
"github.com/jmpsec/osctrl/pkg/settings" | ||
"github.com/jmpsec/osctrl/pkg/types" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
// Function to load the configuration file | ||
func loadHeaders(file string) (types.JSONConfigurationHeaders, error) { | ||
var cfg types.JSONConfigurationHeaders | ||
log.Printf("Loading %s", file) | ||
// Load file and read config | ||
viper.SetConfigFile(file) | ||
err := viper.ReadInConfig() | ||
if err != nil { | ||
return cfg, err | ||
} | ||
// Header values | ||
headersRaw := viper.Sub(settings.AuthHeaders) | ||
err = headersRaw.Unmarshal(&cfg) | ||
if err != nil { | ||
return cfg, err | ||
} | ||
|
||
// No errors! | ||
return cfg, nil | ||
} |
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