-
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.
Improve the Header Authentication Method
This adds more of the code needed to properly authenticate a user based on headers present added by a reverse proxy.
- Loading branch information
Mitchell Grenier
committed
Sep 27, 2019
1 parent
b9ce02d
commit d7a86e4
Showing
4 changed files
with
112 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