Skip to content

Commit

Permalink
bugfix: empty placeholders in crypto configs
Browse files Browse the repository at this point in the history
  • Loading branch information
greenpau committed Jan 28, 2022
1 parent 134550f commit 057cc47
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ all: info
@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.7=/home/greenpau/dev/go/src/github.com/greenpau/go-authcrunch
@#--with github.com/greenpau/go-authcrunch@v1.0.9=/home/greenpau/dev/go/src/github.com/greenpau/go-authcrunch
@#--with github.com/greenpau/caddy-trace@v1.1.8=/home/greenpau/dev/go/src/github.com/greenpau/caddy-trace
@#bin/caddy run -config assets/config/Caddyfile
@for f in `find ./assets -type f -name 'Caddyfile'`; do bin/caddy fmt -overwrite $$f; done
Expand Down
7 changes: 5 additions & 2 deletions assets/cla/consent.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# Corporate CLA Consent
# By adding your name, email, and company below, you I hereby consent to the
# Corporate CLA Consent provided in assets/cla/corporate_cla.md.
#
#- name: John Smith
# email: foo@bar.com
# company: Contoso Inc.
#
# Individual CLA Consent
# By adding your name and email below, you I hereby consent to the Individual
# CLA provided in assets/cla/individual_cla.md.
#
#- name: John Smith
# email: foo@bar.com
33 changes: 33 additions & 0 deletions assets/cla/corporate_cla.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Corporate Contributor License Agreement

In order to clarify the intellectual property license granted with Contributions from any person or entity, Paul Greenberg ("Project Owner") must have a Contributor License Agreement (CLA) on file that has been signed by each Contributor, indicating agreement to the license terms below. This license is for your protection as a Contributor as well as the protection of Project Owner and its users; it does not change your rights to use your own Contributions for any other purpose.

This version of the Agreement allows an entity (the "Corporation") to submit Contributions to Project Owner, to authorize Contributions submitted by its designated employees to Project Owner, and to grant copyright and patent licenses thereto.

You accept and agree to the following terms and conditions for Your present and future Contributions submitted to Project Owner. Except for the license granted herein to Project Owner and recipients of software distributed by Project Owner, You reserve all right, title, and interest in and to Your Contributions.

## Definitions

"You" (or "Your") shall mean the copyright owner or legal entity authorized by the copyright owner that is making this Agreement with Project Owner. For legal entities, the entity making a Contribution and all other entities that control, are controlled by, or are under common control with that entity are considered to be a single Contributor. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.

"Contribution" shall mean the code, documentation or any original work of authorship, including any modifications or additions to an existing work, that is intentionally submitted by You to Project Owner for inclusion in, or documentation of, any of the products owned or managed by Project Owner (the "Work"). For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to Project Owner or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, Project Owner for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by You as "Not a Contribution."

## Grant of Copyright License

Subject to the terms and conditions of this Agreement, You hereby grant to Project Owner and to recipients of software distributed by Project Owner a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, sublicense, and distribute Your Contributions and such derivative works.

## Grant of Patent License

Subject to the terms and conditions of this Agreement, You hereby grant to Project Owner and to recipients of software distributed by Project Owner a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by You that are necessarily infringed by Your Contribution(s) alone or by combination of Your Contribution(s) with the Work to which such Contribution(s) was submitted. If any entity institutes patent litigation against You or any other entity (including a cross-claim or counterclaim in a lawsuit) alleging that your Contribution, or the Work to which you have contributed, constitutes direct or contributory patent infringement, then any patent licenses granted to that entity under this Agreement for that Contribution or Work shall terminate as of the date such litigation is filed.

## Miscellaneous

1. You represent that You are legally entitled to grant the above license. You represent further that each employee of the Corporation designated by You is authorized to submit Contributions on behalf of the Corporation.

2. You represent that each of Your Contributions is Your original creation (see section 4 for submissions on behalf of others).

3. You are not expected to provide support for Your Contributions, except to the extent You desire to provide support. You may provide support for free, for a fee, or not at all. Unless required by applicable law or agreed to in writing, You provide Your Contributions on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.

4. Should You wish to submit work that is not Your original creation, You may submit it to Project Owner separately from any Contribution, identifying the complete details of its source and of any license or other restriction (including, but not limited to, related patents, trademarks, and license agreements) of which you are personally aware, and conspicuously marking the work as "Submitted on behalf of a third-party: [named here]".

5. It is your responsibility to notify Project Owner when any change is required to the list of designated employees authorized to submit Contributions on behalf of the Corporation, or to the Corporation's Point of Contact with Project Owner.
2 changes: 0 additions & 2 deletions assets/cla/individual_consent.yaml

This file was deleted.

