| 1 |
package config |
| 2 |
|
| 3 |
import ( |
| 4 |
"html/template" |
| 5 |
"log/slog" |
| 6 |
"net/url" |
| 7 |
"time" |
| 8 |
|
| 9 |
"github.com/jkroepke/openvpn-auth-oauth2/v2/internal/config/types" |
| 10 |
"github.com/jkroepke/openvpn-auth-oauth2/v2/internal/ui" |
| 11 |
"github.com/jkroepke/openvpn-auth-oauth2/v2/internal/ui/assets" |
| 12 |
"golang.org/x/oauth2" |
| 13 |
) |
| 14 |
|
| 15 |
const ( |
| 16 |
CommonName = "common_name" |
| 17 |
SchemeHTTP = "http" |
| 18 |
SchemeHTTPS = "https" |
| 19 |
SchemeTCP = "tcp" |
| 20 |
SchemeUNIX = "unix" |
| 21 |
) |
| 22 |
|
| 23 |
//nolint:gochecknoglobals |
| 24 |
var Defaults = Config{ |
| 25 |
Debug: Debug{ |
| 26 |
Listen: "127.0.0.1:9001", |
| 27 |
}, |
| 28 |
Log: Log{ |
| 29 |
Format: "console", |
| 30 |
Level: slog.LevelInfo, |
| 31 |
VPNClientIP: true, |
| 32 |
}, |
| 33 |
HTTP: HTTP{ |
| 34 |
AssetPath: types.FS{FS: assets.FS}, |
| 35 |
BaseURL: types.URL{URL: &url.URL{ |
| 36 |
Scheme: SchemeHTTP, |
| 37 |
Host: "localhost:9000", |
| 38 |
}}, |
| 39 |
Listen: ":9000", |
| 40 |
TLS: false, |
| 41 |
Check: HTTPCheck{ |
| 42 |
IPAddr: false, |
| 43 |
}, |
| 44 |
TrustedProxies: types.StringSlice{}, |
| 45 |
Template: types.Template{Template: template.Must(template.New("index.gohtml").ParseFS(ui.Template, "index.gohtml"))}, |
| 46 |
}, |
| 47 |
OpenVPN: OpenVPN{ |
| 48 |
Addr: types.URL{URL: &url.URL{ |
| 49 |
Scheme: SchemeUNIX, |
| 50 |
Path: "/run/openvpn/server.sock", |
| 51 |
OmitHost: true, |
| 52 |
}}, |
| 53 |
AuthTokenUser: true, |
| 54 |
AuthPendingTimeout: 3 * time.Minute, |
| 55 |
ClientConfig: OpenVPNConfig{ |
| 56 |
Enabled: false, |
| 57 |
Path: types.NewRootFS("/etc/openvpn-auth-oauth2/client-config/"), |
| 58 |
IgnoreNotFound: true, |
| 59 |
}, |
| 60 |
CommonName: OpenVPNCommonName{ |
| 61 |
EnvironmentVariableName: "common_name", |
| 62 |
}, |
| 63 |
EnforceUniqueUser: false, |
| 64 |
OverrideUsername: false, |
| 65 |
Bypass: OpenVPNBypass{ |
| 66 |
CommonNames: types.RegexpSlice{}, |
| 67 |
}, |
| 68 |
Passthrough: OpenVPNPassthrough{ |
| 69 |
Enabled: false, |
| 70 |
Address: types.URL{URL: &url.URL{ |
| 71 |
Scheme: SchemeUNIX, |
| 72 |
Path: "/run/openvpn-auth-oauth2/server.sock", |
| 73 |
OmitHost: true, |
| 74 |
}}, |
| 75 |
SocketMode: 0o660, |
| 76 |
SocketGroup: "", |
| 77 |
}, |
| 78 |
CommandTimeout: 10 * time.Second, |
| 79 |
ReAuthentication: true, |
| 80 |
}, |
| 81 |
OAuth2: OAuth2{ |
| 82 |
AuthStyle: OAuth2AuthStyle(oauth2.AuthStyleInParams), |
| 83 |
Client: OAuth2Client{}, |
| 84 |
Endpoints: OAuth2Endpoints{ |
| 85 |
Auth: types.URL{URL: &url.URL{Scheme: "", Host: ""}}, |
| 86 |
Discovery: types.URL{URL: &url.URL{Scheme: "", Host: ""}}, |
| 87 |
Token: types.URL{URL: &url.URL{Scheme: "", Host: ""}}, |
| 88 |
}, |
| 89 |
Issuer: types.URL{URL: &url.URL{Scheme: "", Host: ""}}, |
| 90 |
Nonce: true, |
| 91 |
RefreshNonce: OAuth2RefreshNonceAuto, |
| 92 |
PKCE: true, |
| 93 |
UserInfo: false, |
| 94 |
GroupsClaim: "groups", |
| 95 |
Provider: "generic", |
| 96 |
OpenVPNUsername: "user.username", |
| 97 |
Refresh: OAuth2Refresh{ |
| 98 |
Expires: time.Hour * 8, |
| 99 |
ValidateUser: true, |
| 100 |
}, |
| 101 |
Scopes: make([]string, 0), |
| 102 |
Validate: OAuth2Validate{ |
| 103 |
Groups: make([]string, 0), |
| 104 |
}, |
| 105 |
}, |
| 106 |
Provider: Provider{ |
| 107 |
Google: ProviderGoogle{ |
| 108 |
Validate: ProviderGoogleValidate{ |
| 109 |
GroupsTransitive: false, |
| 110 |
}, |
| 111 |
}, |
| 112 |
}, |
| 113 |
} |