diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 16f3432..ff9b20c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -81,10 +81,10 @@ module github.com/greenpau/caddy-security go 1.16 require ( - github.com/greenpau/go-authcrunch v1.0.23 + github.com/greenpau/go-authcrunch v1.0.24 ) -replace github.com/greenpau/go-authcrunch v1.0.23 => /home/greenpau/dev/go/src/github.com/greenpau/go-authcrunch +replace github.com/greenpau/go-authcrunch v1.0.24 => /home/greenpau/dev/go/src/github.com/greenpau/go-authcrunch ``` Then, modify `Makefile` such that that replacement passes to `xcaddy` builder: @@ -93,7 +93,7 @@ Then, modify `Makefile` such that that replacement passes to `xcaddy` builder: @mkdir -p ../xcaddy-$(PLUGIN_NAME) && cd ../xcaddy-$(PLUGIN_NAME) && \ xcaddy build $(CADDY_VERSION) --output ../$(PLUGIN_NAME)/bin/caddy \ --with github.com/greenpau/caddy-security@$(LATEST_GIT_COMMIT)=$(BUILD_DIR) \ - --with github.com/greenpau/go-authcrunch@v1.0.23=/home/greenpau/dev/go/src/github.com/greenpau/go-authcrunch + --with github.com/greenpau/go-authcrunch@v1.0.24=/home/greenpau/dev/go/src/github.com/greenpau/go-authcrunch ``` Once all the necessary packages are installed, you should be ready to compile diff --git a/Makefile b/Makefile index c608b6e..84415d3 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ all: info xcaddy build $(CADDY_VERSION) --output ../$(PLUGIN_NAME)/bin/caddy \ --with github.com/greenpau/caddy-security@$(LATEST_GIT_COMMIT)=$(BUILD_DIR) \ --with github.com/greenpau/caddy-trace@v1.1.8 - @#--with github.com/greenpau/go-authcrunch@v1.0.23=/home/greenpau/dev/go/src/github.com/greenpau/go-authcrunch + @#--with github.com/greenpau/go-authcrunch@v1.0.24=/home/greenpau/dev/go/src/github.com/greenpau/go-authcrunch @#bin/caddy run -config assets/config/Caddyfile @for f in `find ./assets -type f -name 'Caddyfile'`; do bin/caddy fmt -overwrite $$f; done diff --git a/caddyfile_identity_provider.go b/caddyfile_identity_provider.go index 49e2706..0f18f6c 100644 --- a/caddyfile_identity_provider.go +++ b/caddyfile_identity_provider.go @@ -40,6 +40,11 @@ import ( // authorization_url // disable key verification // disable email claim check +// icon +// enable accept header +// enable js callback +// extract from userinfo +// extract all from userinfo // } // // oauth identity provider { @@ -128,6 +133,20 @@ func parseCaddyfileIdentityProvider(d *caddyfile.Dispenser, repl *caddy.Replacer return errors.ErrMalformedDirectiveValue.WithArgs(rd, args, err) } m[k] = i + case "icon": + switch len(args) { + case 1: + m["icon_text"] = args[0] + case 2: + m["icon_text"] = args[0] + m["icon_name"] = args[1] + case 3: + m["icon_text"] = args[0] + m["icon_name"] = args[1] + m["icon_color"] = args[2] + default: + return errors.ErrMalformedDirectiveValue.WithArgs(rd, args, "unsupported value") + } case "disable": // OAuth only. v := strings.Join(args, "_") @@ -150,6 +169,16 @@ func parseCaddyfileIdentityProvider(d *caddyfile.Dispenser, repl *caddy.Replacer return errors.ErrMalformedDirectiveValue.WithArgs(rd, args, "unsupported value") } m[v+"_enabled"] = true + case "extract": + if len(args) < 3 { + return errors.ErrMalformedDirectiveValue.WithArgs(rd, args, "too short") + } + switch { + case strings.HasSuffix(strings.Join(args, " "), "from userinfo"): + m["user_info_fields"] = args[:len(args)-2] + default: + return errors.ErrMalformedDirectiveValue.WithArgs(rd, args, "unsupported value") + } case "required_token_fields": // OAuth only. if len(args) < 1 { diff --git a/go.mod b/go.mod index f61913c..ba438fb 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,6 @@ require ( github.com/caddyserver/caddy/v2 v2.4.6 github.com/google/go-cmp v0.5.7 github.com/google/uuid v1.3.0 - github.com/greenpau/go-authcrunch v1.0.23 + github.com/greenpau/go-authcrunch v1.0.24 go.uber.org/zap v1.20.0 ) diff --git a/go.sum b/go.sum index 29abf2d..1844c0c 100644 --- a/go.sum +++ b/go.sum @@ -476,8 +476,8 @@ github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2z github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/greenpau/go-authcrunch v1.0.23 h1:OFr41do9zFb/0P4022Yd/vZXR4zzJ5l4tjyDXixTbG4= -github.com/greenpau/go-authcrunch v1.0.23/go.mod h1:d54vnpcLS68I0YzGX+d2Svv4tKWmAYs5F9vl5ali6uA= +github.com/greenpau/go-authcrunch v1.0.24 h1:kbl9CqZGXb23+KdCMzUR9bpdpeGfqViEtUcnDzvyXO8= +github.com/greenpau/go-authcrunch v1.0.24/go.mod h1:d54vnpcLS68I0YzGX+d2Svv4tKWmAYs5F9vl5ali6uA= github.com/greenpau/versioned v1.0.27 h1:aFJ16tzsUkbc6WT7DRia60S0VrgWzBNuul3h0RXFKxM= github.com/greenpau/versioned v1.0.27/go.mod h1:rtFCvaWWNbMH4CJnje/xicgmrM63j++rUh5juSu0k/A= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=