4 changes: 3 additions & 1 deletion caddyfile_authn_crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package security
import (
"github.com/caddyserver/caddy/v2"
"github.com/caddyserver/caddy/v2/caddyconfig/caddyfile"
"github.com/greenpau/caddy-security/pkg/util"
"github.com/greenpau/go-authcrunch/pkg/authn"
"github.com/greenpau/go-authcrunch/pkg/errors"
cfgutil "github.com/greenpau/go-authcrunch/pkg/util/cfg"
Expand All @@ -26,7 +27,8 @@ func parseCaddyfileAuthPortalCrypto(h *caddyfile.Dispenser, repl *caddy.Replacer
if len(args) < 3 {
return h.Errf("%v", errors.ErrConfigDirectiveShort.WithArgs(rootDirective, args))
}
encodedArgs := cfgutil.EncodeArgs(args)

encodedArgs := cfgutil.EncodeArgs(util.FindReplaceAll(repl, args))
switch args[0] {
case "key":
case "default":
Expand Down
2 changes: 1 addition & 1 deletion caddyfile_authz_acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func parseCaddyfileAuthorizationACL(h *caddyfile.Dispenser, repl *caddy.Replacer
return h.Errf("%s directive %q is too long", rootDirective, strings.Join(args, " "))
}
rule := &acl.RuleConfiguration{
Conditions: []string{"always match iss any"},
Conditions: []string{"match any"},
}
switch args[1] {
case "allow", "deny":
Expand Down
2 changes: 1 addition & 1 deletion caddyfile_authz_acl_shortcuts.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func parseCaddyfileAuthorizationACLShortcuts(h *caddyfile.Dispenser, repl *caddy
}
}
if matchAlways {
rule.Conditions = append(rule.Conditions, cfgutil.EncodeArgs(append([]string{"always", "match"}, cond...)))
rule.Conditions = append(rule.Conditions, cfgutil.EncodeArgs([]string{"field", cond[0], "exists"}))
} else {
rule.Conditions = append(rule.Conditions, cfgutil.EncodeArgs(append([]string{"match"}, cond...)))
}
Expand Down
3 changes: 2 additions & 1 deletion caddyfile_authz_crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package security
import (
"github.com/caddyserver/caddy/v2"
"github.com/caddyserver/caddy/v2/caddyconfig/caddyfile"
"github.com/greenpau/caddy-security/pkg/util"
"github.com/greenpau/go-authcrunch/pkg/authz"
"github.com/greenpau/go-authcrunch/pkg/errors"
cfgutil "github.com/greenpau/go-authcrunch/pkg/util/cfg"
Expand All @@ -26,7 +27,7 @@ func parseCaddyfileAuthorizationCrypto(h *caddyfile.Dispenser, repl *caddy.Repla
if len(args) < 3 {
return h.Errf("%v", errors.ErrConfigDirectiveShort.WithArgs(rootDirective, args))
}
encodedArgs := cfgutil.EncodeArgs(args)
encodedArgs := cfgutil.EncodeArgs(util.FindReplaceAll(repl, args))
switch args[0] {
case "key":
case "default":
Expand Down
8 changes: 4 additions & 4 deletions caddyfile_authz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func TestParseCaddyfileAuthorization(t *testing.T) {
}
acl rule {
comment default deny
always match role any
match any
deny log warn
}
}
Expand All @@ -200,7 +200,7 @@ func TestParseCaddyfileAuthorization(t *testing.T) {
{
"comment": "comment default deny",
"conditions": [
"always match role any"
"match any"
],
"action": "deny log warn"
}
Expand Down Expand Up @@ -270,7 +270,7 @@ func TestParseCaddyfileAuthorization(t *testing.T) {
"action": "allow log debug"
},
{
"conditions": ["always match origin any"],
"conditions": ["field origin exists"],
"action": "allow log debug"
},
{
Expand Down Expand Up @@ -310,7 +310,7 @@ func TestParseCaddyfileAuthorization(t *testing.T) {
"action": "allow stop log info"
},
{
"conditions": ["always match iss any"],
"conditions": ["match any"],
"action": "deny"
}
]
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.16
require (
github.com/caddyserver/caddy/v2 v2.4.6
github.com/google/go-cmp v0.5.7
github.com/greenpau/go-authcrunch v1.0.8
github.com/greenpau/go-authcrunch v1.0.9
github.com/satori/go.uuid v1.2.0
go.uber.org/zap v1.20.0
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,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.8 h1:iBU5bMGf/rpOrltZa2Q8ObVF8fmrsxncU3er7t0lgSk=
github.com/greenpau/go-authcrunch v1.0.8/go.mod h1:guuktZjZUnHdP5pZ7D164GtiqKF1s1rlL99GR107XJk=
github.com/greenpau/go-authcrunch v1.0.9 h1:8upZTqfZ0FGT8fZt47wZqgI1bxcLNW2MFGY//kQUObA=
github.com/greenpau/go-authcrunch v1.0.9/go.mod h1:guuktZjZUnHdP5pZ7D164GtiqKF1s1rlL99GR107XJk=
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=
Expand Down

0 comments on commit 057cc47

Please sign in to comment.