Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding constants to prepare for OIDC auth #424

Merged
merged 1 commit into from Apr 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
38 changes: 38 additions & 0 deletions admin/oidc.go
@@ -0,0 +1,38 @@
package main

import (
"log"

"github.com/jmpsec/osctrl/settings"
"github.com/spf13/viper"
)

// JSONConfigurationOIDC to keep all OIDC details for auth
type JSONConfigurationOIDC struct {
IssuerURL string `json:"issuerurl"`
ClientID string `json:"clientid"`
ClientSecret string `json:"clientsecret"`
RedirectURL string `json:"redirecturl"`
Scope []string `json:"scope"`
Nonce string `json:"nonce"`
ResponseType string `json:"responsetype"`
AuthorizationCode string `json:"authorizationcode"`
}

// Function to load the configuration file
func loadOIDC(file string) (JSONConfigurationOIDC, error) {
var cfg JSONConfigurationOIDC
log.Printf("Loading %s", file)
// Load file and read config
viper.SetConfigFile(file)
if err := viper.ReadInConfig(); err != nil {
return cfg, err
}
// OAuth values
oauthRaw := viper.Sub(settings.AuthOIDC)
if err := oauthRaw.Unmarshal(&cfg); err != nil {
return cfg, err
}
// No errors!
return cfg, nil
}
1 change: 1 addition & 0 deletions settings/settings.go
Expand Up @@ -30,6 +30,7 @@ const (
AuthSAML string = "saml"
AuthJWT string = "jwt"
AuthOAuth string = "oauth"
AuthOIDC string = "oidc"
)

// Types of logging
Expand Down