Skip to content

Commit 9be464b

Browse files
committed
Use flagsfiller for env var mapping
1 parent 6b3d4b3 commit 9be464b

File tree

5 files changed

+18
-34
lines changed

5 files changed

+18
-34
lines changed

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,31 @@ Provides a SAML SP authentication proxy for backend web services
88

99
```text
1010
-attribute-header-mappings attribute=header
11-
Comma separated list of attribute=header pairs mapping SAML IdP response attributes to forwarded request header [SAML_PROXY_ATTRIBUTE_HEADER_MAPPINGS]
11+
Comma separated list of attribute=header pairs mapping SAML IdP response attributes to forwarded request header (env SAML_PROXY_ATTRIBUTE_HEADER_MAPPINGS)
1212
-authorize-attribute attribute
13-
Enables authorization and specifies the attribute to check for authorized values [SAML_PROXY_AUTHORIZE_ATTRIBUTE]
13+
Enables authorization and specifies the attribute to check for authorized values (env SAML_PROXY_AUTHORIZE_ATTRIBUTE)
1414
-authorize-values values
15-
If enabled, comma separated list of values that must be present in the authorize attribute [SAML_PROXY_AUTHORIZE_VALUES]
15+
If enabled, comma separated list of values that must be present in the authorize attribute (env SAML_PROXY_AUTHORIZE_VALUES)
1616
-backend-url URL
17-
URL of the backend being proxied [SAML_PROXY_BACKEND_URL]
17+
URL of the backend being proxied (env SAML_PROXY_BACKEND_URL)
1818
-base-url URL
19-
External URL of this proxy [SAML_PROXY_BASE_URL]
19+
External URL of this proxy (env SAML_PROXY_BASE_URL)
2020
-bind host:port
21-
host:port to bind for serving HTTP [SAML_PROXY_BIND] (default ":8080")
21+
host:port to bind for serving HTTP (env SAML_PROXY_BIND) (default ":8080")
2222
-idp-ca-path path
23-
Optional path to a CA certificate PEM file for the IdP [SAML_PROXY_IDP_CA_PATH]
23+
Optional path to a CA certificate PEM file for the IdP (env SAML_PROXY_IDP_CA_PATH)
2424
-idp-metadata-url URL
25-
URL of the IdP's metadata XML [SAML_PROXY_IDP_METADATA_URL]
25+
URL of the IdP's metadata XML (env SAML_PROXY_IDP_METADATA_URL)
2626
-name-id-format string
27-
One of unspecified, transient (default), email, or persistent to use a standard format or give a full URN of the name ID format [SAML_PROXY_NAME_ID_FORMAT]
27+
One of unspecified, transient (default), email, or persistent to use a standard format or give a full URN of the name ID format (env SAML_PROXY_NAME_ID_FORMAT)
2828
-name-id-mapping header
29-
Name of the request header to convey the SAML nameID/subject [SAML_PROXY_NAME_ID_MAPPING]
29+
Name of the request header to convey the SAML nameID/subject (env SAML_PROXY_NAME_ID_MAPPING)
3030
-new-auth-webhook-url URL
31-
URL of webhook that will get POST'ed when a new authentication is processed [SAML_PROXY_NEW_AUTH_WEBHOOK_URL]
31+
URL of webhook that will get POST'ed when a new authentication is processed (env SAML_PROXY_NEW_AUTH_WEBHOOK_URL)
3232
-sp-cert-path path
33-
The path to the X509 public certificate PEM file for this SP [SAML_PROXY_SP_CERT_PATH] (default "saml-auth-proxy.cert")
33+
The path to the X509 public certificate PEM file for this SP (env SAML_PROXY_SP_CERT_PATH) (default "saml-auth-proxy.cert")
3434
-sp-key-path path
35-
The path to the X509 private key PEM file for this SP [SAML_PROXY_SP_KEY_PATH] (default "saml-auth-proxy.key")
35+
The path to the X509 private key PEM file for this SP (env SAML_PROXY_SP_KEY_PATH) (default "saml-auth-proxy.key")
3636
```
3737

3838
The snake-case values, such as `SAML_PROXY_BACKEND_URL`, are the equivalent environment variables

