Skip to content

Commit

Permalink
upgrade to go1.21 and github.com/greenpau/go-authcrunch v1.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
greenpau committed Mar 24, 2024
1 parent 2a4b891 commit b3739cf
Show file tree
Hide file tree
Showing 10 changed files with 136 additions and 8 deletions.
3 changes: 3 additions & 0 deletions caddyfile_authn.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ func parseCaddyfileAuthentication(d *caddyfile.Dispenser, repl *caddy.Replacer,
CookieConfig: &cookie.Config{},
TokenValidatorOptions: &options.TokenValidatorOptions{},
TokenGrantorOptions: &options.TokenGrantorOptions{},
API: &authn.APIConfig{
ProfileEnabled: true,
},
}
for nesting := d.Nesting(); d.NextBlock(nesting); {
k := d.Val()
Expand Down
5 changes: 1 addition & 4 deletions caddyfile_authn_misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ func parseCaddyfileAuthPortalMisc(h *caddyfile.Dispenser, repl *caddy.Replacer,
case v == "source ip tracking":
portal.TokenGrantorOptions.EnableSourceAddress = true
case v == "admin api":
if portal.API == nil {
portal.API = &authn.APIConfig{}
portal.API.Enabled = true
}
portal.API.AdminEnabled = true
case strings.HasPrefix(v, "identity provider"):
if len(args) < 3 {
return h.Errf("malformed directive for %s: %s", rootDirective, v)
Expand Down
12 changes: 12 additions & 0 deletions caddyfile_authn_misc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,19 @@ func TestParseCaddyfileAuthenticationMisc(t *testing.T) {
{
"cookie_config": {},
"identity_stores": ["localdb"],
"portal_admin_roles": {
"authp/admin": true
},
"portal_user_roles": {
"authp/user": true
},
"portal_guest_roles": {
"authp/guest": true
},
"name": "myportal",
"api": {
"profile_enabled": true
},
"token_grantor_options": {},
"trusted_logout_redirect_uri_configs": [
{
Expand Down
12 changes: 12 additions & 0 deletions caddyfile_authn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ func TestParseCaddyfileAuthentication(t *testing.T) {
]
}
],
"api": {
"profile_enabled": true
},
"cookie_config": {
"domains": {
"contoso.com": {
Expand All @@ -179,6 +182,15 @@ func TestParseCaddyfileAuthentication(t *testing.T) {
"azure",
"okta"
],
"portal_admin_roles": {
"authp/admin": true
},
"portal_user_roles": {
"authp/user": true
},
"portal_guest_roles": {
"authp/guest": true
},
"token_validator_options": {
"validate_source_address": true
},
Expand Down
24 changes: 24 additions & 0 deletions caddyfile_identity_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,22 @@ func TestParseCaddyfileIdentityProvider(t *testing.T) {
{
"name": "myportal",
"ui": {},
"api": {
"profile_enabled": true
},
"cookie_config": {},
"identity_providers": [
"authp"
],
"portal_admin_roles": {
"authp/admin": true
},
"portal_user_roles": {
"authp/user": true
},
"portal_guest_roles": {
"authp/guest": true
},
"token_validator_options": {},
"token_grantor_options": {}
}
Expand Down Expand Up @@ -125,6 +137,18 @@ func TestParseCaddyfileIdentityProvider(t *testing.T) {
"name": "myportal",
"ui": {},
"cookie_config": {},
"api": {
"profile_enabled": true
},
"portal_admin_roles": {
"authp/admin": true
},
"portal_user_roles": {
"authp/user": true
},
"portal_guest_roles": {
"authp/guest": true
},
"identity_providers": [
"authp"
],
Expand Down
24 changes: 24 additions & 0 deletions caddyfile_identity_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ func TestParseCaddyfileIdentityStore(t *testing.T) {
"identity_stores": [
"localdb"
],
"portal_admin_roles": {
"authp/admin": true
},
"portal_user_roles": {
"authp/user": true
},
"portal_guest_roles": {
"authp/guest": true
},
"api": {
"profile_enabled": true
},
"token_validator_options": {},
"token_grantor_options": {}
}
Expand Down Expand Up @@ -104,10 +116,22 @@ func TestParseCaddyfileIdentityStore(t *testing.T) {
{
"name": "myportal",
"ui": {},
"api": {
"profile_enabled": true
},
"cookie_config": {},
"identity_stores": [
"contoso.com"
],
"portal_admin_roles": {
"authp/admin": true
},
"portal_user_roles": {
"authp/user": true
},
"portal_guest_roles": {
"authp/guest": true
},
"token_validator_options": {},
"token_grantor_options": {}
}
Expand Down
12 changes: 12 additions & 0 deletions caddyfile_identity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,22 @@ func TestParseCaddyfileIdentity(t *testing.T) {
"identity_stores": [
"localdb"
],
"api": {
"profile_enabled": true
},
"identity_providers": [
"authp",
"github"
],
"portal_admin_roles": {
"authp/admin": true
},
"portal_user_roles": {
"authp/user": true
},
"portal_guest_roles": {
"authp/guest": true
},
"token_validator_options": {},
"token_grantor_options": {}
}
Expand Down
12 changes: 12 additions & 0 deletions caddyfile_sso_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,21 @@ func TestParseCaddyfileSingleSignOnProvider(t *testing.T) {
"identity_stores": [
"localdb"
],
"portal_admin_roles": {
"authp/admin": true
},
"portal_user_roles": {
"authp/user": true
},
"portal_guest_roles": {
"authp/guest": true
},
"sso_providers": [
"aws"
],
"api": {
"profile_enabled": true
},
"token_validator_options": {},
"token_grantor_options": {}
}
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module github.com/greenpau/caddy-security

go 1.20
go 1.21

require (
github.com/caddyserver/caddy/v2 v2.7.6
github.com/google/go-cmp v0.6.0
github.com/google/uuid v1.6.0
github.com/greenpau/caddy-trace v1.1.13
github.com/greenpau/go-authcrunch v1.0.50
github.com/greenpau/go-authcrunch v1.1.2
github.com/tidwall/gjson v1.17.1
go.uber.org/zap v1.27.0
)
Expand Down
Loading

0 comments on commit b3739cf

Please sign in to comment.