From 465c8c9036aa727813a91ab6a5374bc939dada9a Mon Sep 17 00:00:00 2001 From: Jim Date: Sat, 5 Jun 2021 13:17:46 -0400 Subject: [PATCH] stop panicing because the issuer port is invalid. (#1282) --- .../authmethods/authmethod_service.go | 2 +- .../handlers/authmethods/oidc_test.go | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/internal/servers/controller/handlers/authmethods/authmethod_service.go b/internal/servers/controller/handlers/authmethods/authmethod_service.go index 6be950ad1..69affed46 100644 --- a/internal/servers/controller/handlers/authmethods/authmethod_service.go +++ b/internal/servers/controller/handlers/authmethods/authmethod_service.go @@ -994,7 +994,7 @@ func validateUpdateRequest(req *pbs.UpdateAuthMethodRequest) error { if err != nil { badFields[issuerField] = fmt.Sprintf("Cannot be parsed as a url. %v", err) } - if !strutil.StrListContains([]string{"http", "https"}, iss.Scheme) { + if iss != nil && !strutil.StrListContains([]string{"http", "https"}, iss.Scheme) { badFields[issuerField] = fmt.Sprintf("Must have schema %q or %q specified", "http", "https") } } diff --git a/internal/servers/controller/handlers/authmethods/oidc_test.go b/internal/servers/controller/handlers/authmethods/oidc_test.go index bcafd774b..ffa5e1718 100644 --- a/internal/servers/controller/handlers/authmethods/oidc_test.go +++ b/internal/servers/controller/handlers/authmethods/oidc_test.go @@ -430,6 +430,25 @@ func TestUpdate_OIDC(t *testing.T) { }, }, }, + { + name: "invalid-issuer-port", + req: &pbs.UpdateAuthMethodRequest{ + UpdateMask: &field_mask.FieldMask{ + Paths: []string{"attributes.issuer"}, + }, + Item: &pb.AuthMethod{ + Attributes: &structpb.Struct{ + Fields: func() map[string]*structpb.Value { + f := defaultAttributeFields() + f["issuer"] = structpb.NewStringValue("http://localhost:7dddd") + f["disable_discovered_config_validation"] = structpb.NewBoolValue(true) + return f + }(), + }, + }, + }, + err: handlers.ApiErrorWithCode(codes.InvalidArgument), + }, { name: "No Update Mask", req: &pbs.UpdateAuthMethodRequest{