go.mod

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,12 @@ require (
44
github.com/beevik/etree v1.1.0 // indirect
55
github.com/crewjam/saml v0.0.0-20190521120225-344d075952c9
66
github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
7-
github.com/inconshreveable/mousetrap v1.0.0 // indirect
8-
github.com/itzg/go-flagsfiller v1.2.0
9-
github.com/jamiealquiza/envy v1.1.0
7+
github.com/itzg/go-flagsfiller v1.4.0
108
github.com/jonboulle/clockwork v0.1.0 // indirect
119
github.com/kr/pretty v0.1.0 // indirect
1210
github.com/patrickmn/go-cache v2.1.0+incompatible
1311
github.com/pkg/errors v0.8.1
1412
github.com/russellhaering/goxmldsig v0.0.0-20180430223755-7acd5e4a6ef7 // indirect
15-
github.com/spf13/cobra v0.0.3 // indirect
16-
github.com/spf13/pflag v1.0.3 // indirect
1713
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 // indirect
1814
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
1915
)

go.sum

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,8 @@ github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumC
88
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
99
github.com/iancoleman/strcase v0.0.0-20191112232945-16388991a334 h1:VHgatEHNcBFEB7inlalqfNqw65aNkM1lGX2yt3NmbS8=
1010
github.com/iancoleman/strcase v0.0.0-20191112232945-16388991a334/go.mod h1:SK73tn/9oHe+/Y0h39VT4UCxmurVJkR5NA7kMEAOgSE=
11-
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
12-
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
13-
github.com/itzg/go-flagsfiller v1.1.0 h1:QwG9LMAaGizSQCJ56BV4Q1Tu8AgMBGuNkveLAiMyZEU=
14-
github.com/itzg/go-flagsfiller v1.1.0/go.mod h1:mfQgTahSs4OHn8PYev2Wwi1LJXUiYiGuZVCpBLxzbYs=
15-
github.com/itzg/go-flagsfiller v1.2.0 h1:MaDdUhy1cVfzbEVAWXJ41XRg/DFxe6HeFtH5hZGh2Nk=
16-
github.com/itzg/go-flagsfiller v1.2.0/go.mod h1:mfQgTahSs4OHn8PYev2Wwi1LJXUiYiGuZVCpBLxzbYs=
17-
github.com/jamiealquiza/envy v1.1.0 h1:Nwh4wqTZ28gDA8zB+wFkhnUpz3CEcO12zotjeqqRoKE=
18-
github.com/jamiealquiza/envy v1.1.0/go.mod h1:MP36BriGCLwEHhi1OU8E9569JNZrjWfCvzG7RsPnHus=
11+
github.com/itzg/go-flagsfiller v1.4.0 h1:iFi1Xd2yTOP9J+FMJ9QFxM9KdtMMeGMnhgDSWCE4gwk=
12+
github.com/itzg/go-flagsfiller v1.4.0/go.mod h1:mfQgTahSs4OHn8PYev2Wwi1LJXUiYiGuZVCpBLxzbYs=
1913
github.com/jonboulle/clockwork v0.1.0 h1:VKV+ZcuP6l3yW9doeqz6ziZGgcynBVQO+obU0+0hcPo=
2014
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
2115
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
@@ -31,10 +25,6 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
3125
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
3226
github.com/russellhaering/goxmldsig v0.0.0-20180430223755-7acd5e4a6ef7 h1:J4AOUcOh/t1XbQcJfkEqhzgvMJ2tDxdCVvmHxW5QXao=
3327
github.com/russellhaering/goxmldsig v0.0.0-20180430223755-7acd5e4a6ef7/go.mod h1:Oz4y6ImuOQZxynhbSXk7btjEfNBtGlj2dcaOvXl2FSM=
34-
github.com/spf13/cobra v0.0.3 h1:ZlrZ4XsMRm04Fr5pSFxBgfND2EBVa1nLpiy1stUsX/8=
35-
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
36-
github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=
37-
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
3828
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
3929
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
4030
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=

main.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"fmt"
66
"github.com/itzg/go-flagsfiller"
77
"github.com/itzg/saml-auth-proxy/server"
8-
"github.com/jamiealquiza/envy"
98
"log"
109
"os"
1110
)
@@ -18,13 +17,12 @@ var (
1817
func main() {
1918
var serverConfig server.Config
2019

21-
filler := flagsfiller.New()
20+
filler := flagsfiller.New(flagsfiller.WithEnv("SamlProxy"))
2221
err := filler.Fill(flag.CommandLine, &serverConfig)
2322
if err != nil {
2423
log.Fatal(err)
2524
}
2625

27-
envy.Parse("SAML_PROXY")
2826
flag.Parse()
2927

3028
if serverConfig.Version {

server/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
)
1515

1616
type Config struct {
17-
Version bool `usage:"show version and exit"`
17+
Version bool `usage:"show version and exit" env:""`
1818
Bind string `default:":8080" usage:"[host:port] to bind for serving HTTP"`
1919
BaseUrl string `usage:"External [URL] of this proxy"`
2020
BackendUrl string `usage:"[URL] of the backend being proxied"`

0 commit comments

Comments
 (0)