Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes for tctl sso test, tctl sso configure commands [SAML] #11508

Merged
merged 61 commits into from
May 4, 2022
Merged
Show file tree
Hide file tree
Changes from 58 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
40f3384
Changes for tctl sso test, tctl sso configure commands
Tener Mar 28, 2022
5500941
Merge branch 'master' into tener/tctl-sso
Tener Mar 28, 2022
e3601a5
Make SSO logging aware of test flows.
Tener Mar 29, 2022
6baf347
Proper method comments.
Tener Mar 29, 2022
5d63ea4
Linter issues.
Tener Mar 29, 2022
9321431
require additional permissions for SSO test flow.
Tener Mar 29, 2022
cbd1090
Update submodule
Tener Mar 29, 2022
1706eaa
Merge branch 'master' into tener/tctl-sso
Tener Mar 30, 2022
097f671
Correct the comment.
Tener Mar 30, 2022
0a6cb7f
Take into account possibly nil variable.
Tener Mar 30, 2022
1e528aa
Declare SSOInfoType as protobuf message.
Tener Apr 5, 2022
c78abc1
Make SSO diag info shared for all auth types.
Tener Apr 5, 2022
354eda9
Rename function for clarity.
Tener Apr 5, 2022
af11fd5
Error handling fixes.
Tener Apr 5, 2022
e4c585f
Use custom marshalling for createUserParams type.
Tener Apr 5, 2022
f14961c
Refactoring to match updated API, cleanups.
Tener Apr 5, 2022
bfeca4c
Lint.
Tener Apr 5, 2022
030d591
Merge branch 'master' into tener/tctl-sso
Tener Apr 5, 2022
fd76564
Add negative test case.
Tener Apr 5, 2022
d6d2c4a
Add missing argument - post-merge cleanup.
Tener Apr 5, 2022
890fd8f
Extend several methods with ctx param.
Tener Apr 5, 2022
a931d9c
Add missing trace.Wrap() calls
Tener Apr 5, 2022
dd69d71
Use existing ctx for CreateSSODiagnosticInfo call
Tener Apr 5, 2022
d9d2fb3
Use var.
Tener Apr 5, 2022
31ed975
Linter.
Tener Apr 5, 2022
3251f47
Add missing license.
Tener Apr 5, 2022
9fff9d6
Replace GetValue with GetValueTyped.
Tener Apr 6, 2022
19c4c32
SSOInfoType: space out constants per type.
Tener Apr 7, 2022
9eb4ffa
Share SSO DiagInfo logic.
Tener Apr 7, 2022
2ed6ad4
Fix error redirect for web login
Tener Apr 7, 2022
3c67fe4
Apply suggestions from code review
Tener Apr 12, 2022
5ed7d79
Merge branch 'master' into tener/tctl-sso
Tener Apr 12, 2022
149e694
Comments for exported methods.
Tener Apr 12, 2022
f0503db
Make Redirector customizable with RedirectorConfig
Tener Apr 12, 2022
f186eae
Better error message.
Tener Apr 12, 2022
f30218c
Better name for function.
Tener Apr 12, 2022
e478da1
Applying feedback from code review.
Tener Apr 12, 2022
f680243
Rename helper function.
Tener Apr 12, 2022
4412351
Merge branch 'master' into tener/tctl-sso
Tener Apr 13, 2022
706203f
Use strongly typed proto messages.
Tener Apr 21, 2022
171cd7d
Switch to structured SSO diag info, store it as single object, submit…
Tener Apr 21, 2022
f1b1eaa
Merge branch 'master' into tener/tctl-sso
Tener Apr 21, 2022
d262d2f
Fix import.
Tener Apr 21, 2022
8d1b03f
API: `go mod tidy`
Tener Apr 21, 2022
1cf2567
Format imports.
Tener Apr 21, 2022
3af2706
Merge branch 'master' into tener/tctl-sso
Tener Apr 21, 2022
543c9e0
Apply suggestions from code review
Tener Apr 22, 2022
8750663
Small refinements.
Tener Apr 22, 2022
49587f3
Add check against empty ConnectorID.
Tener Apr 25, 2022
a98fbf0
Add several tests.
Tener Apr 25, 2022
667aeec
Imports.
Tener Apr 25, 2022
4483221
Merge branch 'master' into tener/tctl-sso
Tener Apr 25, 2022
ce09f34
Lint.
Tener Apr 25, 2022
8c94199
License.
Tener Apr 25, 2022
bc7446c
Additional tests.
Tener Apr 26, 2022
6a4e849
Expand test coverage in lib/services for SAML.
Tener Apr 26, 2022
f6a465a
Merge branch 'master' into tener/tctl-sso
Tener Apr 26, 2022
7e00976
Check all returned values in test.
Tener Apr 26, 2022
2df26a6
Merge branch 'master' into tener/tctl-sso
Tener May 4, 2022
8b311cf
Cleanup go.mod post merge.
Tener May 4, 2022
0a6c00e
Merge branch 'master' into tener/tctl-sso
Tener May 4, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions api/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ require (
github.com/golang/protobuf v1.4.3
github.com/google/go-cmp v0.5.4
github.com/gravitational/trace v1.1.17
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/russellhaering/gosaml2 v0.6.1-0.20210916051624-757d23f1bc28
github.com/sirupsen/logrus v1.8.1
github.com/stretchr/testify v1.7.0
golang.org/x/crypto v0.0.0-20220126234351-aa10faf2a1f8
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd
google.golang.org/grpc v1.43.0
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
gopkg.in/yaml.v2 v2.4.0
)
32 changes: 26 additions & 6 deletions api/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/beevik/etree v1.1.0 h1:T0xke/WvNtMoCqgzPhkX2r4rjY3GDZFi+FjpRZY2Jbs=
github.com/beevik/etree v1.1.0/go.mod h1:r8Aw8JqVegEf0w2fDnATrX9VpkMcyFeM0FhwO62wh+A=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
Expand All @@ -11,6 +13,7 @@ github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XP
github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down Expand Up @@ -52,20 +55,34 @@ github.com/jonboulle/clockwork v0.2.2 h1:UOGuzwb1PwsrDAObMuhUnj0p5ULPj8V/xJ7Kx9q
github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/mattermost/xml-roundtrip-validator v0.1.0 h1:RXbVD2UAl7A7nOTR4u7E3ILa4IbtvKBHw64LDsmu9hU=
github.com/mattermost/xml-roundtrip-validator v0.1.0/go.mod h1:qccnGMcpgwcNaBnxqpJpWWUiPNr5H3O8eDgGV9gT5To=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
github.com/russellhaering/gosaml2 v0.6.1-0.20210916051624-757d23f1bc28 h1:659ZmS9riGgajUnT9ym74yQSug2KZyvVHi3EmIqASnQ=
github.com/russellhaering/gosaml2 v0.6.1-0.20210916051624-757d23f1bc28/go.mod h1:PiLt5KX4EMjlMIq3WLRR/xb5yqhiwtQhGr8wmU0b08M=
github.com/russellhaering/goxmldsig v1.1.1 h1:vI0r2osGF1A9PLvsGdPUAGwEIrKa4Pj5sesSBsebIxM=
github.com/russellhaering/goxmldsig v1.1.1/go.mod h1:gM4MDENBQf7M+V824SGfyIUVFWydB7n0KkEubVJl+Tw=
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down Expand Up @@ -162,13 +179,16 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD
google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c=
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
56 changes: 56 additions & 0 deletions api/types/assertion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
Copyright 2022 Gravitational, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package types

