Repository: chef/automate (go)

Issue:
LDAP login sometimes fails when there is a session for a user but no associated reference in refresh_token_table
## Describe the bug

> I have a customer running into issues with trying to login using LDAP with automate. It looks like it's accepting the credentials, but then giving an error "failed to delete refresh token: not found", then returns a 500 error to the browser. 

We've seen this bug pop up for at least four customers. The main commonality is that LDAP is configured.

While we don't understand why yet, it's apparently possible for a session to be created for an LDAP user whose user ID wasn't added to the `refresh_token table`. On subsequent logins, the user can't log in because it finds the session entry but no refresh_token entry.

## To Reproduce
We've so far been unable to reproduce the circumstances that caused the customer to not have an entry in the refresh_token table in dex.

However, you can simulate the state they're in by removing entries directly from the table.

```
chef-automate dev psql dex
delete from offline_session where user_id="some-user-id";
```

## Expected behavior
LDAP users with a session should always have an associated entry in the `refresh_token table`

We probably need some garbage collection. It'd be ideal to get a fix upstream in dex.

## Versions (please complete the following information):
- Automate Build Number: 
  CLI Build: 20200504210439
  Server Build: 20200506172513

## Additional context
- relevant dex code: https://github.com/dexidp/dex/blame/f2590ee07dbe6a9cd98179ea467255fab41466f4/server/handlers.go#L821-L834
- ticket: https://getchef.zendesk.com/agent/tickets/23553


Pull request description:
auth: filter SAML groups
### :nut_and_bolt: Description: What code changed, and why?

We want to unblock SAML users with too many groups.

ℹ️ This branch includes #3615 and ~should rebased after that one is merged.~ **replaces it**

~🚧 Waiting for `core/dex` to be bumped to 2.24.0: https://github.com/habitat-sh/core-plans/pull/3366~ ✔️ 

~⚠️ **Needs docs** ⚠️~ 

### :chains: Related Resources

#3611
fixes #3668 

### :+1: Definition of Done

You can configure the list of groups, it'll be restricting the groups of users able to login using SAML.

### :athletic_shoe: How to Build and Test the Change

- `rebuild components/automate-dex`
- `rebuild components/automate-deployment`
- `rebuild components/automate-cli`

Login using SAML, note the logs:
```
[2020-05-11T09:51:40+00:00] authz-service.default(O): time="2020-05-11T09:51:40Z" level=info msg="Projects Authorized Query" action="event:events:list" projects="[]" resource="event:events" result="[]" subject="[team:saml:Everyone team:saml:devteam team:saml:All Developers user:saml:srenatus]"
```

Apply this config:
```
[dex.v1.sys.connectors.saml]
allowed_groups = ["Everyone"]
```

```
[16][default:/src:0]# chef-automate config patch saml_groups.toml

Updating deployment configuration

Applying deployment configuration
  Started automate-dex
Success: Configuration patched
```

and notice that **upon re-signin**, the list of user groups will be only `team:saml:Everyone`:

```
[2020-05-14T11:20:32+00:00] authz-service.default(O): time="2020-05-14T11:20:32Z" level=info msg="Projects Authorized Query" action="system:license:get" projects="[]" resource="system:status" result="[*]" subject="[team:saml:Everyone user:saml:srenatus]"
```

### :white_check_mark: Checklist

- [ ] I have read the [CONTRIBUTING document](https://github.com/chef/automate/blob/master/CONTRIBUTING.md).
- [X] Tests added/updated?
- [X] Docs added/updated?
- [X] All commits have been signed-off for the [Developer Certification of Origin](https://github.com/chef/chef/blob/master/CONTRIBUTING.md#developer-certification-of-origin-dco).

### :camera: Screenshots, if applicable


Patch:
diff --git a/api/config/dex/config_request.pb.go b/api/config/dex/config_request.pb.go
index 40c50a9a7..537f05ce7 100644
--- a/api/config/dex/config_request.pb.go
+++ b/api/config/dex/config_request.pb.go
@@ -953,6 +953,7 @@ type ConfigRequest_V1_Saml struct {
 	GroupsAttr           *wrappers.StringValue `protobuf:"bytes,5,opt,name=groups_attr,json=groupsAttr,proto3" json:"groups_attr,omitempty" toml:"groups_attr,omitempty" mapstructure:"groups_attr,omitempty"`
 	EntityIssuer         *wrappers.StringValue `protobuf:"bytes,6,opt,name=entity_issuer,json=entityIssuer,proto3" json:"entity_issuer,omitempty" toml:"entity_issuer,omitempty" mapstructure:"entity_issuer,omitempty"`
 	NameIdPolicyFormat   *wrappers.StringValue `protobuf:"bytes,7,opt,name=name_id_policy_format,json=nameIdPolicyFormat,proto3" json:"name_id_policy_format,omitempty" toml:"name_id_policy_format,omitempty" mapstructure:"name_id_policy_format,omitempty"`
+	AllowedGroups        []string              `protobuf:"bytes,8,rep,name=allowed_groups,json=allowedGroups,proto3" json:"allowed_groups,omitempty" toml:"allowed_groups,omitempty" mapstructure:"allowed_groups,omitempty"`
 	XXX_NoUnkeyedLiteral struct{}              `json:"-" toml:"-" mapstructure:"-,omitempty"`
 	XXX_unrecognized     []byte                `json:"-" toml:"-" mapstructure:"-,omitempty"`
 	XXX_sizecache        int32                 `json:"-" toml:"-" mapstructure:"-,omitempty"`
@@ -1032,6 +1033,13 @@ func (m *ConfigRequest_V1_Saml) GetNameIdPolicyFormat() *wrappers.StringValue {
 	return nil
 }
 
+func (m *ConfigRequest_V1_Saml) GetAllowedGroups() []string {
+	if m != nil {
+		return m.AllowedGroups
+	}
+	return nil
+}
+
 func init() {
 	proto.RegisterType((*ConfigRequest)(nil), "chef.automate.domain.dex.ConfigRequest")
 	proto.RegisterType((*ConfigRequest_V1)(nil), "chef.automate.domain.dex.ConfigRequest.V1")
@@ -1055,89 +1063,91 @@ func init() {
 }
 
 var fileDescriptor_3e591b6849cffa8a = []byte{
-	// 1341 bytes of a gzipped FileDescriptorProto
-	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x98, 0xdd, 0x6e, 0x13, 0x47,
-	0x14, 0xc7, 0x95, 0xd8, 0xf1, 0xc7, 0x49, 0x42, 0xc2, 0x84, 0xc2, 0x6a, 0xa9, 0x10, 0x6a, 0xd5,
-	0x4f, 0x29, 0xeb, 0x26, 0x80, 0x54, 0x68, 0x69, 0x9b, 0x8f, 0x02, 0x09, 0xe1, 0x6b, 0x0d, 0xa8,
-	0xe2, 0x66, 0x35, 0xde, 0x1d, 0x6f, 0x56, 0x8c, 0x67, 0x36, 0x33, 0xe3, 0x10, 0xab, 0x52, 0xaf,
-	0xa0, 0x17, 0x7d, 0x8c, 0x3e, 0x43, 0xaf, 0x7a, 0xc9, 0x55, 0xef, 0xfa, 0x18, 0x7d, 0x00, 0x5e,
-	0xa0, 0x9a, 0x0f, 0x9b, 0x04, 0x07, 0xd8, 0x35, 0x5c, 0x72, 0x67, 0x67, 0xcf, 0xef, 0xef, 0x73,
-	0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c, 0xe8,
-	0xbd, 0x9a, 0xd1, 0xbf, 0x15, 0xa8, 0xea, 0xe7, 0xbf, 0x77, 0xf5, 0xa1, 0x4b, 0x50, 0x97, 0x92,
-	0x47, 0x7d, 0x41, 0x0b, 0x59, 0x51, 0x4d, 0x4a, 0xfe, 0x40, 0xd0, 0x57, 0xa6, 0xab, 0x52, 0x6e,
-	0xba, 0xc6, 0xb6, 0xa3, 0x5a, 0x7a, 0x3b, 0xae, 0xc2, 0xac, 0x6b, 0xb6, 0x11, 0x28, 0x62, 0x45,
-	0x60, 0x81, 0x61, 0x06, 0xfa, 0xff, 0x60, 0x35, 0x88, 0x32, 0x29, 0xfb, 0x05, 0x9f, 0x86, 0xe6,
-	0x2c, 0xb2, 0x65, 0x08, 0x74, 0x07, 0x3e, 0x32, 0x05, 0x64, 0x49, 0x94, 0x73, 0x9a, 0xc5, 0x83,
-	0xa8, 0xcb, 0x45, 0x0f, 0xab, 0x42, 0xe6, 0x83, 0x34, 0xba, 0x95, 0xdc, 0x35, 0xe0, 0x35, 0xc3,
-	0x5d, 0x41, 0xcf, 0x5f, 0x78, 0x27, 0x60, 0x6e, 0xf4, 0xc6, 0x2d, 0x21, 0x07, 0xdb, 0xd5, 0xc6,
-	0xd4, 0x62, 0x65, 0xfd, 0xab, 0x47, 0x5f, 0xa4, 0x99, 0xda, 0xed, 0x77, 0x82, 0x98, 0xf7, 0x5a,
-	0xfa, 0xa9, 0x7e, 0xf4, 0x5e, 0xae, 0x75, 0xf4, 0x3d, 0x61, 0xa7, 0x66, 0x7e, 0xee, 0xc2, 0xff,
-	0x01, 0x00, 0x00, 0xff, 0xff, 0xdd, 0x68, 0xa0, 0xca, 0x40, 0x14, 0x00, 0x00,
+	// 1361 bytes of a gzipped FileDescriptorProto
+	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x98, 0x5b, 0x6f, 0x13, 0x47,
+	0x14, 0xc7, 0x95, 0xd8, 0xf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0xe2, 0xe6, 0xd8, 0xab, 0x9d, 0x2b, 0x5d, 0xa8, 0x87,
+	0x73, 0xee, 0x57, 0x3b, 0x9c, 0x57, 0xd1, 0x8b, 0x97, 0xde, 0x3c, 0x34, 0x86, 0x2f, 0xe6, 0x12,
+	0x72, 0xb0, 0x5d, 0xae, 0x4d, 0x2d, 0x96, 0xd6, 0xbf, 0x7a, 0xfc, 0x65, 0x9a, 0xa9, 0xdd, 0x5e,
+	0x3b, 0x88, 0x79, 0xb7, 0xa9, 0x1f, 0xfe, 0x87, 0xaf, 0xef, 0x9a, 0x47, 0x5f, 0x27, 0xb6, 0x2b,
+	0x26, 0xab, 0x8b, 0xff, 0x07, 0x00, 0x00, 0xff, 0xff, 0x94, 0x03, 0x11, 0xbc, 0x67, 0x14, 0x00,
+	0x00,
 }
diff --git a/api/config/dex/config_request.proto b/api/config/dex/config_request.proto
index 70132badb..511381445 100644
--- a/api/config/dex/config_request.proto
+++ b/api/config/dex/config_request.proto
@@ -123,6 +123,7 @@ message ConfigRequest {
 			google.protobuf.StringValue groups_attr = 5;
 			google.protobuf.StringValue entity_issuer = 6;
 			google.protobuf.StringValue name_id_policy_format = 7;
+			repeated string allowed_groups = 8;
 		}
 	}
 }
diff --git a/components/automate-chef-io/content/docs/saml.md b/components/automate-chef-io/content/docs/saml.md
index 1723b754c..4da52744b 100644
--- a/components/automate-chef-io/content/docs/saml.md
+++ b/components/automate-chef-io/content/docs/saml.md
@@ -59,6 +59,7 @@ sso_url = "<your SSO URL>"                  # required
 email_attr = "<your email attribute>"       # required
 username_attr = "<your username attribute>" # required
 groups_attr = "<your groups attribute>"     # optional
+allowed_groups = ["group1", "group 2"]      # optional
 entity_issuer = "<your entity issuer>"      # optional
 name_id_policy_format = "<see below>"       # optional
 ```
@@ -78,10 +79,13 @@ k2WFcoiiKyeIznNScx/K6AeykKR/lPrJedanSA==
 ```
 
 {{% warning %}}
-The `groups_attr` setting is optional. However, if it is not provided,
-users authenticating via SAML will not be members of any teams.
+The `groups_attr` setting is optional, but if not provided, users authenticating via SAML will not be members of any teams.
 {{% /warning %}}
 
+Setting `allowed_groups` provides SAML sign in to members of the listed groups.
+All of the other user groups that are _not_ in the list are discarded, and not available to Chef Automate.
+In the configuration example above, only users in either "group1" or "group2" may sign in, and those groups would appear as `team:saml:group1` and `team:saml:group2` respectively.
+
 Chef Automate supports using SAML to authenticate users and apply permissions to SAML groups. See [IAM Overview]({{< relref "iam-v2-overview.md" >}}).
 
 ```toml
diff --git a/components/automate-dex/habitat/plan.sh b/components/automate-dex/habitat/plan.sh
index f7711806d..d3a9f493f 100644
--- a/components/automate-dex/habitat/plan.sh
+++ b/components/automate-dex/habitat/plan.sh
@@ -16,7 +16,7 @@ pkg_binds=(
   [pg-sidecar-service]="port"
 )
 pkg_deps=(
-  core/dex/2.19.0
+  core/dex/2.24.0
   chef/mlsa
   ${local_platform_tools_origin:-chef}/automate-platform-tools
   core/bash
diff --git a/components/automate-dex/habitat/templates/config.yml b/components/automate-dex/habitat/templates/config.yml
index f29edd636..0ff68aa37 100644
--- a/components/automate-dex/habitat/templates/config.yml
+++ b/components/automate-dex/habitat/templates/config.yml
@@ -211,6 +211,13 @@ connectors:
       usernameAttr: {{cfg.connectors.saml.username_attr}}
       emailAttr: {{cfg.connectors.saml.email_attr}}
       groupsAttr: {{cfg.connectors.saml.groups_attr}}
+      {{- if cfg.connectors.saml.allowed_groups}}
+      allowedGroups:
+        {{- range cfg.connectors.saml.allowed_groups}}
+        - {{.}}
+        {{- end}}
+      filterGroups: true
+      {{- end}}
       nameIDPolicyFormat: {{cfg.connectors.saml.name_id_policy_format}}
   {{- end}}
 {{- end}}
diff --git a/components/automate-dex/web/templates/login.html b/components/automate-dex/web/templates/login.html
index e81e70566..139d5d4b3 100644
--- a/components/automate-dex/web/templates/login.html
+++ b/components/automate-dex/web/templates/login.html
@@ -7,12 +7,12 @@
     <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
     <title>{{ issuer }}</title>
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
-    <link href="{{ url "static/main.css" }}" rel="stylesheet">
-    <link href="{{ url "theme/styles.css" }}" rel="stylesheet">
+    <link href="{{ url .ReqPath "static/main.css" }}" rel="stylesheet">
+    <link href="{{ url .ReqPath "theme/styles.css" }}" rel="stylesheet">
   </head>
   <div class="theme-panel">
     <div class="logo">
-      <img class="theme-navbar__logo" src="{{url "static/img/automate-blue-d9789f4b.svg" }}">
+      <img class="theme-navbar__logo" src="{{url .ReqPath "static/img/automate-blue-d9789f4b.svg" }}">
     </div>
     <div>
       {{ range $c := .Connectors }}
diff --git a/components/automate-dex/web/templates/password.html b/components/automate-dex/web/templates/password.html
index dccae35fe..5424dad85 100644
--- a/components/automate-dex/web/templates/password.html
+++ b/components/automate-dex/web/templates/password.html
@@ -7,9 +7,9 @@
     <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
     <title>{{ issuer }}</title>
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
-    <link href="{{ url "static/main.css" }}" rel="stylesheet">
-    <link href="{{ url "theme/styles.css" }}" rel="stylesheet">
-    <link rel="stylesheet" href="{{ url "static/font-awesome-4.7.0/css/font-awesome.min.css" }}">
+    <link href="{{ url .ReqPath "static/main.css" }}" rel="stylesheet">
+    <link href="{{ url .ReqPath "theme/styles.css" }}" rel="stylesheet">
+    <link rel="stylesheet" href="{{ url .ReqPath "static/font-awesome-4.7.0/css/font-awesome.min.css" }}">
   </head>
   {{ if .BackLink }}
   <a class="back" href="javascript:history.back()">
@@ -21,7 +21,7 @@
   {{ end }}
   <div class="theme-panel">
     <div class="logo">
-      <img class="theme-navbar__logo" src="{{url "static/img/automate-blue-d9789f4b.svg" }}">
+      <img class="theme-navbar__logo" src="{{url .ReqPath "static/img/automate-blue-d9789f4b.svg" }}">
     </div>
     {{ if .Invalid }}
     <div class="dex-error-box">


Test patch:
diff --git a/api/config/dex/config_request_test.go b/api/config/dex/config_request_test.go
index 3962a31ff..261ec40c8 100644
--- a/api/config/dex/config_request_test.go
+++ b/api/config/dex/config_request_test.go
@@ -53,6 +53,7 @@ func TestValidate(t *testing.T) {
 			UsernameAttr:       w.String("username"),
 			GroupsAttr:         w.String("groups"),
 			NameIdPolicyFormat: w.String("urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified"),
+			AllowedGroups:      []string{"admins", "ops"},
 		}
 	}
 
@@ -369,6 +370,23 @@ func TestValidate(t *testing.T) {
 		})
 	})
 
+	t.Run("allowed_groups (saml)", func(t *testing.T) {
+		valid := map[string][]string{
+			"one group":  {"admins"},
+			"two groups": {"admins", "ops"},
+			"no groups":  {}, // should this warn?
+		}
+		for k, v := range valid {
+			t.Run(k, func(t *testing.T) {
+				cfg := dex.DefaultConfigRequest()
+				saml := completeSAML()
+				saml.AllowedGroups = v
+				cfg.V1.Sys.Connectors = &dex.ConfigRequest_V1_Connectors{Saml: saml}
+				assert.NoError(t, cfg.Validate())
+			})
+		}
+	})
+
 	t.Run("ca_contents", func(t *testing.T) {
 		tests := map[string]func(certs string) *dex.ConfigRequest_V1_Connectors{
 			"saml": func(certs string) *dex.ConfigRequest_V1_Connectors {
diff --git a/api/config/shared/config_test.go b/api/config/shared/config_test.go
index 9ab5ac3dd..ab33e4e6c 100644
--- a/api/config/shared/config_test.go
+++ b/api/config/shared/config_test.go
@@ -1,21 +1,60 @@
-package shared
+package shared_test
 
 import (
 	"testing"
 
+	"github.com/chef/automate/api/config/dex"
+	"github.com/chef/automate/api/config/shared"
+	"github.com/chef/toml"
 	"github.com/stretchr/testify/assert"
 )
 
 func TestAddKeyMissing(t *testing.T) {
-	c := NewInvalidConfigError()
+	c := shared.NewInvalidConfigError()
 	c.AddMissingKey("foo")
 
 	assert.EqualValues(t, c.MissingKeys(), []string{"foo"})
 }
 
 func TestAddInvalidValue(t *testing.T) {
-	c := NewInvalidConfigError()
+	c := shared.NewInvalidConfigError()
 	c.AddInvalidValue("foo", "bar")
 
 	assert.EqualValues(t, c.InvalidValues(), map[string]string{"foo": "bar"})
 }
+
+func TestDexSAMLAllowedGroupsOptionalList(t *testing.T) {
+	t.Run("no list", func(t *testing.T) {
+		c := loadDexSAMLConfigFromToml(`
+groups_attr = "groups"
+`)
+		setting := c.GetAllowedGroups()
+		assert.Equal(t, "groups", c.GetGroupsAttr().Value)
+		assert.Equal(t, []string(nil), setting) // not set means nil
+	})
+
+	t.Run("empty list", func(t *testing.T) {
+		c := loadDexSAMLConfigFromToml(`
+allowed_groups = []
+`)
+		setting := c.GetAllowedGroups()
+		assert.EqualValues(t, []string{}, setting) // set to empty list means []string{}
+	})
+
+	t.Run("non-empty list", func(t *testing.T) {
+		c := loadDexSAMLConfigFromToml(`
+allowed_groups = ["alices", "bobs"]
+`)
+		setting := c.GetAllowedGroups()
+		assert.EqualValues(t, []string{"alices", "bobs"}, setting)
+	})
+}
+
+func loadDexSAMLConfigFromToml(s string) *dex.ConfigRequest_V1_Saml {
+	c := &dex.ConfigRequest_V1_Saml{}
+	err := toml.Unmarshal([]byte(s), c)
+	if err != nil {
+		panic(err)
+	}
+	return c
+}