import (
"encoding/json"

"github.com/gravitational/trace"

saml2 "github.com/russellhaering/gosaml2"
)

// AssertionInfo is an alias for saml2.AssertionInfo with additional methods, required for serialization to/from protobuf.
// With those we can reference it with an option like so: `(gogoproto.customtype) = "AssertionInfo"`
type AssertionInfo saml2.AssertionInfo

func (a *AssertionInfo) Size() int {
bytes, err := json.Marshal(a)
if err != nil {
return 0
}
return len(bytes)
}

func (a *AssertionInfo) Unmarshal(bytes []byte) error {
return trace.Wrap(json.Unmarshal(bytes, a))
}

func (a *AssertionInfo) MarshalTo(bytes []byte) (int, error) {
out, err := json.Marshal(a)
if err != nil {
return 0, trace.Wrap(err)
}

if len(out) > cap(bytes) {
return 0, trace.BadParameter("capacity too low: %v, need %v", cap(bytes), len(out))
}

copy(bytes, out)

return len(out), nil
}
81 changes: 81 additions & 0 deletions api/types/assertion_info_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
Copyright 2022 Gravitational, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package types

import (
"encoding/xml"
"testing"
"time"

saml2 "github.com/russellhaering/gosaml2"
samltypes "github.com/russellhaering/gosaml2/types"
"github.com/stretchr/testify/require"
)

func TestAssertionInfo_RoundTrip(t *testing.T) {
tests := []struct {
name string
src AssertionInfo
}{
{name: "empty", src: AssertionInfo{}},
{name: "full", src: (AssertionInfo)(saml2.AssertionInfo{
NameID: "zz",
Values: map[string]samltypes.Attribute{
"foo": {
XMLName: xml.Name{
Space: "ddd",
Local: "aaa",
},
FriendlyName: "aaa",
Name: "aaa",
NameFormat: "",
Values: nil,
},
},
WarningInfo: &saml2.WarningInfo{
OneTimeUse: true,
ProxyRestriction: &saml2.ProxyRestriction{
Count: 1,
Audience: []string{"foo"},
},
NotInAudience: true,
InvalidTime: true,
},
SessionIndex: "aaa",
AuthnInstant: new(time.Time),
SessionNotOnOrAfter: new(time.Time),
Assertions: []samltypes.Assertion{
{XMLName: xml.Name{Space: "urn:oasis:names:tc:SAML:2.0:assertion", Local: "AttributeValue"}},
},
ResponseSignatureValidated: true,
})},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
buf := make([]byte, tt.src.Size())
count, err := tt.src.MarshalTo(buf)
require.NoError(t, err)
require.Equal(t, tt.src.Size(), count)

dst := &AssertionInfo{}
err = dst.Unmarshal(buf)
require.NoError(t, err)
require.Equal(t, &tt.src, dst)
})
}
}
11 changes: 0 additions & 11 deletions api/types/traits.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,5 @@ limitations under the License.

package types

// TraitMapping is a mapping that maps a trait to one or
// more teleport roles.
type TraitMapping struct {
// Trait is a teleport trait name
Trait string `json:"trait"`
// Value is trait value to match
Value string `json:"value"`
// Roles is a list of static teleport roles to map to
Roles []string `json:"roles,omitempty"`
}

// TraitMappingSet is a set of trait mappings
type TraitMappingSet []TraitMapping
Loading