diff --git a/driver/registery_default_saml.go b/driver/registery_default_saml.go new file mode 100644 index 000000000000..c201047fc21d --- /dev/null +++ b/driver/registery_default_saml.go @@ -0,0 +1,11 @@ +package driver + +import "github.com/ory/kratos/selfservice/flow/saml" + +func (m *RegistryDefault) SAMLHandler() *saml.Handler { + if m.selfserviceSAMLHandler == nil { + m.selfserviceSAMLHandler = saml.NewHandler(m) + } + + return m.selfserviceSAMLHandler +} diff --git a/driver/registry_default.go b/driver/registry_default.go index acf0580d5a28..8e7ad24c5d73 100644 --- a/driver/registry_default.go +++ b/driver/registry_default.go @@ -35,11 +35,13 @@ import ( "github.com/ory/kratos/hash" "github.com/ory/kratos/schema" "github.com/ory/kratos/selfservice/flow/recovery" + "github.com/ory/kratos/selfservice/flow/saml" "github.com/ory/kratos/selfservice/flow/settings" "github.com/ory/kratos/selfservice/flow/verification" "github.com/ory/kratos/selfservice/hook" "github.com/ory/kratos/selfservice/strategy/link" "github.com/ory/kratos/selfservice/strategy/profile" + samlstrategy "github.com/ory/kratos/selfservice/strategy/saml/strategy" "github.com/ory/kratos/x" "github.com/cenkalti/backoff" @@ -118,6 +120,8 @@ type RegistryDefault struct { selfserviceLoginHandler *login.Handler selfserviceLoginRequestErrorHandler *login.ErrorHandler + selfserviceSAMLHandler *saml.Handler + selfserviceSettingsHandler *settings.Handler selfserviceSettingsErrorHandler *settings.ErrorHandler selfserviceSettingsExecutor *settings.HookExecutor @@ -150,6 +154,7 @@ func (m *RegistryDefault) Audit() *logrusx.Logger { func (m *RegistryDefault) RegisterPublicRoutes(ctx context.Context, router *x.RouterPublic) { m.LoginHandler().RegisterPublicRoutes(router) + m.SAMLHandler().RegisterPublicRoutes(router) m.RegistrationHandler().RegisterPublicRoutes(router) m.LogoutHandler().RegisterPublicRoutes(router) m.SettingsHandler().RegisterPublicRoutes(router) @@ -274,6 +279,7 @@ func (m *RegistryDefault) selfServiceStrategies() []interface{} { m.selfserviceStrategies = []interface{}{ password2.NewStrategy(m), oidc.NewStrategy(m), + samlstrategy.NewStrategy(m), profile.NewStrategy(m), link.NewStrategy(m), totp.NewStrategy(m), diff --git a/driver/registry_default_test.go b/driver/registry_default_test.go index 54524c8b6b71..a8821188e130 100644 --- a/driver/registry_default_test.go +++ b/driver/registry_default_test.go @@ -686,7 +686,7 @@ func TestDefaultRegistry_AllStrategies(t *testing.T) { _, reg := internal.NewFastRegistryWithMocks(t) t.Run("case=all login strategies", func(t *testing.T) { - expects := []string{"password", "oidc", "totp", "webauthn", "lookup_secret"} + expects := []string{"password", "oidc", "saml", "totp", "webauthn", "lookup_secret"} s := reg.AllLoginStrategies() require.Len(t, s, len(expects)) for k, e := range expects { @@ -695,7 +695,7 @@ func TestDefaultRegistry_AllStrategies(t *testing.T) { }) t.Run("case=all registration strategies", func(t *testing.T) { - expects := []string{"password", "oidc", "webauthn"} + expects := []string{"password", "oidc", "saml", "webauthn"} s := reg.AllRegistrationStrategies() require.Len(t, s, len(expects)) for k, e := range expects { diff --git a/embedx/config.schema.json b/embedx/config.schema.json index ec7751da6328..3d688f5bd267 100644 --- a/embedx/config.schema.json +++ b/embedx/config.schema.json @@ -312,6 +312,225 @@ } } }, + "selfServiceSAMLProvider": { + "type": "object", + "properties": { + "id": { + "title":"ID of the IdentityProvider", + "type": "string", + "examples": [ + "activedirectory1" + ] + }, + "label": { + "title": "Optional string which will be used when generating labels for UI buttons.", + "type": "string", + "examples": [ + "Microsoft Active Directory" + ] + }, + "public_cert_path": { + "title": "Public Certificate Path", + "description": "The Public Certificate for your SAML Messages", + "type": "string", + "format": "uri", + "examples": [ + "file://path/to/cert", + "https://foo.bar.com/path/to/cert" + ] + }, + "private_key_path": { + "title": "Private Key Path", + "description": "The Private Key for your SAML Messages", + "type": "string", + "format": "uri", + "examples": [ + "file://path/to/key", + "https://foo.bar.com/path/to/key" + ] + }, + "mapper_url": { + "title": "Jsonnet Mapper URL", + "description": "Location for the jsonnet mapping between provider's data and Ory Kratos data", + "type": "string", + "format": "uri", + "examples": [ + "file://path/to/oidc.jsonnet", + "https://foo.bar.com/path/to/oidc.jsonnet", + "base64://bG9jYWwgc3ViamVjdCA9I..." + ] + }, + "idp_information": { + "type": "object", + "properties": { + "idp_metadata_url": { + "title": "IDP Metadata URL", + "description": "The URL of the metadata of the IDP", + "type": "string", + "examples": [ + "https://path/to/metadata" + ] + }, + "idp_certificate_path": { + "title": "IDP Certificate Path", + "description": "The path to the certificate of the IDP", + "type": "string", + "examples": [ + "file://path/to/certificate", + "https://foo.bar.com/path/to/certificate" + ] + }, + "idp_logout_url": { + "title": "IDP Logout URL", + "description": "The URL of the SLO API of the IDP", + "type": "string", + "examples": [ + "https://path/to/logout" + ] + }, + "idp_sso_url": { + "title": "IDP SSO URL", + "description": "The URL of the SSO Handler at the IDP", + "type": "string", + "examples": [ + "https://path/to/sso" + ] + }, + "idp_entity_id": { + "title": "The EntityID of the IDP", + "description": "It is a unique identifier representing the IDP in saml requests", + "type": "string", + "examples": [ + "https://samltest.id/saml/idp" + ] + } + }, + "allOf": [ + { + "if": { + "properties": { + "idp_metadata_url": { + "const": {} + } + } + }, + "then": { + "required": [ + "idp_logout_url", + "idp_certificate_path", + "idp_entity_id" + ] + }, + "else":{ + "properties": { + "idp_certificate_path": { + "const": {} + }, + "idp_logout_url": { + "const": {} + }, + "idp_entity_id":{ + "const":{} + }, + "idp_sso_url":{ + "const":{} + } + } + } + } + ] + }, + "attributes_map": { + "type": "object", + "properties": { + "id": { + "title": "ID", + "description": "Name of the IDP attribute representing user ID on Kratos", + "type": "string", + "examples": [ + "file://path/to/oidc.jsonnet", + "https://foo.bar.com/path/to/oidc.jsonnet", + "base64://bG9jYWwgc3ViamVjdCA9I..." + ] + }, + "firstname": { + "title": "Firstname", + "description": "Name of the IDP attribute representing user firstname on Kratos", + "type": "string", + "examples": [ + "John" + ] + }, + "lastname": { + "title": "Lastname", + "description": "Name of the IDP attribute representing user lastname on Kratos", + "type": "string", + "examples": [ + "Doe" + ] + }, + "nickname": { + "title": "Nickname", + "description": "Name of the IDP attribute representing user username on Kratos", + "type": "string", + "examples": [ + "JohnDoe1337" + ] + }, + "gender": { + "title": "Gender", + "description": "Name of the IDP attribute representing user's gender on Kratos", + "type": "string", + "examples": [ + "Male", + "Female", + "Non-binary" + ] + }, + "birthdate": { + "title": "Birthdate", + "description": "Name of the IDP attribute representing user birthdate on Kratos", + "type": "string", + "examples": [ + "08/23/1978" + ] + }, + "picture": { + "title": "Picture", + "description": "Name of the IDP attribute representing user picture on Kratos", + "type": "string", + "examples": [ + "https://imagepicture.jpg" + ] + }, + "email": { + "title": "Email", + "description": "Name of the IDP attribute representing user email on Kratos", + "type": "string", + "examples": [ + "john.doe@gmail.com" + ] + }, + "phone_number": { + "title": "Phone Number", + "description": "Name of the IDP attribute representing user phone number on Kratos", + "type": "string", + "examples": [ + "+33678984320" + ] + } + } + } + }, + "additionalProperties": false, + "required": [ + "id", + "label", + "public_cert_path", + "private_key_path", + "mapper_url" + ] + }, "selfServiceOIDCProvider": { "type": "object", "properties": { @@ -770,6 +989,9 @@ "oidc": { "$ref": "#/definitions/selfServiceAfterRegistrationMethod" }, + "saml": { + "$ref": "#/definitions/selfServiceAfterRegistrationMethod" + }, "hooks": { "$ref": "#/definitions/selfServiceHooks" } @@ -1394,6 +1616,35 @@ ] } }, + "saml": { + "type": "object", + "title": "Specify SAML configuration", + "showEnvVarBlockForObject": true, + "additionalProperties": false, + "properties": { + "enabled": { + "type": "boolean", + "title": "Enables SAML Authentication Method", + "default": false + }, + "config": { + "type": "object", + "additionalProperties": false, + "properties": { + "providers": { + "title": "SAML Provider", + "description": "All information required to implement a SAML authentication", + "type": "array", + "items": { + "$ref": "#/definitions/selfServiceSAMLProvider" + } + } + } + + + } + } + }, "oidc": { "type": "object", "title": "Specify OpenID Connect and OAuth2 Configuration", diff --git a/go.mod b/go.mod index aaee750ce886..51d254d0510b 100644 --- a/go.mod +++ b/go.mod @@ -24,12 +24,14 @@ require ( github.com/Masterminds/sprig/v3 v3.0.0 github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0 github.com/avast/retry-go/v3 v3.1.1 + github.com/beevik/etree v1.1.0 github.com/bradleyjkemp/cupaloy/v2 v2.6.0 github.com/bwmarrin/discordgo v0.23.0 github.com/bxcodec/faker/v3 v3.3.1 github.com/cenkalti/backoff v2.2.1+incompatible github.com/coreos/go-oidc v2.2.1+incompatible github.com/cortesi/modd v0.0.0-20210323234521-b35eddab86cc + github.com/crewjam/saml v0.4.6 github.com/davecgh/go-spew v1.1.1 github.com/davidrjonas/semver-cli v0.0.0-20190116233701-ee19a9a0dda6 github.com/dgraph-io/ristretto v0.1.0 @@ -96,6 +98,7 @@ require ( golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 golang.org/x/sync v0.0.0-20210220032951-036812b2e83c golang.org/x/tools v0.1.8-0.20211029000441-d6a9af8af023 + gotest.tools v2.2.0+incompatible ) require ( @@ -133,6 +136,8 @@ require ( github.com/cortesi/moddwatch v0.0.0-20210222043437-a6aaad86a36e // indirect github.com/cortesi/termlog v0.0.0-20210222042314-a1eec763abec // indirect github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect + github.com/crewjam/httperr v0.2.0 // indirect + github.com/dgraph-io/ristretto v0.1.0 // indirect github.com/docker/cli v20.10.11+incompatible // indirect github.com/docker/distribution v2.8.1+incompatible // indirect github.com/docker/docker v20.10.9+incompatible // indirect @@ -182,6 +187,7 @@ require ( github.com/golang/protobuf v1.5.2 // indirect github.com/google/btree v1.0.1 // indirect github.com/google/certificate-transparency-go v1.1.2-0.20210511102531-373a877eec92 // indirect + github.com/google/go-cmp v0.5.6 // indirect github.com/google/go-querystring v1.0.0 // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect github.com/gorilla/css v1.0.0 // indirect @@ -226,6 +232,7 @@ require ( github.com/magiconair/properties v1.8.5 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/markbates/hmax v1.0.0 // indirect + github.com/mattermost/xml-roundtrip-validator v0.1.0 // indirect github.com/mattn/go-colorable v0.1.12 // indirect github.com/mattn/go-isatty v0.0.14 // indirect github.com/mattn/go-runewidth v0.0.12 // indirect @@ -259,6 +266,7 @@ require ( github.com/rivo/uniseg v0.2.0 // indirect github.com/rjeczalik/notify v0.0.0-20181126183243-629144ba06a1 // indirect github.com/rogpeppe/go-internal v1.8.0 // indirect + github.com/russellhaering/goxmldsig v1.1.1 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/seatgeek/logrus-gelf-formatter v0.0.0-20210414080842-5b05eb8ff761 // indirect github.com/segmentio/backo-go v0.0.0-20200129164019-23eae7c10bd3 // indirect diff --git a/go.sum b/go.sum index 3d04d7cd7776..5a1fd7ef3059 100644 --- a/go.sum +++ b/go.sum @@ -213,6 +213,8 @@ github.com/aws/smithy-go v1.8.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAm github.com/aybabtme/rgbterm v0.0.0-20170906152045-cc83f3b3ce59/go.mod h1:q/89r3U2H7sSsE2t6Kca0lfwTK8JdoNGS/yzM/4iH5I= github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk= github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= +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/beorn7/perks v0.0.0-20160804104726-4c0e84591b9a/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= @@ -428,6 +430,10 @@ github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7Do github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.11 h1:07n33Z8lZxZ2qwegKbObQohDhXDQxiMMz1NOUGYlesw= github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/crewjam/httperr v0.2.0 h1:b2BfXR8U3AlIHwNeFFvZ+BV1LFvKLlzMjzaTnZMybNo= +github.com/crewjam/httperr v0.2.0/go.mod h1:Jlz+Sg/XqBQhyMjdDiC+GNNRzZTD7x39Gu3pglZ5oH4= +github.com/crewjam/saml v0.4.6 h1:XCUFPkQSJLvzyl4cW9OvpWUbRf0gE7VUpU8ZnilbeM4= +github.com/crewjam/saml v0.4.6/go.mod h1:ZBOXnNPFzB3CgOkRm7Nd6IVdkG+l/wF+0ZXLqD96t1A= github.com/cyphar/filepath-securejoin v0.2.2/go.mod h1:FpkQEhXnPnOthhzymB7CGsFk2G9VLXONKD9G7QGMM+4= github.com/d2g/dhcp4 v0.0.0-20170904100407-a1d1b6c41b1c/go.mod h1:Ct2BUK8SB0YC1SMSibvLzxjeJLnrYEVLULFNiHY9YfQ= github.com/d2g/dhcp4client v1.0.0/go.mod h1:j0hNfjhrt2SxUOw55nL0ATM/z4Yt3t2Kd1mW34z5W5s= @@ -441,6 +447,7 @@ 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= github.com/davidrjonas/semver-cli v0.0.0-20190116233701-ee19a9a0dda6 h1:VzPvKOw28XJ77PYwOq5gAqvFB4gk6gst0HxxiW8kfZQ= github.com/davidrjonas/semver-cli v0.0.0-20190116233701-ee19a9a0dda6/go.mod h1:+6FzxsSbK4oEuvdN06Jco8zKB2mQqIB6UduZdd0Zesk= +github.com/dchest/uniuri v0.0.0-20200228104902-7aecb25e1fe5/go.mod h1:GgB8SF9nRG+GqaDtLcwJZsQFhcogVCJ79j4EdT0c2V4= github.com/denverdino/aliyungo v0.0.0-20190125010748-a747050bb1ba/go.mod h1:dV8lFg6daOBZbT6/BDGIz6Y3WFGn8juu6G+CQ6LHtl0= github.com/devigned/tab v0.1.1/go.mod h1:XG9mPq0dFghrYvoBF3xdRrJzSTX1b7IQrvaL9mzjeJY= github.com/dgraph-io/ristretto v0.0.1/go.mod h1:T40EBc7CJke8TkpiYfGGKAeFjSaxuFXhuXRyumBd6RE= @@ -1211,6 +1218,8 @@ github.com/markbates/oncer v1.0.0/go.mod h1:Z59JA581E9GP6w96jai+TGqafHPW+cPfRxz2 github.com/markbates/pkger v0.17.1 h1:/MKEtWqtc0mZvu9OinB9UzVN9iYCwLWuyUv4Bw+PCno= github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0= github.com/marstr/guid v1.1.0/go.mod h1:74gB1z2wpxxInTG6yaqA7KrtM0NZ+RbrcqDvYHefzho= +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/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= @@ -1541,6 +1550,8 @@ github.com/rs/cors v1.8.0/go.mod h1:EBwu+T5AvHOcXwvZIkQFjUN6s8Czyqw12GL/Y0tUyRM= github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU= github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc= +github.com/russellhaering/goxmldsig v1.1.1 h1:vI0r2osGF1A9PLvsGdPUAGwEIrKa4Pj5sesSBsebIxM= +github.com/russellhaering/goxmldsig v1.1.1/go.mod h1:gM4MDENBQf7M+V824SGfyIUVFWydB7n0KkEubVJl+Tw= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= @@ -1755,6 +1766,7 @@ github.com/yvasiyarov/go-metrics v0.0.0-20140926110328-57bccd1ccd43/go.mod h1:aX github.com/yvasiyarov/gorelic v0.0.0-20141212073537-a9bba5b9ab50/go.mod h1:NUSPSUX/bi6SeDMUh6brw0nXpxHnc96TguQh0+r/ssA= github.com/yvasiyarov/newrelic_platform_go v0.0.0-20140908184405-b21fdbd4370f/go.mod h1:GlGEuHIJweS1mbCqG+7vt2nvWLzLLnRHbXz5JKd/Qbg= github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q= +github.com/zenazn/goji v1.0.1/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q= github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0= github.com/zmap/rc2 v0.0.0-20131011165748-24b9757f5521/go.mod h1:3YZ9o3WnatTIZhuOtot4IcUfzoKVjUHqu6WALIyI0nE= github.com/zmap/zcertificate v0.0.0-20180516150559-0e3d58b1bac4/go.mod h1:5iU54tB79AMBcySS0R2XIyZBAVmeHranShAFELYx7is= diff --git a/identity/credentials.go b/identity/credentials.go index 466bb5c61c6d..46b4d10529bb 100644 --- a/identity/credentials.go +++ b/identity/credentials.go @@ -49,6 +49,7 @@ const ( CredentialsTypeTOTP CredentialsType = "totp" CredentialsTypeLookup CredentialsType = "lookup_secret" CredentialsTypeWebAuthn CredentialsType = "webauthn" + CredentialsTypeSAML CredentialsType = "saml" ) const ( diff --git a/identity/credentials_saml.go b/identity/credentials_saml.go new file mode 100644 index 000000000000..0613fcbd8a50 --- /dev/null +++ b/identity/credentials_saml.go @@ -0,0 +1,51 @@ +package identity + +import ( + "bytes" + "encoding/json" + "fmt" + + "github.com/pkg/errors" + + "github.com/ory/kratos/x" +) + +// CredentialsSAML is contains the configuration for credentials of the type saml. +// +// swagger:model identityCredentialsSaml +type CredentialsSAML struct { + Providers []CredentialsSAMLProvider `json:"providers"` +} + +// CredentialsSAMLProvider is contains a specific saml credential +// +// swagger:model identityCredentialsSamlProvider +type CredentialsSAMLProvider struct { + Subject string `json:"subject"` + Provider string `json:"provider"` +} + +// NewCredentialsSAML creates a new SAML credential. +func NewCredentialsSAML(idToken, accessToken, refreshToken, provider, subject string) (*Credentials, error) { + var b bytes.Buffer + if err := json.NewEncoder(&b).Encode(CredentialsSAML{ + Providers: []CredentialsSAMLProvider{ + { + Subject: subject, + Provider: provider, + }}, + }); err != nil { + return nil, errors.WithStack(x.PseudoPanic. + WithDebugf("Unable to encode password options to JSON: %s", err)) + } + + return &Credentials{ + Type: CredentialsTypeSAML, + Identifiers: []string{SAMLUniqueID(provider, subject)}, + Config: b.Bytes(), + }, nil +} + +func SAMLUniqueID(provider, subject string) string { + return fmt.Sprintf("%s:%s", provider, subject) +} diff --git a/internal/httpclient/.openapi-generator/FILES b/internal/httpclient/.openapi-generator/FILES index 24b1600e0f74..564340d28183 100644 --- a/internal/httpclient/.openapi-generator/FILES +++ b/internal/httpclient/.openapi-generator/FILES @@ -47,6 +47,7 @@ docs/SelfServiceRecoveryFlow.md docs/SelfServiceRecoveryFlowState.md docs/SelfServiceRecoveryLink.md docs/SelfServiceRegistrationFlow.md +docs/SelfServiceSamlUrl.md docs/SelfServiceSettingsFlow.md docs/SelfServiceSettingsFlowState.md docs/SelfServiceVerificationFlow.md @@ -135,6 +136,7 @@ model_self_service_recovery_flow.go model_self_service_recovery_flow_state.go model_self_service_recovery_link.go model_self_service_registration_flow.go +model_self_service_saml_url.go model_self_service_settings_flow.go model_self_service_settings_flow_state.go model_self_service_verification_flow.go diff --git a/internal/httpclient/README.md b/internal/httpclient/README.md index d7811eb31702..2bbeafd6a11c 100644 --- a/internal/httpclient/README.md +++ b/internal/httpclient/README.md @@ -110,6 +110,7 @@ Class | Method | HTTP request | Description *V0alpha2Api* | [**InitializeSelfServiceRecoveryFlowWithoutBrowser**](docs/V0alpha2Api.md#initializeselfservicerecoveryflowwithoutbrowser) | **Get** /self-service/recovery/api | Initialize Recovery Flow for APIs, Services, Apps, ... *V0alpha2Api* | [**InitializeSelfServiceRegistrationFlowForBrowsers**](docs/V0alpha2Api.md#initializeselfserviceregistrationflowforbrowsers) | **Get** /self-service/registration/browser | Initialize Registration Flow for Browsers *V0alpha2Api* | [**InitializeSelfServiceRegistrationFlowWithoutBrowser**](docs/V0alpha2Api.md#initializeselfserviceregistrationflowwithoutbrowser) | **Get** /self-service/registration/api | Initialize Registration Flow for APIs, Services, Apps, ... +*V0alpha2Api* | [**InitializeSelfServiceSamlFlowForBrowsers**](docs/V0alpha2Api.md#initializeselfservicesamlflowforbrowsers) | **Get** /self-service/methods/saml/auth | Initialize Registration Flow for APIs, Services, Apps, ... *V0alpha2Api* | [**InitializeSelfServiceSettingsFlowForBrowsers**](docs/V0alpha2Api.md#initializeselfservicesettingsflowforbrowsers) | **Get** /self-service/settings/browser | Initialize Settings Flow for Browsers *V0alpha2Api* | [**InitializeSelfServiceSettingsFlowWithoutBrowser**](docs/V0alpha2Api.md#initializeselfservicesettingsflowwithoutbrowser) | **Get** /self-service/settings/api | Initialize Settings Flow for APIs, Services, Apps, ... *V0alpha2Api* | [**InitializeSelfServiceVerificationFlowForBrowsers**](docs/V0alpha2Api.md#initializeselfserviceverificationflowforbrowsers) | **Get** /self-service/verification/browser | Initialize Verification Flow for Browser Clients @@ -169,6 +170,7 @@ Class | Method | HTTP request | Description - [SelfServiceRecoveryFlowState](docs/SelfServiceRecoveryFlowState.md) - [SelfServiceRecoveryLink](docs/SelfServiceRecoveryLink.md) - [SelfServiceRegistrationFlow](docs/SelfServiceRegistrationFlow.md) + - [SelfServiceSamlUrl](docs/SelfServiceSamlUrl.md) - [SelfServiceSettingsFlow](docs/SelfServiceSettingsFlow.md) - [SelfServiceSettingsFlowState](docs/SelfServiceSettingsFlowState.md) - [SelfServiceVerificationFlow](docs/SelfServiceVerificationFlow.md) diff --git a/internal/httpclient/api/openapi.yaml b/internal/httpclient/api/openapi.yaml index 68ae6e705d7b..61e14bcd0340 100644 --- a/internal/httpclient/api/openapi.yaml +++ b/internal/httpclient/api/openapi.yaml @@ -1179,6 +1179,51 @@ paths: summary: Create a Logout URL for Browsers tags: - v0alpha2 + /self-service/methods/saml/auth: + get: + description: |- + This endpoint initiates a registration flow for API clients such as mobile devices, smart TVs, and so on. + + If a valid provided session cookie or session token is provided, a 400 Bad Request error + will be returned unless the URL query parameter `?refresh=true` is set. + + To fetch an existing registration flow call `/self-service/registration/flows?flow=`. + + You MUST NOT use this endpoint in client-side (Single Page Apps, ReactJS, AngularJS) nor server-side (Java Server + Pages, NodeJS, PHP, Golang, ...) browser applications. Using this endpoint in these applications will make + you vulnerable to a variety of CSRF attacks. + + In the case of an error, the `error.id` of the JSON response body can be one of: + + `session_already_available`: The user is already signed in. + `security_csrf_violation`: Unable to fetch the flow because a CSRF violation occurred. + + This endpoint MUST ONLY be used in scenarios such as native mobile apps (React Native, Objective C, Swift, Java, ...). + + More information can be found at [Ory Kratos User Login and User Registration Documentation](https://www.ory.sh/docs/next/kratos/self-service/flows/user-login-user-registration). + operationId: initializeSelfServiceSamlFlowForBrowsers + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/selfServiceRegistrationFlow' + description: selfServiceRegistrationFlow + "400": + content: + application/json: + schema: + $ref: '#/components/schemas/jsonError' + description: jsonError + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/jsonError' + description: jsonError + summary: Initialize Registration Flow for APIs, Services, Apps, ... + tags: + - v0alpha2 /self-service/recovery: post: description: |- @@ -3822,6 +3867,24 @@ components: - type - ui type: object + selfServiceSamlUrl: + properties: + saml_acs_url: + description: |- + SamlAcsURL is a post endpoint to handle SAML Response + + format: uri + type: string + saml_metadata_url: + description: |- + SamlMetadataURL is a get endpoint to get the metadata + + format: uri + type: string + required: + - saml_acs_url + - saml_metadata_url + type: object selfServiceSettingsFlow: description: |- This flow is used when an identity wants to update settings diff --git a/internal/httpclient/docs/SelfServiceSamlUrl.md b/internal/httpclient/docs/SelfServiceSamlUrl.md new file mode 100644 index 000000000000..c7f22694c63c --- /dev/null +++ b/internal/httpclient/docs/SelfServiceSamlUrl.md @@ -0,0 +1,72 @@ +# SelfServiceSamlUrl + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**SamlAcsUrl** | **string** | SamlAcsURL is a post endpoint to handle SAML Response format: uri | +**SamlMetadataUrl** | **string** | SamlMetadataURL is a get endpoint to get the metadata format: uri | + +## Methods + +### NewSelfServiceSamlUrl + +`func NewSelfServiceSamlUrl(samlAcsUrl string, samlMetadataUrl string, ) *SelfServiceSamlUrl` + +NewSelfServiceSamlUrl instantiates a new SelfServiceSamlUrl object +This constructor will assign default values to properties that have it defined, +and makes sure properties required by API are set, but the set of arguments +will change when the set of required properties is changed + +### NewSelfServiceSamlUrlWithDefaults + +`func NewSelfServiceSamlUrlWithDefaults() *SelfServiceSamlUrl` + +NewSelfServiceSamlUrlWithDefaults instantiates a new SelfServiceSamlUrl object +This constructor will only assign default values to properties that have it defined, +but it doesn't guarantee that properties required by API are set + +### GetSamlAcsUrl + +`func (o *SelfServiceSamlUrl) GetSamlAcsUrl() string` + +GetSamlAcsUrl returns the SamlAcsUrl field if non-nil, zero value otherwise. + +### GetSamlAcsUrlOk + +`func (o *SelfServiceSamlUrl) GetSamlAcsUrlOk() (*string, bool)` + +GetSamlAcsUrlOk returns a tuple with the SamlAcsUrl field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetSamlAcsUrl + +`func (o *SelfServiceSamlUrl) SetSamlAcsUrl(v string)` + +SetSamlAcsUrl sets SamlAcsUrl field to given value. + + +### GetSamlMetadataUrl + +`func (o *SelfServiceSamlUrl) GetSamlMetadataUrl() string` + +GetSamlMetadataUrl returns the SamlMetadataUrl field if non-nil, zero value otherwise. + +### GetSamlMetadataUrlOk + +`func (o *SelfServiceSamlUrl) GetSamlMetadataUrlOk() (*string, bool)` + +GetSamlMetadataUrlOk returns a tuple with the SamlMetadataUrl field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetSamlMetadataUrl + +`func (o *SelfServiceSamlUrl) SetSamlMetadataUrl(v string)` + +SetSamlMetadataUrl sets SamlMetadataUrl field to given value. + + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/internal/httpclient/docs/V0alpha2Api.md b/internal/httpclient/docs/V0alpha2Api.md index cc1ce80bdf1b..ea479d840d5c 100644 --- a/internal/httpclient/docs/V0alpha2Api.md +++ b/internal/httpclient/docs/V0alpha2Api.md @@ -28,6 +28,7 @@ Method | HTTP request | Description [**InitializeSelfServiceRecoveryFlowWithoutBrowser**](V0alpha2Api.md#InitializeSelfServiceRecoveryFlowWithoutBrowser) | **Get** /self-service/recovery/api | Initialize Recovery Flow for APIs, Services, Apps, ... [**InitializeSelfServiceRegistrationFlowForBrowsers**](V0alpha2Api.md#InitializeSelfServiceRegistrationFlowForBrowsers) | **Get** /self-service/registration/browser | Initialize Registration Flow for Browsers [**InitializeSelfServiceRegistrationFlowWithoutBrowser**](V0alpha2Api.md#InitializeSelfServiceRegistrationFlowWithoutBrowser) | **Get** /self-service/registration/api | Initialize Registration Flow for APIs, Services, Apps, ... +[**InitializeSelfServiceSamlFlowForBrowsers**](V0alpha2Api.md#InitializeSelfServiceSamlFlowForBrowsers) | **Get** /self-service/methods/saml/auth | Initialize Registration Flow for APIs, Services, Apps, ... [**InitializeSelfServiceSettingsFlowForBrowsers**](V0alpha2Api.md#InitializeSelfServiceSettingsFlowForBrowsers) | **Get** /self-service/settings/browser | Initialize Settings Flow for Browsers [**InitializeSelfServiceSettingsFlowWithoutBrowser**](V0alpha2Api.md#InitializeSelfServiceSettingsFlowWithoutBrowser) | **Get** /self-service/settings/api | Initialize Settings Flow for APIs, Services, Apps, ... [**InitializeSelfServiceVerificationFlowForBrowsers**](V0alpha2Api.md#InitializeSelfServiceVerificationFlowForBrowsers) | **Get** /self-service/verification/browser | Initialize Verification Flow for Browser Clients @@ -1672,6 +1673,67 @@ No authorization required [[Back to README]](../README.md) +## InitializeSelfServiceSamlFlowForBrowsers + +> SelfServiceRegistrationFlow InitializeSelfServiceSamlFlowForBrowsers(ctx).Execute() + +Initialize Registration Flow for APIs, Services, Apps, ... + + + +### Example + +```go +package main + +import ( + "context" + "fmt" + "os" + openapiclient "./openapi" +) + +func main() { + + configuration := openapiclient.NewConfiguration() + apiClient := openapiclient.NewAPIClient(configuration) + resp, r, err := apiClient.V0alpha2Api.InitializeSelfServiceSamlFlowForBrowsers(context.Background()).Execute() + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `V0alpha2Api.InitializeSelfServiceSamlFlowForBrowsers``: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + // response from `InitializeSelfServiceSamlFlowForBrowsers`: SelfServiceRegistrationFlow + fmt.Fprintf(os.Stdout, "Response from `V0alpha2Api.InitializeSelfServiceSamlFlowForBrowsers`: %v\n", resp) +} +``` + +### Path Parameters + +This endpoint does not need any parameter. + +### Other Parameters + +Other parameters are passed through a pointer to a apiInitializeSelfServiceSamlFlowForBrowsersRequest struct via the builder pattern + + +### Return type + +[**SelfServiceRegistrationFlow**](SelfServiceRegistrationFlow.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) +[[Back to Model list]](../README.md#documentation-for-models) +[[Back to README]](../README.md) + + ## InitializeSelfServiceSettingsFlowForBrowsers > SelfServiceSettingsFlow InitializeSelfServiceSettingsFlowForBrowsers(ctx).ReturnTo(returnTo).Execute() diff --git a/internal/httpclient/model_self_service_saml_url.go b/internal/httpclient/model_self_service_saml_url.go new file mode 100644 index 000000000000..935f53b0aaf6 --- /dev/null +++ b/internal/httpclient/model_self_service_saml_url.go @@ -0,0 +1,134 @@ +/* + * Ory Kratos API + * + * Documentation for all public and administrative Ory Kratos APIs. Public and administrative APIs are exposed on different ports. Public APIs can face the public internet without any protection while administrative APIs should never be exposed without prior authorization. To protect the administative API port you should use something like Nginx, Ory Oathkeeper, or any other technology capable of authorizing incoming requests. + * + * API version: 1.0.0 + * Contact: hi@ory.sh + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package client + +import ( + "encoding/json" +) + +// SelfServiceSamlUrl struct for SelfServiceSamlUrl +type SelfServiceSamlUrl struct { + // SamlAcsURL is a post endpoint to handle SAML Response format: uri + SamlAcsUrl string `json:"saml_acs_url"` + // SamlMetadataURL is a get endpoint to get the metadata format: uri + SamlMetadataUrl string `json:"saml_metadata_url"` +} + +// NewSelfServiceSamlUrl instantiates a new SelfServiceSamlUrl object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewSelfServiceSamlUrl(samlAcsUrl string, samlMetadataUrl string) *SelfServiceSamlUrl { + this := SelfServiceSamlUrl{} + this.SamlAcsUrl = samlAcsUrl + this.SamlMetadataUrl = samlMetadataUrl + return &this +} + +// NewSelfServiceSamlUrlWithDefaults instantiates a new SelfServiceSamlUrl object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewSelfServiceSamlUrlWithDefaults() *SelfServiceSamlUrl { + this := SelfServiceSamlUrl{} + return &this +} + +// GetSamlAcsUrl returns the SamlAcsUrl field value +func (o *SelfServiceSamlUrl) GetSamlAcsUrl() string { + if o == nil { + return "" + } + + return o.SamlAcsUrl +} + +// GetSamlAcsUrlOk returns a tuple with the SamlAcsUrl field value +// and a boolean to check if the value has been set. +func (o *SelfServiceSamlUrl) GetSamlAcsUrlOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.SamlAcsUrl, true +} + +// SetSamlAcsUrl sets field value +func (o *SelfServiceSamlUrl) SetSamlAcsUrl(v string) { + o.SamlAcsUrl = v +} + +// GetSamlMetadataUrl returns the SamlMetadataUrl field value +func (o *SelfServiceSamlUrl) GetSamlMetadataUrl() string { + if o == nil { + return "" + } + + return o.SamlMetadataUrl +} + +// GetSamlMetadataUrlOk returns a tuple with the SamlMetadataUrl field value +// and a boolean to check if the value has been set. +func (o *SelfServiceSamlUrl) GetSamlMetadataUrlOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.SamlMetadataUrl, true +} + +// SetSamlMetadataUrl sets field value +func (o *SelfServiceSamlUrl) SetSamlMetadataUrl(v string) { + o.SamlMetadataUrl = v +} + +func (o SelfServiceSamlUrl) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + + toSerialize["saml_acs_url"] = o.SamlAcsUrl + toSerialize["saml_metadata_url"] = o.SamlMetadataUrl + + return json.Marshal(toSerialize) +} + +type NullableSelfServiceSamlUrl struct { + value *SelfServiceSamlUrl + isSet bool +} + +func (v NullableSelfServiceSamlUrl) Get() *SelfServiceSamlUrl { + return v.value +} + +func (v *NullableSelfServiceSamlUrl) Set(val *SelfServiceSamlUrl) { + v.value = val + v.isSet = true +} + +func (v NullableSelfServiceSamlUrl) IsSet() bool { + return v.isSet +} + +func (v *NullableSelfServiceSamlUrl) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableSelfServiceSamlUrl(val *SelfServiceSamlUrl) *NullableSelfServiceSamlUrl { + return &NullableSelfServiceSamlUrl{value: val, isSet: true} +} + +func (v NullableSelfServiceSamlUrl) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableSelfServiceSamlUrl) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/persistence/sql/migrations/sql/20220415152108000000_credentials_types_saml.cockroach.down.sql b/persistence/sql/migrations/sql/20220415152108000000_credentials_types_saml.cockroach.down.sql new file mode 100644 index 000000000000..fced32072ece --- /dev/null +++ b/persistence/sql/migrations/sql/20220415152108000000_credentials_types_saml.cockroach.down.sql @@ -0,0 +1 @@ +DELETE FROM identity_credential_types WHERE name = 'saml'; \ No newline at end of file diff --git a/persistence/sql/migrations/sql/20220415152108000000_credentials_types_saml.cockroach.up.sql b/persistence/sql/migrations/sql/20220415152108000000_credentials_types_saml.cockroach.up.sql new file mode 100644 index 000000000000..615f55bdc46f --- /dev/null +++ b/persistence/sql/migrations/sql/20220415152108000000_credentials_types_saml.cockroach.up.sql @@ -0,0 +1 @@ +INSERT INTO identity_credential_types (id, name) SELECT 'ff5a1823-8b47-4255-860f-4b70ed122740', 'saml' WHERE NOT EXISTS ( SELECT * FROM identity_credential_types WHERE name = 'saml'); \ No newline at end of file diff --git a/persistence/sql/migrations/sql/20220415152108000000_credentials_types_saml.mysql.down.sql b/persistence/sql/migrations/sql/20220415152108000000_credentials_types_saml.mysql.down.sql new file mode 100644 index 000000000000..fced32072ece --- /dev/null +++ b/persistence/sql/migrations/sql/20220415152108000000_credentials_types_saml.mysql.down.sql @@ -0,0 +1 @@ +DELETE FROM identity_credential_types WHERE name = 'saml'; \ No newline at end of file diff --git a/persistence/sql/migrations/sql/20220415152108000000_credentials_types_saml.mysql.up.sql b/persistence/sql/migrations/sql/20220415152108000000_credentials_types_saml.mysql.up.sql new file mode 100644 index 000000000000..615f55bdc46f --- /dev/null +++ b/persistence/sql/migrations/sql/20220415152108000000_credentials_types_saml.mysql.up.sql @@ -0,0 +1 @@ +INSERT INTO identity_credential_types (id, name) SELECT 'ff5a1823-8b47-4255-860f-4b70ed122740', 'saml' WHERE NOT EXISTS ( SELECT * FROM identity_credential_types WHERE name = 'saml'); \ No newline at end of file diff --git a/persistence/sql/migrations/sql/20220415152108000000_credentials_types_saml.postgres.down.sql b/persistence/sql/migrations/sql/20220415152108000000_credentials_types_saml.postgres.down.sql new file mode 100644 index 000000000000..fced32072ece --- /dev/null +++ b/persistence/sql/migrations/sql/20220415152108000000_credentials_types_saml.postgres.down.sql @@ -0,0 +1 @@ +DELETE FROM identity_credential_types WHERE name = 'saml'; \ No newline at end of file diff --git a/persistence/sql/migrations/sql/20220415152108000000_credentials_types_saml.postgres.up.sql b/persistence/sql/migrations/sql/20220415152108000000_credentials_types_saml.postgres.up.sql new file mode 100644 index 000000000000..615f55bdc46f --- /dev/null +++ b/persistence/sql/migrations/sql/20220415152108000000_credentials_types_saml.postgres.up.sql @@ -0,0 +1 @@ +INSERT INTO identity_credential_types (id, name) SELECT 'ff5a1823-8b47-4255-860f-4b70ed122740', 'saml' WHERE NOT EXISTS ( SELECT * FROM identity_credential_types WHERE name = 'saml'); \ No newline at end of file diff --git a/persistence/sql/migrations/sql/20220415152108000000_credentials_types_saml.sqlite3.down.sql b/persistence/sql/migrations/sql/20220415152108000000_credentials_types_saml.sqlite3.down.sql new file mode 100644 index 000000000000..fced32072ece --- /dev/null +++ b/persistence/sql/migrations/sql/20220415152108000000_credentials_types_saml.sqlite3.down.sql @@ -0,0 +1 @@ +DELETE FROM identity_credential_types WHERE name = 'saml'; \ No newline at end of file diff --git a/persistence/sql/migrations/sql/20220415152108000000_credentials_types_saml.sqlite3.up.sql b/persistence/sql/migrations/sql/20220415152108000000_credentials_types_saml.sqlite3.up.sql new file mode 100644 index 000000000000..615f55bdc46f --- /dev/null +++ b/persistence/sql/migrations/sql/20220415152108000000_credentials_types_saml.sqlite3.up.sql @@ -0,0 +1 @@ +INSERT INTO identity_credential_types (id, name) SELECT 'ff5a1823-8b47-4255-860f-4b70ed122740', 'saml' WHERE NOT EXISTS ( SELECT * FROM identity_credential_types WHERE name = 'saml'); \ No newline at end of file diff --git a/persistence/sql/migrations/templates/20220415152108_credentials_types_saml.down.fizz b/persistence/sql/migrations/templates/20220415152108_credentials_types_saml.down.fizz new file mode 100644 index 000000000000..8b00adca29d7 --- /dev/null +++ b/persistence/sql/migrations/templates/20220415152108_credentials_types_saml.down.fizz @@ -0,0 +1 @@ +sql("DELETE FROM identity_credential_types WHERE name = 'saml'") \ No newline at end of file diff --git a/persistence/sql/migrations/templates/20220415152108_credentials_types_saml.up.fizz b/persistence/sql/migrations/templates/20220415152108_credentials_types_saml.up.fizz new file mode 100644 index 000000000000..8a7f27af90b7 --- /dev/null +++ b/persistence/sql/migrations/templates/20220415152108_credentials_types_saml.up.fizz @@ -0,0 +1 @@ +sql("INSERT INTO identity_credential_types (id, name) SELECT 'ff5a1823-8b47-4255-860f-4b70ed122740', 'saml' WHERE NOT EXISTS ( SELECT * FROM identity_credential_types WHERE name = 'saml')") \ No newline at end of file diff --git a/selfservice/flow/saml/handler.go b/selfservice/flow/saml/handler.go new file mode 100644 index 000000000000..d78fb387466a --- /dev/null +++ b/selfservice/flow/saml/handler.go @@ -0,0 +1,306 @@ +package saml + +import ( + "bytes" + "context" + "crypto/rsa" + "crypto/tls" + "crypto/x509" + "encoding/pem" + "io/ioutil" + "net/http" + "net/url" + "strings" + "time" + + "github.com/pkg/errors" + + "github.com/crewjam/saml/samlsp" + "github.com/julienschmidt/httprouter" + + "github.com/ory/kratos/driver/config" + "github.com/ory/kratos/selfservice/errorx" + + samlidp "github.com/crewjam/saml" + + samlstrategy "github.com/ory/kratos/selfservice/strategy/saml" + + "github.com/ory/kratos/session" + "github.com/ory/kratos/x" + "github.com/ory/x/decoderx" + "github.com/ory/x/jsonx" +) + +const ( + RouteSamlMetadata = "/self-service/methods/saml/metadata" + RouteSamlLoginInit = "/self-service/methods/saml/browser" // Redirect to the IDP + RouteSamlAcs = "/self-service/methods/saml/acs" +) + +var ErrNoSession = errors.New("saml: session not present") +var samlMiddleware *samlsp.Middleware + +type ( + handlerDependencies interface { + x.WriterProvider + x.CSRFProvider + session.ManagementProvider + session.PersistenceProvider + errorx.ManagementProvider + config.Provider + } + HandlerProvider interface { + LogoutHandler() *Handler + } + Handler struct { + d handlerDependencies + dx *decoderx.HTTP + } +) + +type CookieSessionProvider struct { + Name string + Domain string + HTTPOnly bool + Secure bool + SameSite http.SameSite + MaxAge time.Duration + Codec samlsp.SessionCodec +} + +func NewHandler(d handlerDependencies) *Handler { + return &Handler{ + d: d, + dx: decoderx.NewHTTP(), + } +} + +func (h *Handler) RegisterPublicRoutes(router *x.RouterPublic) { + + h.d.CSRFHandler().IgnorePath(RouteSamlLoginInit) + h.d.CSRFHandler().IgnorePath(RouteSamlAcs) + + router.GET(RouteSamlMetadata, h.serveMetadata) + router.GET(RouteSamlLoginInit, h.loginWithIdp) +} + +// Handle /selfservice/methods/saml/metadata +func (h *Handler) serveMetadata(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { + config := h.d.Config(r.Context()) + if samlMiddleware == nil { + if err := h.instantiateMiddleware(*config); err != nil { + h.d.SelfServiceErrorManager().Forward(r.Context(), w, r, err) + } + } + + samlMiddleware.ServeMetadata(w, r) +} + +// Handle /selfservice/methods/saml/browser +func (h *Handler) loginWithIdp(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { + + // Middleware is a singleton so we have to verify that it exist + if samlMiddleware == nil { + config := h.d.Config(r.Context()) + if err := h.instantiateMiddleware(*config); err != nil { + h.d.SelfServiceErrorManager().Forward(r.Context(), w, r, err) + } + } + + conf := h.d.Config(r.Context()) + + // Checks if the user already have an active session + if e := new(session.ErrNoActiveSessionFound); errors.As(e, &e) { + // No session exists yet, we start the auth flow and create the session + samlMiddleware.HandleStartAuthFlow(w, r) + } else { + // A session already exist, we redirect to the main page + http.Redirect(w, r, conf.SelfServiceBrowserDefaultReturnTo().Path, http.StatusTemporaryRedirect) + } +} + +func DestroyMiddlewareIfExists() { + if samlMiddleware != nil { + samlMiddleware = nil + } +} + +func (h *Handler) instantiateMiddleware(config config.Config) error { + // Create a SAMLProvider object from the config file + var c samlstrategy.ConfigurationCollection + conf := config.SelfServiceStrategy("saml").Config + if err := jsonx. + NewStrictDecoder(bytes.NewBuffer(conf)). + Decode(&c); err != nil { + return errors.Wrapf(err, "Unable to decode config %v", string(conf)) + } + + // Key pair to encrypt and sign SAML requests + keyPair, err := tls.LoadX509KeyPair(strings.Replace(c.SAMLProviders[len(c.SAMLProviders)-1].PublicCertPath, "file://", "", 1), strings.Replace(c.SAMLProviders[len(c.SAMLProviders)-1].PrivateKeyPath, "file://", "", 1)) + if err != nil { + return err + } + keyPair.Leaf, err = x509.ParseCertificate(keyPair.Certificate[0]) + if err != nil { + return err + } + + var idpMetadata *samlidp.EntityDescriptor + + if len(c.SAMLProviders) > 0 { + // We check if the metadata file is provided + + if val, ok := c.SAMLProviders[len(c.SAMLProviders)-1].IDPInformation["idp_metadata_url"]; ok && len(val) > 0 { + + metadataURL := c.SAMLProviders[len(c.SAMLProviders)-1].IDPInformation["idp_metadata_url"] + // The metadata file is provided + if strings.HasPrefix(metadataURL, "file://") { + metadataURL = strings.Replace(metadataURL, "file://", "", 1) + + metadataPlainText, err := ioutil.ReadFile(metadataURL) + if err != nil { + return err + } + + idpMetadata, err = samlsp.ParseMetadata([]byte(metadataPlainText)) + if err != nil { + return err + } + + } else { + idpMetadataURL, err := url.Parse(metadataURL) + if err != nil { + return err + } + // Parse the content of metadata file into a Golang struct + idpMetadata, err = samlsp.FetchMetadata(context.Background(), http.DefaultClient, *idpMetadataURL) + if err != nil { + return err + } + } + } else { + + // The metadata file is not provided + // So were are creating a minimalist IDP metadata based on what is provided by the user on the config file + entityIDURL, err := url.Parse(c.SAMLProviders[len(c.SAMLProviders)-1].IDPInformation["idp_entity_id"]) + if err != nil { + return err + } + + // The IDP SSO URL + IDPSSOURL, err := url.Parse(c.SAMLProviders[len(c.SAMLProviders)-1].IDPInformation["idp_sso_url"]) + if err != nil { + return err + } + + // The IDP Logout URL + IDPlogoutURL, err := url.Parse(c.SAMLProviders[len(c.SAMLProviders)-1].IDPInformation["idp_logout_url"]) + if err != nil { + return err + } + + // The certificate of the IDP + certificate, err := ioutil.ReadFile(strings.Replace(c.SAMLProviders[len(c.SAMLProviders)-1].IDPInformation["idp_certificate_path"], "file://", "", 1)) + if err != nil { + return err + } + + // We parse it into a x509.Certificate object + IDPCertificate, err := MustParseCertificate(certificate) + if err != nil { + return err + } + + // Because the metadata file is not provided, we need to simulate an IDP to create artificial metadata from the data entered in the conf file + tempIDP := samlidp.IdentityProvider{ + Key: nil, + Certificate: IDPCertificate, + Logger: nil, + MetadataURL: *entityIDURL, + SSOURL: *IDPSSOURL, + LogoutURL: *IDPlogoutURL, + } + + // Now we assign our reconstructed metadata to our SP + idpMetadata = tempIDP.Metadata() + } + } else { + + return errors.New("Please add a SAML provider.") + + } + + // The main URL + rootURL, err := url.Parse(config.SelfServiceBrowserDefaultReturnTo().String()) + if err != nil { + return err + } + + // Here we create a MiddleWare to transform Kratos into a Service Provider + samlMiddleWare, err := samlsp.New(samlsp.Options{ + URL: *rootURL, + Key: keyPair.PrivateKey.(*rsa.PrivateKey), + Certificate: keyPair.Leaf, + IDPMetadata: idpMetadata, + SignRequest: true, + }) + if err != nil { + return err + } + + var publicUrlString = config.SelfPublicURL().String() + + // Sometimes there is an issue with double slash into the url so we prevent it + // Crewjam library use default route for ACS and metadat but we want to overwrite them + RouteSamlAcsWithSlash := RouteSamlAcs + if publicUrlString[len(publicUrlString)-1] != '/' { + + u, err := url.Parse(publicUrlString + RouteSamlAcsWithSlash) + if err != nil { + return err + } + samlMiddleWare.ServiceProvider.AcsURL = *u + + } else if publicUrlString[len(publicUrlString)-1] == '/' { + + publicUrlString = publicUrlString[:len(publicUrlString)-1] + u, err := url.Parse(publicUrlString + RouteSamlAcsWithSlash) + if err != nil { + return err + } + samlMiddleWare.ServiceProvider.AcsURL = *u + } + + // Crewjam library use default route for ACS and metadat but we want to overwrite them + metadata, err := url.Parse(publicUrlString + RouteSamlMetadata) + samlMiddleWare.ServiceProvider.MetadataURL = *metadata + + // The EntityID in the AuthnRequest is the Metadata URL + samlMiddleWare.ServiceProvider.EntityID = samlMiddleWare.ServiceProvider.MetadataURL.String() + + // The issuer format is unspecified + samlMiddleWare.ServiceProvider.AuthnNameIDFormat = samlidp.UnspecifiedNameIDFormat + + samlMiddleware = samlMiddleWare + + return nil +} + +func GetMiddleware() (*samlsp.Middleware, error) { + if samlMiddleware == nil { + return nil, errors.Errorf("The MiddleWare for SAML is nil") + } + return samlMiddleware, nil +} + +func MustParseCertificate(pemStr []byte) (*x509.Certificate, error) { + b, _ := pem.Decode(pemStr) + if b == nil { + return nil, errors.Errorf("Cannot find the next PEM formatted block") + } + cert, err := x509.ParseCertificate(b.Bytes) + if err != nil { + return nil, err + } + return cert, nil +} diff --git a/selfservice/flow/saml/helpertest/helpertest.go b/selfservice/flow/saml/helpertest/helpertest.go new file mode 100644 index 000000000000..1def12d4c3f6 --- /dev/null +++ b/selfservice/flow/saml/helpertest/helpertest.go @@ -0,0 +1,202 @@ +package helpertest + +import ( + "crypto" + "crypto/rand" + "crypto/rsa" + "crypto/x509" + "encoding/pem" + "encoding/xml" + "io/ioutil" + "net/http" + "net/http/cookiejar" + "net/http/httptest" + "testing" + "time" + + "github.com/beevik/etree" + crewjamsaml "github.com/crewjam/saml" + "github.com/crewjam/saml/samlsp" + "github.com/crewjam/saml/xmlenc" + "github.com/pkg/errors" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/tidwall/gjson" + "gotest.tools/golden" + + "github.com/ory/kratos/driver/config" + "github.com/ory/kratos/identity" + "github.com/ory/kratos/internal" + "github.com/ory/kratos/internal/testhelpers" + samlhandler "github.com/ory/kratos/selfservice/flow/saml" + "github.com/ory/kratos/selfservice/strategy/saml" + samlstrategy "github.com/ory/kratos/selfservice/strategy/saml" + samlstrat "github.com/ory/kratos/selfservice/strategy/saml/strategy" + "github.com/ory/kratos/x" +) + +var TimeNow = func() time.Time { return time.Now().UTC() } +var RandReader = rand.Reader + +func NewSAMLProvider( + t *testing.T, + kratos *httptest.Server, + id, label string, +) samlstrategy.Configuration { + + return samlstrategy.Configuration{ + ID: id, + Label: label, + PublicCertPath: "secret", + PrivateKeyPath: "/", + Mapper: "file://./stub/oidc.hydra.jsonnet", + //IDPMetadataURL: "", + //IDPSSOURL: "", + } +} + +func ViperSetProviderConfig(t *testing.T, conf *config.Config, SAMLProvider ...samlstrategy.Configuration) { + conf.MustSet(config.ViperKeySelfServiceStrategyConfig+"."+string(identity.CredentialsTypeSAML)+".config", &samlstrategy.ConfigurationCollection{SAMLProviders: SAMLProvider}) + conf.MustSet(config.ViperKeySelfServiceStrategyConfig+"."+string(identity.CredentialsTypeSAML)+".enabled", true) +} + +func NewClient(t *testing.T, jar *cookiejar.Jar) *http.Client { + if jar == nil { + j, err := cookiejar.New(nil) + jar = j + require.NoError(t, err) + } + return &http.Client{ + Jar: jar, + CheckRedirect: func(req *http.Request, via []*http.Request) error { + if len(via) >= 20 { + for k, v := range via { + t.Logf("Failed with redirect (%d): %s", k, v.URL.String()) + } + return errors.New("stopped after 20 redirects") + } + return nil + }, + } +} + +// AssertSystemError asserts an error ui response +func AssertSystemError(t *testing.T, errTS *httptest.Server, res *http.Response, body []byte, code int, reason string) { + require.Contains(t, res.Request.URL.String(), errTS.URL, "%s", body) + + assert.Equal(t, int64(code), gjson.GetBytes(body, "code").Int(), "%s", body) + assert.Contains(t, gjson.GetBytes(body, "reason").String(), reason, "%s", body) +} + +func mustParseCertificate(pemStr []byte) *x509.Certificate { + b, _ := pem.Decode(pemStr) + if b == nil { + panic("cannot parse PEM") + } + cert, err := x509.ParseCertificate(b.Bytes) + if err != nil { + panic(err) + } + return cert +} + +func mustParsePrivateKey(pemStr []byte) crypto.PrivateKey { + b, _ := pem.Decode(pemStr) + if b == nil { + panic("cannot parse PEM") + } + k, err := x509.ParsePKCS1PrivateKey(b.Bytes) + if err != nil { + panic(err) + } + return k +} + +func InitMiddleware(t *testing.T, idpInformation map[string]string) (*samlsp.Middleware, *samlstrat.Strategy, *httptest.Server, error) { + conf, reg := internal.NewFastRegistryWithMocks(t) + + strategy := samlstrat.NewStrategy(reg) + errTS := testhelpers.NewErrorTestServer(t, reg) + routerP := x.NewRouterPublic() + routerA := x.NewRouterAdmin() + ts, _ := testhelpers.NewKratosServerWithRouters(t, reg, routerP, routerA) + + attributesMap := make(map[string]string) + attributesMap["id"] = "mail" + attributesMap["firstname"] = "givenName" + attributesMap["lastname"] = "sn" + attributesMap["email"] = "mail" + + // Initiates the service provider + ViperSetProviderConfig( + t, + conf, + NewSAMLProvider(t, ts, "samlProviderTestID", "samlProviderTestLabel"), + saml.Configuration{ + ID: "samlProviderTestID", + Label: "samlProviderTestLabel", + PublicCertPath: "file://testdata/myservice.cert", + PrivateKeyPath: "file://testdata/myservice.key", + Mapper: "file://testdata/saml.jsonnet", + AttributesMap: attributesMap, + IDPInformation: idpInformation, + }, + ) + + conf.MustSet(config.ViperKeySelfServiceRegistrationEnabled, true) + testhelpers.SetDefaultIdentitySchema(conf, "file://testdata/registration.schema.json") + conf.MustSet(config.HookStrategyKey(config.ViperKeySelfServiceRegistrationAfter, + identity.CredentialsTypeSAML.String()), []config.SelfServiceHook{{Name: "session"}}) + + t.Logf("Kratos Public URL: %s", ts.URL) + t.Logf("Kratos Error URL: %s", errTS.URL) + + // Instantiates the MiddleWare + _, err := NewClient(t, nil).Get(ts.URL + "/self-service/methods/saml/metadata") + require.NoError(t, err) + + middleware, err := samlhandler.GetMiddleware() + middleware.ServiceProvider.Key = mustParsePrivateKey(golden.Get(t, "key.pem")).(*rsa.PrivateKey) + middleware.ServiceProvider.Certificate = mustParseCertificate(golden.Get(t, "cert.pem")) + require.NoError(t, err) + + return middleware, strategy, ts, err +} + +func InitMiddlewareWithMetadata(t *testing.T, metadataURL string) (*samlsp.Middleware, *samlstrat.Strategy, *httptest.Server, error) { + idpInformation := make(map[string]string) + idpInformation["idp_metadata_url"] = metadataURL + + return InitMiddleware(t, idpInformation) +} + +func InitMiddlewareWithoutMetadata(t *testing.T, idpSsoUrl string, idpEntityId string, + idpCertifiatePath string, idpLogoutUrl string) (*samlsp.Middleware, *samlstrat.Strategy, *httptest.Server, error) { + + idpInformation := make(map[string]string) + idpInformation["idp_sso_url"] = idpSsoUrl + idpInformation["idp_entity_id"] = idpEntityId + idpInformation["idp_certificate_path"] = idpCertifiatePath + idpInformation["idp_logout_url"] = idpLogoutUrl + + return InitMiddleware(t, idpInformation) +} + +func GetAndDecryptAssertion(t *testing.T, samlResponseFile string, key *rsa.PrivateKey) (*crewjamsaml.Assertion, error) { + // Load saml response test file + samlResponse, err := ioutil.ReadFile(samlResponseFile) + + // Decrypt saml response assertion + doc := etree.NewDocument() + err = doc.ReadFromBytes(samlResponse) + require.NoError(t, err) + responseEl := doc.Root() + el := responseEl.FindElement("//EncryptedAssertion/EncryptedData") + plaintextAssertion, err := xmlenc.Decrypt(key, el) + + assertion := &crewjamsaml.Assertion{} + err = xml.Unmarshal(plaintextAssertion, assertion) + require.NoError(t, err) + + return assertion, err +} diff --git a/selfservice/flow/saml/test/handler_test.go b/selfservice/flow/saml/test/handler_test.go new file mode 100644 index 000000000000..0af00023e473 --- /dev/null +++ b/selfservice/flow/saml/test/handler_test.go @@ -0,0 +1,92 @@ +package saml_test + +import ( + "io/ioutil" + "testing" + + samlhandler "github.com/ory/kratos/selfservice/flow/saml" + "github.com/stretchr/testify/require" + + helpertest "github.com/ory/kratos/selfservice/flow/saml/helpertest" + "gotest.tools/assert" +) + +func TestInitMiddleWareWithMetadata(t *testing.T) { + if testing.Short() { + t.Skip() + } + + samlhandler.DestroyMiddlewareIfExists() + + middleWare, _, _, err := helpertest.InitMiddlewareWithMetadata(t, + "file://testdata/idp_saml_metadata.xml") + + require.NoError(t, err) + assert.Check(t, middleWare != nil) + assert.Check(t, middleWare.ServiceProvider.IDPMetadata != nil) + assert.Check(t, middleWare.ServiceProvider.MetadataURL.Path == "/self-service/methods/saml/metadata") + assert.Check(t, middleWare.ServiceProvider.IDPMetadata.EntityID == "https://idp.testshib.org/idp/shibboleth") +} + +func TestInitMiddleWareWithoutMetadata(t *testing.T) { + if testing.Short() { + t.Skip() + } + + samlhandler.DestroyMiddlewareIfExists() + + middleWare, _, _, err := helpertest.InitMiddlewareWithoutMetadata(t, + "https://samltest.id/idp/profile/SAML2/Redirect/SSO", + "https://samltest.id/saml/idp", + "file://testdata/samlkratos.crt", + "https://samltest.id/idp/profile/SAML2/Redirect/SSO") + + require.NoError(t, err) + assert.Check(t, middleWare != nil) + assert.Check(t, middleWare.ServiceProvider.IDPMetadata != nil) + assert.Check(t, middleWare.ServiceProvider.MetadataURL.Path == "/self-service/methods/saml/metadata") + assert.Check(t, middleWare.ServiceProvider.IDPMetadata.EntityID == "https://samltest.id/saml/idp") +} + +func TestGetMiddleware(t *testing.T) { + if testing.Short() { + t.Skip() + } + + samlhandler.DestroyMiddlewareIfExists() + + helpertest.InitMiddlewareWithMetadata(t, + "file://testdata/idp_saml_metadata.xml") + + middleWare, err := samlhandler.GetMiddleware() + + require.NoError(t, err) + assert.Check(t, middleWare != nil) + assert.Check(t, middleWare.ServiceProvider.IDPMetadata != nil) + assert.Check(t, middleWare.ServiceProvider.MetadataURL.Path == "/self-service/methods/saml/metadata") + assert.Check(t, middleWare.ServiceProvider.IDPMetadata.EntityID == "https://idp.testshib.org/idp/shibboleth") +} + +func TestMustParseCertificate(t *testing.T) { + if testing.Short() { + t.Skip() + } + + samlhandler.DestroyMiddlewareIfExists() + + certificate, err := ioutil.ReadFile("testdata/samlkratos.crt") + require.NoError(t, err) + + cert, err := samlhandler.MustParseCertificate(certificate) + + require.NoError(t, err) + assert.Check(t, cert.Issuer.Country[0] == "AU") + assert.Check(t, cert.Issuer.Organization[0] == "Internet Widgits Pty Ltd") + assert.Check(t, cert.Issuer.Province[0] == "Some-State") + assert.Check(t, cert.Subject.Country[0] == "AU") + assert.Check(t, cert.Subject.Organization[0] == "Internet Widgits Pty Ltd") + assert.Check(t, cert.Subject.Province[0] == "Some-State") + assert.Check(t, cert.NotBefore.String() == "2022-02-21 11:08:20 +0000 UTC") + assert.Check(t, cert.NotAfter.String() == "2023-02-21 11:08:20 +0000 UTC") + assert.Check(t, cert.SerialNumber.String() == "485646075402096403898806020771481121115125312047") +} diff --git a/selfservice/flow/saml/test/metadata_test.go b/selfservice/flow/saml/test/metadata_test.go new file mode 100644 index 000000000000..7545034d7157 --- /dev/null +++ b/selfservice/flow/saml/test/metadata_test.go @@ -0,0 +1,127 @@ +package saml_test + +import ( + "encoding/xml" + "io" + "io/ioutil" + "net/http" + "reflect" + "testing" + + samlhandler "github.com/ory/kratos/selfservice/flow/saml" + helpertest "github.com/ory/kratos/selfservice/flow/saml/helpertest" + + samltesthelpers "github.com/ory/kratos/selfservice/flow/saml/helpertest" + + "github.com/stretchr/testify/require" + "gotest.tools/assert" + is "gotest.tools/assert/cmp" +) + +type Metadata struct { + XMLName xml.Name `xml:"EntityDescriptor"` + Text string `xml:",chardata"` + Xmlns string `xml:"xmlns,attr"` + ValidUntil string `xml:"validUntil,attr"` + EntityID string `xml:"entityID,attr"` + SPSSODescriptor struct { + Text string `xml:",chardata"` + Xmlns string `xml:"xmlns,attr"` + ValidUntil string `xml:"validUntil,attr"` + ProtocolSupportEnumeration string `xml:"protocolSupportEnumeration,attr"` + AuthnRequestsSigned string `xml:"AuthnRequestsSigned,attr"` + WantAssertionsSigned string `xml:"WantAssertionsSigned,attr"` + KeyDescriptor []struct { + Text string `xml:",chardata"` + Use string `xml:"use,attr"` + KeyInfo struct { + Text string `xml:",chardata"` + Xmlns string `xml:"xmlns,attr"` + X509Data struct { + Text string `xml:",chardata"` + Xmlns string `xml:"xmlns,attr"` + X509Certificate struct { + Text string `xml:",chardata"` + Xmlns string `xml:"xmlns,attr"` + } `xml:"X509Certificate"` + } `xml:"X509Data"` + } `xml:"KeyInfo"` + EncryptionMethod []struct { + Text string `xml:",chardata"` + Algorithm string `xml:"Algorithm,attr"` + } `xml:"EncryptionMethod"` + } `xml:"KeyDescriptor"` + SingleLogoutService struct { + Text string `xml:",chardata"` + Binding string `xml:"Binding,attr"` + Location string `xml:"Location,attr"` + ResponseLocation string `xml:"ResponseLocation,attr"` + } `xml:"SingleLogoutService"` + AssertionConsumerService []struct { + Text string `xml:",chardata"` + Binding string `xml:"Binding,attr"` + Location string `xml:"Location,attr"` + Index string `xml:"index,attr"` + } `xml:"AssertionConsumerService"` + } `xml:"SPSSODescriptor"` +} + +func TestXmlMetadataExist(t *testing.T) { + if testing.Short() { + t.Skip() + } + + samlhandler.DestroyMiddlewareIfExists() + + _, _, ts, err := helpertest.InitMiddlewareWithMetadata(t, + "file://testdata/idp_saml_metadata.xml") + assert.NilError(t, err) + res, _ := samltesthelpers.NewClient(t, nil).Get(ts.URL + "/self-service/methods/saml/metadata") + + assert.Check(t, is.Equal(http.StatusOK, res.StatusCode)) + assert.Check(t, is.Equal("application/samlmetadata+xml", + res.Header.Get("Content-type"))) +} + +func TestXmlMetadataValues(t *testing.T) { + if testing.Short() { + t.Skip() + } + + samlhandler.DestroyMiddlewareIfExists() + + _, _, ts, err := helpertest.InitMiddlewareWithMetadata(t, + "file://testdata/idp_saml_metadata.xml") + res, _ := samltesthelpers.NewClient(t, nil).Get(ts.URL + "/self-service/methods/saml/metadata") + body, _ := io.ReadAll(res.Body) + + assert.Check(t, is.Equal(http.StatusOK, res.StatusCode)) + assert.Check(t, is.Equal("application/samlmetadata+xml", + res.Header.Get("Content-type"))) + + expectedMetadata, err := ioutil.ReadFile("./testdata/expected_metadata.xml") + assert.NilError(t, err) + + // The string is parse to a struct + var expectedStructMetadata Metadata + err = xml.Unmarshal(expectedMetadata, &expectedStructMetadata) + require.NoError(t, err) + + var obtainedStructureMetadata Metadata + err = xml.Unmarshal(body, &obtainedStructureMetadata) + require.NoError(t, err) + + // We delete data that is likely to change naturally + expectedStructMetadata.SPSSODescriptor.AssertionConsumerService[0].Location = "" + expectedStructMetadata.SPSSODescriptor.AssertionConsumerService[1].Location = "" + obtainedStructureMetadata.SPSSODescriptor.AssertionConsumerService[0].Location = "" + obtainedStructureMetadata.SPSSODescriptor.AssertionConsumerService[1].Location = "" + expectedStructMetadata.ValidUntil = "" + expectedStructMetadata.SPSSODescriptor.ValidUntil = "" + obtainedStructureMetadata.ValidUntil = "" + obtainedStructureMetadata.SPSSODescriptor.ValidUntil = "" + expectedStructMetadata.EntityID = "" + obtainedStructureMetadata.EntityID = "" + + assert.Check(t, reflect.DeepEqual(expectedStructMetadata, obtainedStructureMetadata)) +} diff --git a/selfservice/flow/saml/test/testdata/cert.pem b/selfservice/flow/saml/test/testdata/cert.pem new file mode 100644 index 000000000000..52667ef39ff2 --- /dev/null +++ b/selfservice/flow/saml/test/testdata/cert.pem @@ -0,0 +1,13 @@ +-----BEGIN CERTIFICATE----- +MIIB7zCCAVgCCQDFzbKIp7b3MTANBgkqhkiG9w0BAQUFADA8MQswCQYDVQQGEwJV +UzELMAkGA1UECAwCR0ExDDAKBgNVBAoMA2ZvbzESMBAGA1UEAwwJbG9jYWxob3N0 +MB4XDTEzMTAwMjAwMDg1MVoXDTE0MTAwMjAwMDg1MVowPDELMAkGA1UEBhMCVVMx +CzAJBgNVBAgMAkdBMQwwCgYDVQQKDANmb28xEjAQBgNVBAMMCWxvY2FsaG9zdDCB +nzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA1PMHYmhZj308kWLhZVT4vOulqx/9 +ibm5B86fPWwUKKQ2i12MYtz07tzukPymisTDhQaqyJ8Kqb/6JjhmeMnEOdTvSPmH +O8m1ZVveJU6NoKRn/mP/BD7FW52WhbrUXLSeHVSKfWkNk6S4hk9MV9TswTvyRIKv +Rsw0X/gfnqkroJcCAwEAATANBgkqhkiG9w0BAQUFAAOBgQCMMlIO+GNcGekevKgk +akpMdAqJfs24maGb90DvTLbRZRD7Xvn1MnVBBS9hzlXiFLYOInXACMW5gcoRFfeT +QLSouMM8o57h0uKjfTmuoWHLQLi6hnF+cvCsEFiJZ4AbF+DgmO6TarJ8O05t8zvn +OwJlNCASPZRH/JmF8tX0hoHuAQ== +-----END CERTIFICATE----- \ No newline at end of file diff --git a/selfservice/flow/saml/test/testdata/expected_metadata.xml b/selfservice/flow/saml/test/testdata/expected_metadata.xml new file mode 100644 index 000000000000..05039766f75f --- /dev/null +++ b/selfservice/flow/saml/test/testdata/expected_metadata.xml @@ -0,0 +1,25 @@ + + + + + + MIIB7zCCAVgCCQDFzbKIp7b3MTANBgkqhkiG9w0BAQUFADA8MQswCQYDVQQGEwJVUzELMAkGA1UECAwCR0ExDDAKBgNVBAoMA2ZvbzESMBAGA1UEAwwJbG9jYWxob3N0MB4XDTEzMTAwMjAwMDg1MVoXDTE0MTAwMjAwMDg1MVowPDELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAkdBMQwwCgYDVQQKDANmb28xEjAQBgNVBAMMCWxvY2FsaG9zdDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgY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git a/selfservice/flow/saml/test/testdata/idp_saml_metadata.xml b/selfservice/flow/saml/test/testdata/idp_saml_metadata.xml new file mode 100644 index 000000000000..dcaf7f051dae --- /dev/null +++ b/selfservice/flow/saml/test/testdata/idp_saml_metadata.xml @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + + testshib.org + + TestShib Test IdP + TestShib IdP. Use this as a source of attributes + for your test SP. + https://www.testshib.org/testshibtwo.jpg + + + + + + MIIEDjCCAvagAwIBAgIBADANBgkqhkiG9w0BAQUFADBnMQswCQYDVQQGEwJVUzEV + MBMGA1UECBMMUGVubnN5bHZhbmlhMRMwEQYDVQQHEwpQaXR0c2J1cmdoMREwDwYD + VQQKEwhUZXN0U2hpYjEZMBcGA1UEAxMQaWRwLnRlc3RzaGliLm9yZzAeFw0wNjA4 + MzAyMTEyMjVaFw0xNjA4MjcyMTEyMjVaMGcxCzAJBgNVBAYTAlVTMRUwEwYDVQQI + EwxQZW5uc3lsdmFuaWExEzARBgNVBAcTClBpdHRzYnVyZ2gxETAPBgNVBAoTCFRl + c3RTaGliMRkwFwYDVQQDExBpZHAudGVzdHNoaWIub3JnMIIBIjANBgkqhkiG9w0B + AQEFAAOCAQ8AMIIBCgKCAQEArYkCGuTmJp9eAOSGHwRJo1SNatB5ZOKqDM9ysg7C + yVTDClcpu93gSP10nH4gkCZOlnESNgttg0r+MqL8tfJC6ybddEFB3YBo8PZajKSe + 3OQ01Ow3yT4I+Wdg1tsTpSge9gEz7SrC07EkYmHuPtd71CHiUaCWDv+xVfUQX0aT + NPFmDixzUjoYzbGDrtAyCqA8f9CN2txIfJnpHE6q6CmKcoLADS4UrNPlhHSzd614 + kR/JYiks0K4kbRqCQF0Dv0P5Di+rEfefC6glV8ysC8dB5/9nb0yh/ojRuJGmgMWH + gWk6h0ihjihqiu4jACovUZ7vVOCgSE5Ipn7OIwqd93zp2wIDAQABo4HEMIHBMB0G + A1UdDgQWBBSsBQ869nh83KqZr5jArr4/7b+QazCBkQYDVR0jBIGJMIGGgBSsBQ86 + 9nh83KqZr5jArr4/7b+Qa6FrpGkwZzELMAkGA1UEBhMCVVMxFTATBgNVBAgTDFBl + bm5zeWx2YW5pYTETMBEGA1UEBxMKUGl0dHNidXJnaDERMA8GA1UEChMIVGVzdFNo + aWIxGTAXBgNVBAMTEGlkcC50ZXN0c2hpYi5vcmeCAQAwDAYDVR0TBAUwAwEB/zAN + BgkqhkiG9w0BAQUFAAOCAQEAjR29PhrCbk8qLN5MFfSVk98t3CT9jHZoYxd8QMRL + I4j7iYQxXiGJTT1FXs1nd4Rha9un+LqTfeMMYqISdDDI6tv8iNpkOAvZZUosVkUo + 93pv1T0RPz35hcHHYq2yee59HJOco2bFlcsH8JBXRSRrJ3Q7Eut+z9uo80JdGNJ4 + /SJy5UorZ8KazGj16lfJhOBXldgrhppQBb0Nq6HKHguqmwRfJ+WkxemZXzhediAj + Geka8nz8JjwxpUjAiSWYKLtJhGEaTqCYxCCX2Dw+dOTqUzHOZ7WKv4JXPK5G/Uhr + 8K/qhmFT2nIQi538n6rVYLeWj8Bbnl+ev0peYzxFyF5sQA== + + + + + + + + + + + + urn:mace:shibboleth:1.0:nameIdentifier + urn:oasis:names:tc:SAML:2.0:nameid-format:transient + + + + + + + + + + + + MIIEDjCCAvagAwIBAgIBADANBgkqhkiG9w0BAQUFADBnMQswCQYDVQQGEwJVUzEV + MBMGA1UECBMMUGVubnN5bHZhbmlhMRMwEQYDVQQHEwpQaXR0c2J1cmdoMREwDwYD + VQQKEwhUZXN0U2hpYjEZMBcGA1UEAxMQaWRwLnRlc3RzaGliLm9yZzAeFw0wNjA4 + MzAyMTEyMjVaFw0xNjA4MjcyMTEyMjVaMGcxCzAJBgNVBAYTAlVTMRUwEwYDVQQI + EwxQZW5uc3lsdmFuaWExEzARBgNVBAcTClBpdHRzYnVyZ2gxETAPBgNVBAoTCFRl + c3RTaGliMRkwFwYDVQQDExBpZHAudGVzdHNoaWIub3JnMIIBIjANBgkqhkiG9w0B + AQEFAAOCAQ8AMIIBCgKCAQEArYkCGuTmJp9eAOSGHwRJo1SNatB5ZOKqDM9ysg7C + yVTDClcpu93gSP10nH4gkCZOlnESNgttg0r+MqL8tfJC6ybddEFB3YBo8PZajKSe + 3OQ01Ow3yT4I+Wdg1tsTpSge9gEz7SrC07EkYmHuPtd71CHiUaCWDv+xVfUQX0aT + NPFmDixzUjoYzbGDrtAyCqA8f9CN2txIfJnpHE6q6CmKcoLADS4UrNPlhHSzd614 + kR/JYiks0K4kbRqCQF0Dv0P5Di+rEfefC6glV8ysC8dB5/9nb0yh/ojRuJGmgMWH + gWk6h0ihjihqiu4jACovUZ7vVOCgSE5Ipn7OIwqd93zp2wIDAQABo4HEMIHBMB0G + A1UdDgQWBBSsBQ869nh83KqZr5jArr4/7b+QazCBkQYDVR0jBIGJMIGGgBSsBQ86 + 9nh83KqZr5jArr4/7b+Qa6FrpGkwZzELMAkGA1UEBhMCVVMxFTATBgNVBAgTDFBl + bm5zeWx2YW5pYTETMBEGA1UEBxMKUGl0dHNidXJnaDERMA8GA1UEChMIVGVzdFNo + aWIxGTAXBgNVBAMTEGlkcC50ZXN0c2hpYi5vcmeCAQAwDAYDVR0TBAUwAwEB/zAN + BgkqhkiG9w0BAQUFAAOCAQEAjR29PhrCbk8qLN5MFfSVk98t3CT9jHZoYxd8QMRL + I4j7iYQxXiGJTT1FXs1nd4Rha9un+LqTfeMMYqISdDDI6tv8iNpkOAvZZUosVkUo + 93pv1T0RPz35hcHHYq2yee59HJOco2bFlcsH8JBXRSRrJ3Q7Eut+z9uo80JdGNJ4 + /SJy5UorZ8KazGj16lfJhOBXldgrhppQBb0Nq6HKHguqmwRfJ+WkxemZXzhediAj + Geka8nz8JjwxpUjAiSWYKLtJhGEaTqCYxCCX2Dw+dOTqUzHOZ7WKv4JXPK5G/Uhr + 8K/qhmFT2nIQi538n6rVYLeWj8Bbnl+ev0peYzxFyF5sQA== + + + + + + + + + + + + urn:mace:shibboleth:1.0:nameIdentifier + urn:oasis:names:tc:SAML:2.0:nameid-format:transient + + + TestShib Two Identity Provider + TestShib Two + http://www.testshib.org/testshib-two/ + + + Nate + Klingenstein + ndk@internet2.edu + + \ No newline at end of file diff --git a/selfservice/flow/saml/test/testdata/key.pem b/selfservice/flow/saml/test/testdata/key.pem new file mode 100644 index 000000000000..48284dac33a1 --- /dev/null +++ b/selfservice/flow/saml/test/testdata/key.pem @@ -0,0 +1,15 @@ +-----BEGIN RSA PRIVATE KEY----- +MIICXgIBAAKBgQDU8wdiaFmPfTyRYuFlVPi866WrH/2JubkHzp89bBQopDaLXYxi +3PTu3O6Q/KaKxMOFBqrInwqpv/omOGZ4ycQ51O9I+Yc7ybVlW94lTo2gpGf+Y/8E +PsVbnZaFutRctJ4dVIp9aQ2TpLiGT0xX1OzBO/JEgq9GzDRf+B+eqSuglwIDAQAB +AoGBAMuy1eN6cgFiCOgBsB3gVDdTKpww87Qk5ivjqEt28SmXO13A1KNVPS6oQ8SJ +CT5Azc6X/BIAoJCURVL+LHdqebogKljhH/3yIel1kH19vr4E2kTM/tYH+qj8afUS +JEmArUzsmmK8ccuNqBcllqdwCZjxL4CHDUmyRudFcHVX9oyhAkEA/OV1OkjM3CLU +N3sqELdMmHq5QZCUihBmk3/N5OvGdqAFGBlEeewlepEVxkh7JnaNXAXrKHRVu/f/ +fbCQxH+qrwJBANeQERF97b9Sibp9xgolb749UWNlAdqmEpmlvmS202TdcaaT1msU +4rRLiQN3X9O9mq4LZMSVethrQAdX1whawpkCQQDk1yGf7xZpMJ8F4U5sN+F4rLyM +Rq8Sy8p2OBTwzCUXXK+fYeXjybsUUMr6VMYTRP2fQr/LKJIX+E5ZxvcIyFmDAkEA +yfjNVUNVaIbQTzEbRlRvT6MqR+PTCefC072NF9aJWR93JimspGZMR7viY6IM4lrr +vBkm0F5yXKaYtoiiDMzlOQJADqmEwXl0D72ZG/2KDg8b4QZEmC9i5gidpQwJXUc6 +hU+IVQoLxRq0fBib/36K9tcrrO5Ba4iEvDcNY+D8yGbUtA== +-----END RSA PRIVATE KEY----- \ No newline at end of file diff --git a/selfservice/flow/saml/test/testdata/myservice.cert b/selfservice/flow/saml/test/testdata/myservice.cert new file mode 100755 index 000000000000..a815f8f44742 --- /dev/null +++ b/selfservice/flow/saml/test/testdata/myservice.cert @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIDITCCAgmgAwIBAgIUAKe3G3G4JRoPJDbHcFfUC0M1vUwwDQYJKoZIhvcNAQEL +BQAwIDEeMBwGA1UEAwwVbXlzZXJ2aWNlLmV4YW1wbGUuY29tMB4XDTIxMTIyODEw +MTcxOFoXDTIyMTIyODEwMTcxOFowIDEeMBwGA1UEAwwVbXlzZXJ2aWNlLmV4YW1w +bGUuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA456eHhpbTabo +JD9IurVIakdb4Y1CtM1cWEgeDB/owu+h13pqj+wk/1AlFUNIYKfzJNmP+CoJv5pS +vUeJaMdA7vKUCHPMY7SNoZdaX0eGV4Z9Q7Q6pSkV+heoamojl+Lq9VIVvWnz4ra9 +3xjvJJ4bACyIz7k9u32jAb+v3Rh3axVlPfYJqCx0gU+tcMxb/Lc7HH7ynAjFGc4N +iG7qOqE2nmzRanKw4dMJhkzhNyFQbqtd4DmEzV70XixyztxmbENVfNdvOrCc34/e +JR4q7w5YEGMwUIPip7/zz/itqsrk0x4/VF1lExMOihf8dfYnqdF3+SdywoBf5UC4 +AUyFS/3FgQIDAQABo1MwUTAdBgNVHQ4EFgQUdG+6zhMmsR2yenGz22Iacjeh6BUw +HwYDVR0jBBgwFoAUdG+6zhMmsR2yenGz22Iacjeh6BUwDwYDVR0TAQH/BAUwAwEB +/zANBgkqhkiG9w0BAQsFAAOCAQEAU5eJKGCBsJpMgL6AgrtpY47iT2KtIkeiI5RC +L+2z2pORG2jFzvY+3kcYA+Nj7EwVyBGmn2lL2JCgk3Qr1YsO4IMJ6sZYbDi6I1SR +z14QMYDRWqPY7VoyqiDzdIS9ENWm80gCG4BChSMtEtN2kmjdTOM++Cr4LY/LLhM4 +9aSNfXHTx4kklP1VVc8dGWw+bFtzZUeP6O+ssrFhcse4V6DoQAxYSU4MAAjePhAP +0IS2I3sSzLe/LCsJMPZv0r1q8YQCGBrijAXSnQiu8KFh8hEQusxilIZV9XPDGB98 +EwTT5cbtUtOIbrZ6kdBs49O27xCTymaIuysidFtywwTaDdrc1g== +-----END CERTIFICATE----- diff --git a/selfservice/flow/saml/test/testdata/myservice.key b/selfservice/flow/saml/test/testdata/myservice.key new file mode 100755 index 000000000000..e7b461f2f228 --- /dev/null +++ b/selfservice/flow/saml/test/testdata/myservice.key @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDjnp4eGltNpugk +P0i6tUhqR1vhjUK0zVxYSB4MH+jC76HXemqP7CT/UCUVQ0hgp/Mk2Y/4Kgm/mlK9 +R4lox0Du8pQIc8xjtI2hl1pfR4ZXhn1DtDqlKRX6F6hqaiOX4ur1UhW9afPitr3f +GO8knhsALIjPuT27faMBv6/dGHdrFWU99gmoLHSBT61wzFv8tzscfvKcCMUZzg2I +buo6oTaebNFqcrDh0wmGTOE3IVBuq13gOYTNXvReLHLO3GZsQ1V81286sJzfj94l +HirvDlgQYzBQg+Knv/PP+K2qyuTTHj9UXWUTEw6KF/x19iep0Xf5J3LCgF/lQLgB +TIVL/cWBAgMBAAECggEAAn9H/s6NN+Hf5B3pn1rDy56yzFuvYqpqG/HWmo1zEUht +vx5xstiFY2OutHgDgEP3b+0PHkrfxoFb7QWu5T5iYPy6UQlsMZ/WefJeJHN1btpj +321Hw24a9p5x05EMiOsNZtmasXRLH66fkKYGYaF2bF8QtS60Fa2AL1G6DTPqg3s4 +T+ijNYPr1xUk5GSh8Ea0DjLhzL6WgSHj+eBKgfEdYPDlOaQaYQuV2OJg9JyqxV6h +/Fa1HDc6RgpIhalLhP+9OqhSr9vmXSzEidzu+WTQSPpabwlVIae30Qh8XT9bYF5v +TElDXv5e5FwFmIJTnhAHyGlpnJ3KzaEHkmGbAxLOQQKBgQD2P4++d0WzrugKnfpz +hMpIVwk4jl1l2LUe3LoKEtF85lj6NjmvUNEPfJ0MIwKAjQYZ9AJWgCPP2/kjDBRv +dwwtSDIjFf79y810MNTGhAKv8nf7Lf5tSiJbvWgwtiiqF/ivUlxOKL9jqc6qj2s9 +psFoPOSAHQz6NqNpGyNza/7+CQKBgQDsojNWLJUXVzeUCMCzF+tn8lgs1aGrjHB7 +ZMHpr5nZCBdXjAzZR6yQH653Fa3OzNnVjq8CiO1ZdvbwW/KgVUHB4Mb/4kJ0Uxbm +WOF7zQjsMleoABFTi5mCcSqEK+u1qnrG8Ful9L6F8WhP7mdDmRXQM3f9rG2NDb1H +/OJuj/LpuQKBgQDK0+31Z069QtsUK62oSv9G+JG6yOC7S/Vbt1lxhLCSnTU620FG +W13n0K+W2JtuATq+U9M9JozY4ApkyMVoTnl0LtxFNA/1QlI3WyVXYlLIVAJpnSfN +I1wLjoZsYQ47lEUdO8yWAFAsqih1Km6duGXkEwvvTn5q9mhA4b6giprc6QKBgQCR +knMcd068ziXdxsitJHDoQHkoE8BiZYIpFuIIHcP6dPTPIdQhsusguqy8i7Sh/Pmh +XCaj25KQMBRX52jKY8iROfOSJSIWp6r1yAXnAEqV655rNqdyCvZD/dRW/SIDXz4q +tmDbJkYy5kDys0oJltqJe7A8eV/nn2UrLRIrTBj22QKBgQCFMmXVRqRje9k0Aqfe +KGYYCEPzeFzY4PzufwoOyhsGkLCwKthf43jXjWy53+u82Od1oKiNCjIhQHOtL720 +mTIhl2AzTJ1VMWoqUIHtGxhaIC3zhDjAaTMHZNDXFU78hPOhcBPtKikh3Hj2bfGG +TK1KTG49VMcWHmYJhJXwVevKAg== +-----END PRIVATE KEY----- diff --git a/selfservice/flow/saml/test/testdata/registration.schema.json b/selfservice/flow/saml/test/testdata/registration.schema.json new file mode 100644 index 000000000000..c7005d87ce8d --- /dev/null +++ b/selfservice/flow/saml/test/testdata/registration.schema.json @@ -0,0 +1,16 @@ +{ + "$id": "https://example.com/registration.schema.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Person", + "type": "object", + "properties": { + "traits": { + "type": "object", + "properties": { + "bar": { + "type": "string" + } + } + } + } +} diff --git a/selfservice/flow/saml/test/testdata/saml.jsonnet b/selfservice/flow/saml/test/testdata/saml.jsonnet new file mode 100644 index 000000000000..87103e26bc6b --- /dev/null +++ b/selfservice/flow/saml/test/testdata/saml.jsonnet @@ -0,0 +1,17 @@ +local claims = { + email_verified: false +} + std.extVar('claims'); + +{ + identity: { + traits: { + // Allowing unverified email addresses enables account + // enumeration attacks, especially if the value is used for + // e.g. verification or as a password login identifier. + // + // Therefore we only return the email if it (a) exists and (b) is marked verified + // by Discord. + [if "email" in claims && claims.email_verified then "email" else null]: claims.email, + }, + }, +} \ No newline at end of file diff --git a/selfservice/flow/saml/test/testdata/samlkratos.crt b/selfservice/flow/saml/test/testdata/samlkratos.crt new file mode 100755 index 000000000000..3dfdeb703e1c --- /dev/null +++ b/selfservice/flow/saml/test/testdata/samlkratos.crt @@ -0,0 +1,21 @@ +-----BEGIN CERTIFICATE----- +MIIDazCCAlOgAwIBAgIUVREfiVXf4z/hq8AsbyNnkuWn6i8wDQYJKoZIhvcNAQEL +BQAwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoM +GEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDAeFw0yMjAyMjExMTA4MjBaFw0yMzAy +MjExMTA4MjBaMEUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEw +HwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQwggEiMA0GCSqGSIb3DQEB +AQUAA4IBDwAwggEKAoIBAQCjvij3wZV+OhbEbwcs7cpc1hGR+uK4Y0y/ItHkAqlV +ddl+D28iDJeHci4LA8XmG0loFMTxdC9PG5t4ewn8G18+EeYRV0K3BMMWfxrO6ibG +z1ElTxQvVSw9tgPpjIgZqL8Qso8UO1ji98yoPhqP77F29pCNqiHrKJI1c52OCPHq +NBCZa76DmCGcXKAwRQaTo+tig6HJ1/3qCLGq57O396mQRFvjB535mceLzKSpFHsh +45beytXiBjTkvOEmNIUGVKIidXxqDtuTHz5QqhHTHMSsFH8cT648sSB9K9jPZ6ai +VCq5z/McyaYFlb/wt7PApJTSRjU0Any4876eBca59ca/AgMBAAGjUzBRMB0GA1Ud +DgQWBBQml5ORluABegdU+rLlpn++esD9fjAfBgNVHSMEGDAWgBQml5ORluABegdU ++rLlpn++esD9fjAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQCL +X5bpRKtMY7FsPtMsO/KBz5GT7P6aqe8pS0m3uXap6KkQwxa2wyyyH+in6uds8Sxm +bsdsGpSpCfGQCMqmu0yCjhfwI8nFA6q1YxLNgmx7kEIAQQQG2+jZJE7adXzSk2vT +tiNQ55mfiO9Wv+JpaB7ldAX3Q+O2uqVLJG/NlvC3ZAq0FXMyeitddLYSmEE0xrcM +QTB7vb7LpZk7Owa2UJ2VcQyZcxLWMonikIg4u3ALHGR0SvEgMwGhWr354RDGLYSO +Ii5O1foUR1O71jffr7CgELauyz3AXv6PNYLkyOCQP5gNB2NEMLJBRn5U4IhCHKzD +t1/BujsTuZV5r6aj3J9+ +-----END CERTIFICATE----- diff --git a/selfservice/strategy/saml/error.go b/selfservice/strategy/saml/error.go new file mode 100644 index 000000000000..f6ffa6f44226 --- /dev/null +++ b/selfservice/strategy/saml/error.go @@ -0,0 +1,8 @@ +package saml + +import "github.com/ory/herodot" + +var ( + ErrAPIFlowNotSupported = herodot.ErrBadRequest.WithError("API-based flows are not supported for this method"). + WithReasonf("SAML SignIn and Registeration are only supported for flows initiated using the Browser endpoint.") +) diff --git a/selfservice/strategy/saml/provider.go b/selfservice/strategy/saml/provider.go new file mode 100644 index 000000000000..59e6b5dbaad9 --- /dev/null +++ b/selfservice/strategy/saml/provider.go @@ -0,0 +1,41 @@ +package saml + +import ( + "context" + + "github.com/crewjam/saml/samlsp" + + "github.com/ory/kratos/driver/config" + "github.com/ory/kratos/x" +) + +type Provider interface { + Claims(ctx context.Context, config *config.Config, SAMLAttribute samlsp.Attributes) (*Claims, error) + Config() *Configuration +} + +type Claims struct { + Issuer string `json:"iss,omitempty"` + Subject string `json:"sub,omitempty"` + Name string `json:"name,omitempty"` + GivenName string `json:"given_name,omitempty"` + FamilyName string `json:"family_name,omitempty"` + LastName string `json:"last_name,omitempty"` + MiddleName string `json:"middle_name,omitempty"` + Nickname string `json:"nickname,omitempty"` + PreferredUsername string `json:"preferred_username,omitempty"` + Profile string `json:"profile,omitempty"` + Picture string `json:"picture,omitempty"` + Website string `json:"website,omitempty"` + Email string `json:"email,omitempty"` + EmailVerified x.ConvertibleBoolean `json:"email_verified,omitempty"` + Gender string `json:"gender,omitempty"` + Birthdate string `json:"birthdate,omitempty"` + Zoneinfo string `json:"zoneinfo,omitempty"` + Locale string `json:"locale,omitempty"` + PhoneNumber string `json:"phone_number,omitempty"` + PhoneNumberVerified bool `json:"phone_number_verified,omitempty"` + UpdatedAt int64 `json:"updated_at,omitempty"` + HD string `json:"hd,omitempty"` + Team string `json:"team,omitempty"` +} diff --git a/selfservice/strategy/saml/provider_config.go b/selfservice/strategy/saml/provider_config.go new file mode 100644 index 000000000000..a5015d54ee32 --- /dev/null +++ b/selfservice/strategy/saml/provider_config.go @@ -0,0 +1,34 @@ +package saml + +type Configuration struct { + // Provider's ID + ID string `json:"id"` + + // An optional label which can be used in the UI generation. + Label string `json:"label"` + + // Path of the certificate of your application + PublicCertPath string `json:"public_cert_path"` + + // Path of the private key of your application + PrivateKeyPath string `json:"private_key_path"` + + // Map where you have to name the attributes contained in the SAML response to associate them with their value + AttributesMap map[string]string `json:"attributes_map"` + + // Information about the IDP like the sso url, slo url, entiy ID, metadata url + IDPInformation map[string]string `json:"idp_information"` + + // Mapper specifies the JSONNet code snippet + // It can be either a URL (file://, http(s)://, base64://) or an inline JSONNet code snippet. + Mapper string `json:"mapper_url"` +} + +type ConfigurationCollection struct { + SAMLProviders []Configuration `json:"providers"` +} + +func (c ConfigurationCollection) Provider(id string, label string) (Provider, error) { + return NewProviderSAML(id, label, &c.SAMLProviders[len(c.SAMLProviders)-1]), nil + +} diff --git a/selfservice/strategy/saml/provider_saml.go b/selfservice/strategy/saml/provider_saml.go new file mode 100644 index 000000000000..15906baccaa5 --- /dev/null +++ b/selfservice/strategy/saml/provider_saml.go @@ -0,0 +1,63 @@ +package saml + +import ( + "bytes" + "context" + + "github.com/crewjam/saml/samlsp" + "github.com/pkg/errors" + + "github.com/ory/kratos/driver/config" + "github.com/ory/x/jsonx" +) + +type ProviderSAML struct { + id string + label string + config *Configuration +} + +func NewProviderSAML( + id string, + label string, + config *Configuration, +) *ProviderSAML { + return &ProviderSAML{ + id: id, + label: label, + config: config, + } +} + +// Translate attributes from saml asseryion into kratos claims +func (d *ProviderSAML) Claims(ctx context.Context, config *config.Config, SAMLAttribute samlsp.Attributes) (*Claims, error) { + + var c ConfigurationCollection + + conf := config.SelfServiceStrategy("saml").Config + if err := jsonx. + NewStrictDecoder(bytes.NewBuffer(conf)). + Decode(&c); err != nil { + return nil, errors.Wrapf(err, "Unable to decode config %v", string(conf)) + } + + claims := &Claims{ + Issuer: "saml", + Subject: SAMLAttribute.Get(c.SAMLProviders[len(c.SAMLProviders)-1].AttributesMap["id"]), + Name: SAMLAttribute.Get(c.SAMLProviders[len(c.SAMLProviders)-1].AttributesMap["firstname"]), + LastName: SAMLAttribute.Get(c.SAMLProviders[len(c.SAMLProviders)-1].AttributesMap["lastname"]), + Nickname: SAMLAttribute.Get(c.SAMLProviders[len(c.SAMLProviders)-1].AttributesMap["nickname"]), + Gender: SAMLAttribute.Get(c.SAMLProviders[len(c.SAMLProviders)-1].AttributesMap["gender"]), + Birthdate: SAMLAttribute.Get(c.SAMLProviders[len(c.SAMLProviders)-1].AttributesMap["birthdate"]), + Picture: SAMLAttribute.Get(c.SAMLProviders[len(c.SAMLProviders)-1].AttributesMap["picture"]), + Email: SAMLAttribute.Get(c.SAMLProviders[len(c.SAMLProviders)-1].AttributesMap["email"]), + PhoneNumber: SAMLAttribute.Get(c.SAMLProviders[len(c.SAMLProviders)-1].AttributesMap["phone_number"]), + EmailVerified: true, + } + + return claims, nil +} + +func (d *ProviderSAML) Config() *Configuration { + return d.config +} diff --git a/selfservice/strategy/saml/strategy/strategy.go b/selfservice/strategy/saml/strategy/strategy.go new file mode 100644 index 000000000000..3e52c03a39b1 --- /dev/null +++ b/selfservice/strategy/saml/strategy/strategy.go @@ -0,0 +1,355 @@ +package strategy + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "net/http" + "strings" + + "github.com/crewjam/saml" + "github.com/crewjam/saml/samlsp" + "github.com/julienschmidt/httprouter" + "github.com/pkg/errors" + "github.com/tidwall/gjson" + + "github.com/ory/herodot" + "github.com/ory/kratos/text" + "github.com/ory/kratos/ui/container" + "github.com/ory/kratos/ui/node" + + "github.com/go-playground/validator/v10" + + "github.com/ory/x/decoderx" + "github.com/ory/x/fetcher" + "github.com/ory/x/jsonx" + + "github.com/ory/kratos/continuity" + "github.com/ory/kratos/driver/config" + "github.com/ory/kratos/hash" + "github.com/ory/kratos/identity" + "github.com/ory/kratos/selfservice/errorx" + "github.com/ory/kratos/selfservice/flow" + "github.com/ory/kratos/selfservice/flow/login" + + "github.com/ory/kratos/selfservice/flow/registration" + samlflow "github.com/ory/kratos/selfservice/flow/saml" + "github.com/ory/kratos/selfservice/flow/settings" + "github.com/ory/kratos/selfservice/strategy" + samlstrategy "github.com/ory/kratos/selfservice/strategy/saml" + "github.com/ory/kratos/session" + "github.com/ory/kratos/x" +) + +const ( + RouteBase = "/self-service/methods/saml" + + RouteAcs = RouteBase + "/acs" + RouteAuth = RouteBase + "/auth" +) + +var _ identity.ActiveCredentialsCounter = new(Strategy) + +type registrationStrategyDependencies interface { + x.LoggingProvider + x.WriterProvider + x.CSRFTokenGeneratorProvider + x.CSRFProvider + + config.Provider + + continuity.ManagementProvider + + errorx.ManagementProvider + hash.HashProvider + + registration.HandlerProvider + registration.HooksProvider + registration.ErrorHandlerProvider + registration.HookExecutorProvider + registration.FlowPersistenceProvider + + login.HooksProvider + login.ErrorHandlerProvider + login.HookExecutorProvider + login.FlowPersistenceProvider + login.HandlerProvider + + settings.FlowPersistenceProvider + settings.HookExecutorProvider + settings.HooksProvider + settings.ErrorHandlerProvider + + identity.PrivilegedPoolProvider + identity.ValidationProvider + + session.HandlerProvider + session.ManagementProvider +} + +func (s *Strategy) ID() identity.CredentialsType { + return identity.CredentialsTypeSAML +} + +func (s *Strategy) D() registrationStrategyDependencies { + return s.d +} + +func (s *Strategy) NodeGroup() node.UiNodeGroup { + return node.SAMLGroup +} + +func uid(provider, subject string) string { + return fmt.Sprintf("%s:%s", provider, subject) +} + +type Strategy struct { + d registrationStrategyDependencies + f *fetcher.Fetcher + v *validator.Validate + hd *decoderx.HTTP +} + +func NewStrategy(d registrationStrategyDependencies) *Strategy { + return &Strategy{ + d: d, + f: fetcher.NewFetcher(), + v: validator.New(), + hd: decoderx.NewHTTP(), + } +} + +// We indicate here that when the ACS endpoint receives a POST request, we call the handleCallback method to process it +func (s *Strategy) setRoutes(r *x.RouterPublic) { + wrappedHandleCallback := strategy.IsDisabled(s.d, s.ID().String(), s.handleCallback) + if handle, _, _ := r.Lookup("POST", RouteAcs); handle == nil { + r.POST(RouteAcs, wrappedHandleCallback) + } // ACS SUPPORT +} + +// Get possible SAML Request IDs +func GetPossibleRequestIDs(r *http.Request, m samlsp.Middleware) []string { + possibleRequestIDs := []string{} + if m.ServiceProvider.AllowIDPInitiated { + possibleRequestIDs = append(possibleRequestIDs, "") + } + + trackedRequests := m.RequestTracker.GetTrackedRequests(r) + for _, tr := range trackedRequests { + possibleRequestIDs = append(possibleRequestIDs, tr.SAMLRequestID) + } + + return possibleRequestIDs +} + +// Retrieves the user's attributes from the SAML Assertion +func (s *Strategy) GetAttributesFromAssertion(assertion *saml.Assertion) (map[string][]string, error) { + + if assertion == nil { + return nil, errors.New("The assertion is nil") + } + + attributes := map[string][]string{} + + for _, attributeStatement := range assertion.AttributeStatements { + for _, attr := range attributeStatement.Attributes { + claimName := attr.Name + for _, value := range attr.Values { + attributes[claimName] = append(attributes[claimName], value.Value) + } + } + } + + return attributes, nil +} + +// Handle /selfservice/methods/saml/acs | Receive SAML response, parse the attributes and start auth flow +func (s *Strategy) handleCallback(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { + if err := r.ParseForm(); err != nil { + s.forwardError(w, r, err) + } + + m, err := samlflow.GetMiddleware() + if err != nil { + s.forwardError(w, r, err) + } + + // We get the possible SAML request IDs + possibleRequestIDs := GetPossibleRequestIDs(r, *m) + assertion, err := m.ServiceProvider.ParseResponse(r, possibleRequestIDs) + if err != nil { + s.forwardError(w, r, err) + } + + // We get the user's attributes from the SAML Response (assertion) + attributes, err := s.GetAttributesFromAssertion(assertion) + if err != nil { + s.forwardError(w, r, err) + return + } + + // We get the provider information from the config file + provider, err := s.Provider(r.Context()) + if err != nil { + s.forwardError(w, r, err) + return + } + + // We translate SAML Attributes into claims (To create an identity we need these claims) + claims, err := provider.Claims(r.Context(), s.d.Config(r.Context()), attributes) + if err != nil { + s.forwardError(w, r, err) + return + } + + // Now that we have the claims and the provider, we have to decide if we log or register the user + if ff, err := s.processLoginOrRegister(w, r, provider, claims); err != nil { + if ff != nil { + s.forwardError(w, r, err) + } + s.forwardError(w, r, err) + } +} + +func (s *Strategy) forwardError(w http.ResponseWriter, r *http.Request, err error) { + s.d.LoginFlowErrorHandler().WriteFlowError(w, r, nil, s.NodeGroup(), err) +} + +// Return the SAML Provider +func (s *Strategy) Provider(ctx context.Context) (samlstrategy.Provider, error) { + c, err := s.Config(ctx) + if err != nil { + return nil, err + } + + provider, err := c.Provider(c.SAMLProviders[len(c.SAMLProviders)-1].ID, c.SAMLProviders[len(c.SAMLProviders)-1].Label) + if err != nil { + return nil, err + } + + return provider, nil +} + +// Translate YAML Config file into a SAML Provider struct +func (s *Strategy) Config(ctx context.Context) (*samlstrategy.ConfigurationCollection, error) { + var c samlstrategy.ConfigurationCollection + + conf := s.d.Config(ctx).SelfServiceStrategy(string(s.ID())).Config + if err := jsonx. + NewStrictDecoder(bytes.NewBuffer(conf)). + Decode(&c); err != nil { + s.d.Logger().WithError(err).WithField("config", conf) + return nil, errors.WithStack(herodot.ErrInternalServerError.WithReasonf("Unable to decode SAML Identity Provider configuration: %s", err)) + } + + return &c, nil +} + +func (s *Strategy) populateMethod(r *http.Request, c *container.Container, message func(provider string) *text.Message) error { + _, err := s.Config(r.Context()) + if err != nil { + return err + } + + // does not need sorting because there is only one field + c.SetCSRF(s.d.GenerateCSRFToken(r)) + + return nil +} + +func (s *Strategy) handleError(w http.ResponseWriter, r *http.Request, f flow.Flow, provider string, traits []byte, err error) error { + switch rf := f.(type) { + case *login.Flow: + return err + case *registration.Flow: + // Reset all nodes to not confuse users. + // This is kinda hacky and will probably need to be updated at some point. + + rf.UI.Nodes = node.Nodes{} + + // Adds the "Continue" button + rf.UI.SetCSRF(s.d.GenerateCSRFToken(r)) + AddProvider(rf.UI, provider, text.NewInfoRegistrationContinue()) + + if traits != nil { + ds, err := s.d.Config(r.Context()).DefaultIdentityTraitsSchemaURL() + if err != nil { + return err + } + + traitNodes, err := container.NodesFromJSONSchema(r.Context(), node.SAMLGroup, ds.String(), "", nil) + if err != nil { + return err + } + + rf.UI.Nodes = append(rf.UI.Nodes, traitNodes...) + rf.UI.UpdateNodeValuesFromJSON(traits, "traits", node.SAMLGroup) + } + + return err + } + + return err +} + +func (s *Strategy) CountActiveCredentials(cc map[identity.CredentialsType]identity.Credentials) (int, error) { + count := 0 + for _, c := range cc { + if c.Type == s.ID() && gjson.ValidBytes(c.Config) { + var conf CredentialsConfig + if err := json.Unmarshal(c.Config, &conf); err != nil { + return 0, errors.WithStack(err) + } + + for _, ider := range c.Identifiers { + parts := strings.Split(ider, ":") + if len(parts) != 2 { + continue + } + + if parts[0] == conf.Providers[0].Provider && parts[1] == conf.Providers[0].Subject && len(conf.Providers[0].Subject) > 1 && len(conf.Providers[0].Provider) > 1 { + count++ + } + + } + } + } + return count, nil +} + +func (s *Strategy) CountActiveFirstFactorCredentials(cc map[identity.CredentialsType]identity.Credentials) (count int, err error) { + for _, c := range cc { + if c.Type == s.ID() && gjson.ValidBytes(c.Config) { + var conf identity.CredentialsSAML + if err = json.Unmarshal(c.Config, &conf); err != nil { + return 0, errors.WithStack(err) + } + + for _, ider := range c.Identifiers { + parts := strings.Split(ider, ":") + if len(parts) != 2 { + continue + } + + for _, prov := range conf.Providers { + if parts[0] == prov.Provider && parts[1] == prov.Subject && len(prov.Subject) > 1 && len(prov.Provider) > 1 { + count++ + } + } + } + } + } + return +} + +func (s *Strategy) CountActiveMultiFactorCredentials(cc map[identity.CredentialsType]identity.Credentials) (count int, err error) { + return 0, nil +} + +func (s *Strategy) CompletedAuthenticationMethod(ctx context.Context) session.AuthenticationMethod { + return session.AuthenticationMethod{ + Method: s.ID(), + AAL: identity.AuthenticatorAssuranceLevel1, + } +} diff --git a/selfservice/strategy/saml/strategy/strategy_auth.go b/selfservice/strategy/saml/strategy/strategy_auth.go new file mode 100644 index 000000000000..5a297ec85a6b --- /dev/null +++ b/selfservice/strategy/saml/strategy/strategy_auth.go @@ -0,0 +1,56 @@ +package strategy + +import ( + "errors" + "net/http" + + "github.com/ory/kratos/identity" + "github.com/ory/kratos/selfservice/flow" + samlsp "github.com/ory/kratos/selfservice/strategy/saml" + "github.com/ory/x/sqlcon" +) + +// Handle SAML Assertion and process to either login or register +func (s *Strategy) processLoginOrRegister(w http.ResponseWriter, r *http.Request, provider samlsp.Provider, claims *samlsp.Claims) (*flow.Flow, error) { + + // This is a check to see if the user exists in the database + i, c, err := s.d.PrivilegedIdentityPool().FindByCredentialsIdentifier(r.Context(), identity.CredentialsTypeSAML, uid(provider.Config().ID, claims.Subject)) + + if err != nil { + // ErrNoRows is returned when a SQL SELECT statement returns no rows. + if errors.Is(err, sqlcon.ErrNoRows) { + + // The user doesn't net existe yet so we register him + registerFlow, err := s.d.RegistrationHandler().NewRegistrationFlow(w, r, flow.TypeBrowser) + if err != nil { + if i == nil { + return nil, s.handleError(w, r, registerFlow, provider.Config().ID, nil, err) + } + return nil, s.handleError(w, r, registerFlow, provider.Config().ID, i.Traits, err) + + } + + if err = s.processRegistration(w, r, registerFlow, provider, claims); err != nil { + if i == nil { + return nil, s.handleError(w, r, registerFlow, provider.Config().ID, nil, err) + } + return nil, s.handleError(w, r, registerFlow, provider.Config().ID, i.Traits, err) + + } + return nil, nil + + } + return nil, err + + } + // The user already exist in database so we log him + loginFlow, err := s.d.LoginHandler().NewLoginFlow(w, r, flow.TypeBrowser) + if err != nil { + return nil, s.handleError(w, r, loginFlow, provider.Config().ID, i.Traits, err) + } + if _, err = s.processLogin(w, r, loginFlow, provider, c, i, claims); err != nil { + return nil, s.handleError(w, r, loginFlow, provider.Config().ID, i.Traits, err) + } + return nil, nil + +} diff --git a/selfservice/strategy/saml/strategy/strategy_login.go b/selfservice/strategy/saml/strategy/strategy_login.go new file mode 100644 index 000000000000..82537965910f --- /dev/null +++ b/selfservice/strategy/saml/strategy/strategy_login.go @@ -0,0 +1,64 @@ +package strategy + +import ( + "bytes" + "encoding/json" + "net/http" + + "github.com/pkg/errors" + + "github.com/ory/herodot" + "github.com/ory/kratos/identity" + "github.com/ory/kratos/selfservice/flow" + "github.com/ory/kratos/selfservice/flow/login" + "github.com/ory/kratos/selfservice/flow/registration" + samlsp "github.com/ory/kratos/selfservice/strategy/saml" + "github.com/ory/kratos/session" + "github.com/ory/kratos/text" + "github.com/ory/kratos/x" +) + +// Implement the interface +var _ login.Strategy = new(Strategy) + +//Call at the creation of Kratos, when Kratos implement all authentication routes +func (s *Strategy) RegisterLoginRoutes(r *x.RouterPublic) { + s.setRoutes(r) +} + +//Login and give a session to the user +func (s *Strategy) processLogin(w http.ResponseWriter, r *http.Request, a *login.Flow, provider samlsp.Provider, c *identity.Credentials, i *identity.Identity, claims *samlsp.Claims) (*registration.Flow, error) { + + var o CredentialsConfig + if err := json.NewDecoder(bytes.NewBuffer(c.Config)).Decode(&o); err != nil { + return nil, s.handleError(w, r, a, provider.Config().ID, nil, errors.WithStack(herodot.ErrInternalServerError.WithReason("The password credentials could not be decoded properly").WithDebug(err.Error()))) + } + + sess := session.NewInactiveSession() //creation of an inactive session + sess.CompletedLoginFor(s.ID(), identity.AuthenticatorAssuranceLevel1) //Add saml to the Authentication Method References + + if err := s.d.LoginHookExecutor().PostLoginHook(w, r, a, i, sess); err != nil { + return nil, s.handleError(w, r, a, provider.Config().ID, nil, err) + } + + return nil, nil +} + +// Method not used but necessary to implement the interface +func (s *Strategy) Login(w http.ResponseWriter, r *http.Request, f *login.Flow, ss *session.Session) (i *identity.Identity, err error) { + return nil, nil +} + +// Method not used but necessary to implement the interface +func (s *Strategy) PopulateLoginMethod(r *http.Request, requestedAAL identity.AuthenticatorAssuranceLevel, l *login.Flow) error { + if l.Type != flow.TypeBrowser { + return nil + } + + // This strategy can only solve AAL1 + if requestedAAL > identity.AuthenticatorAssuranceLevel1 { + return nil + } + + return s.populateMethod(r, l.UI, text.NewInfoLoginWith) +} diff --git a/selfservice/strategy/saml/strategy/strategy_registration.go b/selfservice/strategy/saml/strategy/strategy_registration.go new file mode 100644 index 000000000000..0ca9534e93ea --- /dev/null +++ b/selfservice/strategy/saml/strategy/strategy_registration.go @@ -0,0 +1,132 @@ +package strategy + +import ( + "bytes" + "context" + "encoding/json" + "net/http" + + "github.com/google/go-jsonnet" + + "github.com/ory/kratos/driver/config" + "github.com/ory/kratos/identity" + + "github.com/ory/kratos/selfservice/flow" + "github.com/ory/kratos/selfservice/flow/registration" + samlsp "github.com/ory/kratos/selfservice/strategy/saml" + "github.com/ory/kratos/text" + + "github.com/tidwall/gjson" + + "github.com/ory/kratos/x" +) + +// Implement the interface +var _ registration.Strategy = new(Strategy) + +//Call at the creation of Kratos, when Kratos implement all authentication routes +func (s *Strategy) RegisterRegistrationRoutes(r *x.RouterPublic) { + s.setRoutes(r) +} + +func (s *Strategy) GetRegistrationIdentity(r *http.Request, ctx context.Context, provider samlsp.Provider, claims *samlsp.Claims, logsEnabled bool) (*identity.Identity, error) { + // Fetch fetches the file contents from the mapper file. + jn, err := s.f.Fetch(provider.Config().Mapper) + if err != nil { + return nil, err + } + + var jsonClaims bytes.Buffer + if err := json.NewEncoder(&jsonClaims).Encode(claims); err != nil { + return nil, err + } + + // Identity Creation + i := identity.NewIdentity(config.DefaultIdentityTraitsSchemaID) + + vm := jsonnet.MakeVM() + vm.ExtCode("claims", jsonClaims.String()) + evaluated, err := vm.EvaluateAnonymousSnippet(provider.Config().Mapper, jn.String()) + if err != nil { + return nil, err + } else if traits := gjson.Get(evaluated, "identity.traits"); !traits.IsObject() { + i.Traits = []byte{'{', '}'} + if logsEnabled { + s.d.Logger(). + WithRequest(r). + WithField("Provider", provider.Config().ID). + WithSensitiveField("saml_claims", claims). + WithField("mapper_jsonnet_output", evaluated). + WithField("mapper_jsonnet_url", provider.Config().Mapper). + Error("SAML Jsonnet mapper did not return an object for key identity.traits. Please check your Jsonnet code!") + } + } else { + i.Traits = []byte(traits.Raw) + } + + if logsEnabled { + s.d.Logger(). + WithRequest(r). + WithField("saml_provider", provider.Config().ID). + WithSensitiveField("saml_claims", claims). + WithSensitiveField("mapper_jsonnet_output", evaluated). + WithField("mapper_jsonnet_url", provider.Config().Mapper). + Debug("SAML Jsonnet mapper completed.") + + s.d.Logger(). + WithRequest(r). + WithField("saml_provider", provider.Config().ID). + WithSensitiveField("identity_traits", i.Traits). + WithSensitiveField("mapper_jsonnet_output", evaluated). + WithField("mapper_jsonnet_url", provider.Config().Mapper). + Debug("Merged form values and SAML Jsonnet output.") + } + + // Verify the identity + if err := s.d.IdentityValidator().Validate(ctx, i); err != nil { + return i, err + } + + // Create new uniq credentials identifier for user is database + creds, err := NewCredentialsForSAML(claims.Subject, provider.Config().ID) + if err != nil { + return i, err + } + + // Set the identifiers to the identity + i.SetCredentials(s.ID(), *creds) + + return i, nil +} + +func (s *Strategy) processRegistration(w http.ResponseWriter, r *http.Request, a *registration.Flow, provider samlsp.Provider, claims *samlsp.Claims) error { + + i, err := s.GetRegistrationIdentity(r, r.Context(), provider, claims, true) + if err != nil { + if i == nil { + return s.handleError(w, r, a, provider.Config().ID, nil, err) + } else { + return s.handleError(w, r, a, provider.Config().ID, i.Traits, err) + } + } + + if err := s.d.RegistrationExecutor().PostRegistrationHook(w, r, identity.CredentialsTypeSAML, a, i); err != nil { + return s.handleError(w, r, a, provider.Config().ID, i.Traits, err) + } + + return nil +} + +// Method not used but necessary to implement the interface +func (s *Strategy) PopulateRegistrationMethod(r *http.Request, f *registration.Flow) error { + if f.Type != flow.TypeBrowser { + return nil + } + + return s.populateMethod(r, f.UI, text.NewInfoRegistrationWith) +} + +// Method not used but necessary to implement the interface +func (s *Strategy) Register(w http.ResponseWriter, r *http.Request, f *registration.Flow, i *identity.Identity) (err error) { + return nil +} diff --git a/selfservice/strategy/saml/strategy/test/strategy_test.go b/selfservice/strategy/saml/strategy/test/strategy_test.go new file mode 100644 index 000000000000..88d4d8931fe1 --- /dev/null +++ b/selfservice/strategy/saml/strategy/test/strategy_test.go @@ -0,0 +1,191 @@ +package strategy_test + +import ( + "bytes" + "context" + "encoding/json" + "regexp" + "testing" + + "github.com/ory/kratos/identity" + samlhandler "github.com/ory/kratos/selfservice/flow/saml" + helpertest "github.com/ory/kratos/selfservice/flow/saml/helpertest" + samlstrategy "github.com/ory/kratos/selfservice/strategy/saml/strategy" + "github.com/stretchr/testify/require" + + "gotest.tools/assert" + gotest "gotest.tools/assert" + is "gotest.tools/assert/cmp" +) + +func TestGetAndDecryptAssertion(t *testing.T) { + if testing.Short() { + t.Skip() + } + + samlhandler.DestroyMiddlewareIfExists() + + middleware, _, _, _ := helpertest.InitMiddlewareWithMetadata(t, + "file://testdata/idp_saml_metadata.xml") + + assertion, err := helpertest.GetAndDecryptAssertion(t, "./testdata/SP_SamlResponse.xml", middleware.ServiceProvider.Key) + + require.NoError(t, err) + assert.Check(t, assertion != nil) +} + +func TestGetAttributesFromAssertion(t *testing.T) { + if testing.Short() { + t.Skip() + } + + samlhandler.DestroyMiddlewareIfExists() + + middleware, strategy, _, _ := helpertest.InitMiddlewareWithMetadata(t, + "file://testdata/idp_saml_metadata.xml") + + assertion, _ := helpertest.GetAndDecryptAssertion(t, "./testdata/SP_SamlResponse.xml", middleware.ServiceProvider.Key) + + mapAttributes, err := strategy.GetAttributesFromAssertion(assertion) + + require.NoError(t, err) + assert.Check(t, mapAttributes["urn:oid:0.9.2342.19200300.100.1.1"][0] == "myself") + assert.Check(t, mapAttributes["urn:oid:1.3.6.1.4.1.5923.1.1.1.1"][0] == "Member") + assert.Check(t, mapAttributes["urn:oid:1.3.6.1.4.1.5923.1.1.1.1"][1] == "Staff") + assert.Check(t, mapAttributes["urn:oid:1.3.6.1.4.1.5923.1.1.1.6"][0] == "myself@testshib.org") + assert.Check(t, mapAttributes["urn:oid:2.5.4.4"][0] == "And I") + assert.Check(t, mapAttributes["urn:oid:1.3.6.1.4.1.5923.1.1.1.9"][0] == "Member@testshib.org") + assert.Check(t, mapAttributes["urn:oid:1.3.6.1.4.1.5923.1.1.1.9"][1] == "Staff@testshib.org") + assert.Check(t, mapAttributes["urn:oid:2.5.4.42"][0] == "Me Myself") + assert.Check(t, mapAttributes["urn:oid:1.3.6.1.4.1.5923.1.1.1.7"][0] == "urn:mace:dir:entitlement:common-lib-terms") + assert.Check(t, mapAttributes["urn:oid:2.5.4.3"][0] == "Me Myself And I") + assert.Check(t, mapAttributes["urn:oid:2.5.4.20"][0] == "555-5555") + + t.Log(mapAttributes) +} + +func TestCreateAuthRequest(t *testing.T) { + if testing.Short() { + t.Skip() + } + + samlhandler.DestroyMiddlewareIfExists() + + middleware, _, _, _ := helpertest.InitMiddlewareWithMetadata(t, + "file://testdata/idp_saml_metadata.xml") + + authReq, err := middleware.ServiceProvider.MakeAuthenticationRequest("https://samltest.id/idp/profile/SAML2/Redirect/SSO", "saml.HTTPPostBinding", "saml.HTTPPostBinding") + require.NoError(t, err) + + matchACS, err := regexp.MatchString(`http://127.0.0.1:\d{5}/self-service/methods/saml/acs`, authReq.AssertionConsumerServiceURL) + require.NoError(t, err) + gotest.Check(t, matchACS) + + matchMetadata, err := regexp.MatchString(`http://127.0.0.1:\d{5}/self-service/methods/saml/metadata`, authReq.Issuer.Value) + require.NoError(t, err) + gotest.Check(t, matchMetadata) + + gotest.Check(t, is.Equal(authReq.Destination, "https://samltest.id/idp/profile/SAML2/Redirect/SSO")) +} + +func TestProvider(t *testing.T) { + if testing.Short() { + t.Skip() + } + + samlhandler.DestroyMiddlewareIfExists() + + _, strategy, _, _ := helpertest.InitMiddlewareWithMetadata(t, + "file://testdata/idp_saml_metadata.xml") + + provider, err := strategy.Provider(context.Background()) + require.NoError(t, err) + gotest.Check(t, provider != nil) + gotest.Check(t, provider.Config().ID == "samlProviderTestID") + gotest.Check(t, provider.Config().Label == "samlProviderTestLabel") +} + +func TestConfig(t *testing.T) { + if testing.Short() { + t.Skip() + } + + samlhandler.DestroyMiddlewareIfExists() + + _, strategy, _, _ := helpertest.InitMiddlewareWithMetadata(t, + "file://testdata/idp_saml_metadata.xml") + + config, err := strategy.Config(context.Background()) + require.NoError(t, err) + gotest.Check(t, config != nil) + gotest.Check(t, len(config.SAMLProviders) == 2) + gotest.Check(t, config.SAMLProviders[0].ID == "samlProviderTestID") + gotest.Check(t, config.SAMLProviders[0].Label == "samlProviderTestLabel") +} + +func TestID(t *testing.T) { + if testing.Short() { + t.Skip() + } + + samlhandler.DestroyMiddlewareIfExists() + + _, strategy, _, _ := helpertest.InitMiddlewareWithMetadata(t, + "file://testdata/idp_saml_metadata.xml") + + id := strategy.ID() + gotest.Check(t, id == "saml") +} + +func TestCountActiveCredentials(t *testing.T) { + if testing.Short() { + t.Skip() + } + + samlhandler.DestroyMiddlewareIfExists() + + _, strategy, _, _ := helpertest.InitMiddlewareWithMetadata(t, + "file://testdata/idp_saml_metadata.xml") + + mapCredentials := make(map[identity.CredentialsType]identity.Credentials) + + var b bytes.Buffer + err := json.NewEncoder(&b).Encode(samlstrategy.CredentialsConfig{ + Providers: []samlstrategy.ProviderCredentialsConfig{ + { + Subject: "testUserID", + Provider: "saml", + }}, + }) + require.NoError(t, err) + + mapCredentials[identity.CredentialsTypeSAML] = identity.Credentials{ + Type: identity.CredentialsTypeSAML, + Identifiers: []string{"saml:testUserID"}, + Config: b.Bytes(), + } + + count, err := strategy.CountActiveCredentials(mapCredentials) + require.NoError(t, err) + gotest.Check(t, count == 1) +} + +func TestGetRegistrationIdentity(t *testing.T) { + if testing.Short() { + t.Skip() + } + + samlhandler.DestroyMiddlewareIfExists() + + middleware, strategy, _, _ := helpertest.InitMiddlewareWithMetadata(t, + "file://testdata/idp_saml_metadata.xml") + + provider, _ := strategy.Provider(context.Background()) + assertion, _ := helpertest.GetAndDecryptAssertion(t, "./testdata/SP_SamlResponse.xml", middleware.ServiceProvider.Key) + attributes, _ := strategy.GetAttributesFromAssertion(assertion) + claims, _ := provider.Claims(context.Background(), strategy.D().Config(context.Background()), attributes) + + i, err := strategy.GetRegistrationIdentity(nil, context.Background(), provider, claims, false) + require.NoError(t, err) + gotest.Check(t, i != nil) +} diff --git a/selfservice/strategy/saml/strategy/test/testdata/SP_IDPMetadata.xml b/selfservice/strategy/saml/strategy/test/testdata/SP_IDPMetadata.xml new file mode 100644 index 000000000000..dcaf7f051dae --- /dev/null +++ b/selfservice/strategy/saml/strategy/test/testdata/SP_IDPMetadata.xml @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + + testshib.org + + TestShib Test IdP + TestShib IdP. Use this as a source of attributes + for your test SP. + https://www.testshib.org/testshibtwo.jpg + + + + + + MIIEDjCCAvagAwIBAgIBADANBgkqhkiG9w0BAQUFADBnMQswCQYDVQQGEwJVUzEV + MBMGA1UECBMMUGVubnN5bHZhbmlhMRMwEQYDVQQHEwpQaXR0c2J1cmdoMREwDwYD + VQQKEwhUZXN0U2hpYjEZMBcGA1UEAxMQaWRwLnRlc3RzaGliLm9yZzAeFw0wNjA4 + MzAyMTEyMjVaFw0xNjA4MjcyMTEyMjVaMGcxCzAJBgNVBAYTAlVTMRUwEwYDVQQI + EwxQZW5uc3lsdmFuaWExEzARBgNVBAcTClBpdHRzYnVyZ2gxETAPBgNVBAoTCFRl + c3RTaGliMRkwFwYDVQQDExBpZHAudGVzdHNoaWIub3JnMIIBIjANBgkqhkiG9w0B + AQEFAAOCAQ8AMIIBCgKCAQEArYkCGuTmJp9eAOSGHwRJo1SNatB5ZOKqDM9ysg7C + yVTDClcpu93gSP10nH4gkCZOlnESNgttg0r+MqL8tfJC6ybddEFB3YBo8PZajKSe + 3OQ01Ow3yT4I+Wdg1tsTpSge9gEz7SrC07EkYmHuPtd71CHiUaCWDv+xVfUQX0aT + NPFmDixzUjoYzbGDrtAyCqA8f9CN2txIfJnpHE6q6CmKcoLADS4UrNPlhHSzd614 + kR/JYiks0K4kbRqCQF0Dv0P5Di+rEfefC6glV8ysC8dB5/9nb0yh/ojRuJGmgMWH + gWk6h0ihjihqiu4jACovUZ7vVOCgSE5Ipn7OIwqd93zp2wIDAQABo4HEMIHBMB0G + A1UdDgQWBBSsBQ869nh83KqZr5jArr4/7b+QazCBkQYDVR0jBIGJMIGGgBSsBQ86 + 9nh83KqZr5jArr4/7b+Qa6FrpGkwZzELMAkGA1UEBhMCVVMxFTATBgNVBAgTDFBl + bm5zeWx2YW5pYTETMBEGA1UEBxMKUGl0dHNidXJnaDERMA8GA1UEChMIVGVzdFNo + aWIxGTAXBgNVBAMTEGlkcC50ZXN0c2hpYi5vcmeCAQAwDAYDVR0TBAUwAwEB/zAN + BgkqhkiG9w0BAQUFAAOCAQEAjR29PhrCbk8qLN5MFfSVk98t3CT9jHZoYxd8QMRL + I4j7iYQxXiGJTT1FXs1nd4Rha9un+LqTfeMMYqISdDDI6tv8iNpkOAvZZUosVkUo + 93pv1T0RPz35hcHHYq2yee59HJOco2bFlcsH8JBXRSRrJ3Q7Eut+z9uo80JdGNJ4 + /SJy5UorZ8KazGj16lfJhOBXldgrhppQBb0Nq6HKHguqmwRfJ+WkxemZXzhediAj + Geka8nz8JjwxpUjAiSWYKLtJhGEaTqCYxCCX2Dw+dOTqUzHOZ7WKv4JXPK5G/Uhr + 8K/qhmFT2nIQi538n6rVYLeWj8Bbnl+ev0peYzxFyF5sQA== + + + + + + + + + + + + urn:mace:shibboleth:1.0:nameIdentifier + urn:oasis:names:tc:SAML:2.0:nameid-format:transient + + + + + + + + + + + + MIIEDjCCAvagAwIBAgIBADANBgkqhkiG9w0BAQUFADBnMQswCQYDVQQGEwJVUzEV + MBMGA1UECBMMUGVubnN5bHZhbmlhMRMwEQYDVQQHEwpQaXR0c2J1cmdoMREwDwYD + VQQKEwhUZXN0U2hpYjEZMBcGA1UEAxMQaWRwLnRlc3RzaGliLm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Z8KazGj16lfJhOBXldgrhppQBb0Nq6HKHguqmwRfJ+WkxemZXzhediAj + Geka8nz8JjwxpUjAiSWYKLtJhGEaTqCYxCCX2Dw+dOTqUzHOZ7WKv4JXPK5G/Uhr + 8K/qhmFT2nIQi538n6rVYLeWj8Bbnl+ev0peYzxFyF5sQA== + + + + + + + + + + + + urn:mace:shibboleth:1.0:nameIdentifier + urn:oasis:names:tc:SAML:2.0:nameid-format:transient + + + TestShib Two Identity Provider + TestShib Two + http://www.testshib.org/testshib-two/ + + + Nate + Klingenstein + ndk@internet2.edu + + \ No newline at end of file diff --git a/selfservice/strategy/saml/strategy/test/testdata/SP_SamlResponse.xml b/selfservice/strategy/saml/strategy/test/testdata/SP_SamlResponse.xml new file mode 100644 index 000000000000..f5dbc10766ab --- /dev/null +++ b/selfservice/strategy/saml/strategy/test/testdata/SP_SamlResponse.xml @@ -0,0 +1,38 @@ + + + https://idp.testshib.org/idp/shibboleth + + + + + + + + + + + + + + MIIB7zCCAVgCCQDFzbKIp7b3MTANBgkqhkiG9w0BAQUFADA8MQswCQYDVQQGEwJVUzELMAkGA1UE +CAwCR0ExDDAKBgNVBAoMA2ZvbzESMBAGA1UEAwwJbG9jYWxob3N0MB4XDTEzMTAwMjAwMDg1MVoX +DTE0MTAwMjAwMDg1MVowPDELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAkdBMQwwCgYDVQQKDANmb28x +EjAQBgNVBAMMCWxvY2FsaG9zdDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA1PMHYmhZj308 +kWLhZVT4vOulqx/9ibm5B86fPWwUKKQ2i12MYtz07tzukPymisTDhQaqyJ8Kqb/6JjhmeMnEOdTv +SPmHO8m1ZVveJU6NoKRn/mP/BD7FW52WhbrUXLSeHVSKfWkNk6S4hk9MV9TswTvyRIKvRsw0X/gf +nqkroJcCAwEAATANBgkqhkiG9w0BAQUFAAOBgQCMMlIO+GNcGekevKgkakpMdAqJfs24maGb90Dv +TLbRZRD7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mZoxtBhNBWvY3ZOVD/21dIUlQanG1n6RygbmAwCHnIB4c7EH2CBYEMDToRQuAuIssviIfdaJglwDgHbLWKNUVDOdqeclBNZjfQfVXbVukPk8DfWLqj9pD4xAOzDeVQcdmg2aLvNKgpZsWs4d+6GlKrpS7qEGvoBkIFh/cVY7DMYrt/JXYuF6DpwB+HbfnuDFc2p47SPNhnmt/ez6/DACBPQ+tgpyWYXUsiviGSp72JNTzd8uFJJZNeKUJZw1c0UTjxdwigh5tL/hWhPl48DY937zymSr1xVqC3RV6wSIpuplH+hss/rsRPAp1/TfxvhJuFsoPbW0586y9YzqEHT4FUu6WSRy0gMJLP2sLqiiZXZ6kPicXsW7M55mV3ugbGQjB7YS7EVqsQzvJTiQbOlcPqwoKK7DTqaeCOXd8kH1tNoe7hjx/UNNdLQQ7IhrJIzxqTTgwcXYMCxhoezDsIHReTIymsHPkCurfteTQcbfwoKN5E9zC2hINOPmhAxLvONzaLXQGMqofuTbFshkB4eUj8U4vBCNp+60iCLnibt4rPuyoWKEHWBYa6FfIykxVKuXkfcb64dCdGCWjv7x1XqkbpHxQB80qhipoSo244pyhIsN91ASu1Q7L75LxGXibY3jb0Y4KZ5zIWsH4kVlvPhangohDO1J9gmL9inGr9hy5BHTQiMcktGoUgOIbFJ72381vYpPxn3ngBbp48mVZd0w6xV8RBaqR3l7CxI9vvMAPYPoXBB18ERoZypza8mAlzv2QxIkNGuRzFENh1SXegBfN7eiazZnwnhbyeMghJpnXzfvHACyjkdH3shRYcJ+oMiOSpInGxm/hxFQxHJZA0Ft/lza + + + + \ No newline at end of file diff --git a/selfservice/strategy/saml/strategy/test/testdata/TestSPCanHandleOneloginResponse_response b/selfservice/strategy/saml/strategy/test/testdata/TestSPCanHandleOneloginResponse_response new file mode 100644 index 000000000000..1031d30218df --- /dev/null +++ b/selfservice/strategy/saml/strategy/test/testdata/TestSPCanHandleOneloginResponse_response @@ -0,0 +1 @@ +PHNhbWxwOlJlc3BvbnNlIHhtbG5zOnNhb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y/test/testdata/cert.pem b/selfservice/strategy/saml/strategy/test/testdata/cert.pem new file mode 100644 index 000000000000..52667ef39ff2 --- /dev/null +++ b/selfservice/strategy/saml/strategy/test/testdata/cert.pem @@ -0,0 +1,13 @@ +-----BEGIN CERTIFICATE----- +MIIB7zCCAVgCCQDFzbKIp7b3MTANBgkqhkiG9w0BAQUFADA8MQswCQYDVQQGEwJV +UzELMAkGA1UECAwCR0ExDDAKBgNVBAoMA2ZvbzESMBAGA1UEAwwJbG9jYWxob3N0 +MB4XDTEzMTAwMjAwMDg1MVoXDTE0MTAwMjAwMDg1MVowPDELMAkGA1UEBhMCVVMx +CzAJBgNVBAgMAkdBMQwwCgYDVQQKDANmb28xEjAQBgNVBAMMCWxvY2FsaG9zdDCB +nzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA1PMHYmhZj308kWLhZVT4vOulqx/9 +ibm5B86fPWwUKKQ2i12MYtz07tzukPymisTDhQaqyJ8Kqb/6JjhmeMnEOdTvSPmH +O8m1ZVveJU6NoKRn/mP/BD7FW52WhbrUXLSeHVSKfWkNk6S4hk9MV9TswTvyRIKv +Rsw0X/gfnqkroJcCAwEAATANBgkqhkiG9w0BAQUFAAOBgQCMMlIO+GNcGekevKgk +akpMdAqJfs24maGb90DvTLbRZRD7Xvn1MnVBBS9hzlXiFLYOInXACMW5gcoRFfeT +QLSouMM8o57h0uKjfTmuoWHLQLi6hnF+cvCsEFiJZ4AbF+DgmO6TarJ8O05t8zvn +OwJlNCASPZRH/JmF8tX0hoHuAQ== +-----END CERTIFICATE----- \ No newline at end of file diff --git a/selfservice/strategy/saml/strategy/test/testdata/idp_saml_metadata.xml b/selfservice/strategy/saml/strategy/test/testdata/idp_saml_metadata.xml new file mode 100644 index 000000000000..dcaf7f051dae --- /dev/null +++ b/selfservice/strategy/saml/strategy/test/testdata/idp_saml_metadata.xml @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + + testshib.org + + TestShib Test IdP + TestShib IdP. Use this as a source of attributes + for your test SP. + https://www.testshib.org/testshibtwo.jpg + + + + + + MIIEDjCCAvagAwIBAgIBADANBgkqhkiG9w0BAQUFADBnMQswCQYDVQQGEwJVUzEV + MBMGA1UECBMMUGVubnN5bHZhbmlhMRMwEQYDVQQHEwpQaXR0c2J1cmdoMREwDwYD + VQQKEwhUZXN0U2hpYjEZMBcGA1UEAxMQaWRwLnRlc3RzaGliLm9yZzAeFw0wNjA4 + MzAyMTEyMjVaFw0xNjA4MjcyMTEyMjVaMGcxCzAJBgNVBAYTAlVTMRUwEwYDVQQI + EwxQZW5uc3lsdmFuaWExEzARBgNVBAcTClBpdHRzYnVyZ2gxETAPBgNVBAoTCFRl + c3RTaGliMRkwFwYDVQQDExBpZHAudGVzdHNoaWIub3JnMIIBIjANBgkqhkiG9w0B + AQEFAAOCAQ8AMIIBCgKCAQEArYkCGuTmJp9eAOSGHwRJo1SNatB5ZOKqDM9ysg7C + yVTDClcpu93gSP10nH4gkCZOlnESNgttg0r+MqL8tfJC6ybddEFB3YBo8PZajKSe + 3OQ01Ow3yT4I+Wdg1tsTpSge9gEz7SrC07EkYmHuPtd71CHiUaCWDv+xVfUQX0aT + NPFmDixzUjoYzbGDrtAyCqA8f9CN2txIfJnpHE6q6CmKcoLADS4UrNPlhHSzd614 + kR/JYiks0K4kbRqCQF0Dv0P5Di+rEfefC6glV8ysC8dB5/9nb0yh/ojRuJGmgMWH + gWk6h0ihjihqiu4jACovUZ7vVOCgSE5Ipn7OIwqd93zp2wIDAQABo4HEMIHBMB0G + A1UdDgQWBBSsBQ869nh83KqZr5jArr4/7b+QazCBkQYDVR0jBIGJMIGGgBSsBQ86 + 9nh83KqZr5jArr4/7b+Qa6FrpGkwZzELMAkGA1UEBhMCVVMxFTATBgNVBAgTDFBl + bm5zeWx2YW5pYTETMBEGA1UEBxMKUGl0dHNidXJnaDERMA8GA1UEChMIVGVzdFNo + aWIxGTAXBgNVBAMTEGlkcC50ZXN0c2hpYi5vcmeCAQAwDAYDVR0TBAUwAwEB/zAN + BgkqhkiG9w0BAQUFAAOCAQEAjR29PhrCbk8qLN5MFfSVk98t3CT9jHZoYxd8QMRL + I4j7iYQxXiGJTT1FXs1nd4Rha9un+LqTfeMMYqISdDDI6tv8iNpkOAvZZUosVkUo + 93pv1T0RPz35hcHHYq2yee59HJOco2bFlcsH8JBXRSRrJ3Q7Eut+z9uo80JdGNJ4 + /SJy5UorZ8KazGj16lfJhOBXldgrhppQBb0Nq6HKHguqmwRfJ+WkxemZXzhediAj + Geka8nz8JjwxpUjAiSWYKLtJhGEaTqCYxCCX2Dw+dOTqUzHOZ7WKv4JXPK5G/Uhr + 8K/qhmFT2nIQi538n6rVYLeWj8Bbnl+ev0peYzxFyF5sQA== + + + + + + + + + + + + urn:mace:shibboleth:1.0:nameIdentifier + urn:oasis:names:tc:SAML:2.0:nameid-format:transient + + + + + + + + + + + + MIIEDjCCAvagAwIBAgIBADANBgkqhkiG9w0BAQUFADBnMQswCQYDVQQGEwJVUzEV + MBMGA1UECBMMUGVubnN5bHZhbmlhMRMwEQYDVQQHEwpQaXR0c2J1cmdoMREwDwYD + VQQKEwhUZXN0U2hpYjEZMBcGA1UEAxMQaWRwLnRlc3RzaGliLm9yZzAeFw0wNjA4 + MzAyMTEyMjVaFw0xNjA4MjcyMTEyMjVaMGcxCzAJBgNVBAYTAlVTMRUwEwYDVQQI + EwxQZW5uc3lsdmFuaWExEzARBgNVBAcTClBpdHRzYnVyZ2gxETAPBgNVBAoTCFRl + c3RTaGliMRkwFwYDVQQDExBpZHAudGVzdHNoaWIub3JnMIIBIjANBgkqhkiG9w0B + AQEFAAOCAQ8AMIIBCgKCAQEArYkCGuTmJp9eAOSGHwRJo1SNatB5ZOKqDM9ysg7C + yVTDClcpu93gSP10nH4gkCZOlnESNgttg0r+MqL8tfJC6ybddEFB3YBo8PZajKSe + 3OQ01Ow3yT4I+Wdg1tsTpSge9gEz7SrC07EkYmHuPtd71CHiUaCWDv+xVfUQX0aT + NPFmDixzUjoYzbGDrtAyCqA8f9CN2txIfJnpHE6q6CmKcoLADS4UrNPlhHSzd614 + kR/JYiks0K4kbRqCQF0Dv0P5Di+rEfefC6glV8ysC8dB5/9nb0yh/ojRuJGmgMWH + gWk6h0ihjihqiu4jACovUZ7vVOCgSE5Ipn7OIwqd93zp2wIDAQABo4HEMIHBMB0G + A1UdDgQWBBSsBQ869nh83KqZr5jArr4/7b+QazCBkQYDVR0jBIGJMIGGgBSsBQ86 + 9nh83KqZr5jArr4/7b+Qa6FrpGkwZzELMAkGA1UEBhMCVVMxFTATBgNVBAgTDFBl + bm5zeWx2YW5pYTETMBEGA1UEBxMKUGl0dHNidXJnaDERMA8GA1UEChMIVGVzdFNo + aWIxGTAXBgNVBAMTEGlkcC50ZXN0c2hpYi5vcmeCAQAwDAYDVR0TBAUwAwEB/zAN + BgkqhkiG9w0BAQUFAAOCAQEAjR29PhrCbk8qLN5MFfSVk98t3CT9jHZoYxd8QMRL + I4j7iYQxXiGJTT1FXs1nd4Rha9un+LqTfeMMYqISdDDI6tv8iNpkOAvZZUosVkUo + 93pv1T0RPz35hcHHYq2yee59HJOco2bFlcsH8JBXRSRrJ3Q7Eut+z9uo80JdGNJ4 + /SJy5UorZ8KazGj16lfJhOBXldgrhppQBb0Nq6HKHguqmwRfJ+WkxemZXzhediAj + Geka8nz8JjwxpUjAiSWYKLtJhGEaTqCYxCCX2Dw+dOTqUzHOZ7WKv4JXPK5G/Uhr + 8K/qhmFT2nIQi538n6rVYLeWj8Bbnl+ev0peYzxFyF5sQA== + + + + + + + + + + + + urn:mace:shibboleth:1.0:nameIdentifier + urn:oasis:names:tc:SAML:2.0:nameid-format:transient + + + TestShib Two Identity Provider + TestShib Two + http://www.testshib.org/testshib-two/ + + + Nate + Klingenstein + ndk@internet2.edu + + \ No newline at end of file diff --git a/selfservice/strategy/saml/strategy/test/testdata/key.pem b/selfservice/strategy/saml/strategy/test/testdata/key.pem new file mode 100644 index 000000000000..48284dac33a1 --- /dev/null +++ b/selfservice/strategy/saml/strategy/test/testdata/key.pem @@ -0,0 +1,15 @@ +-----BEGIN RSA PRIVATE KEY----- +MIICXgIBAAKBgQDU8wdiaFmPfTyRYuFlVPi866WrH/2JubkHzp89bBQopDaLXYxi +3PTu3O6Q/KaKxMOFBqrInwqpv/omOGZ4ycQ51O9I+Yc7ybVlW94lTo2gpGf+Y/8E +PsVbnZaFutRctJ4dVIp9aQ2TpLiGT0xX1OzBO/JEgq9GzDRf+B+eqSuglwIDAQAB +AoGBAMuy1eN6cgFiCOgBsB3gVDdTKpww87Qk5ivjqEt28SmXO13A1KNVPS6oQ8SJ +CT5Azc6X/BIAoJCURVL+LHdqebogKljhH/3yIel1kH19vr4E2kTM/tYH+qj8afUS +JEmArUzsmmK8ccuNqBcllqdwCZjxL4CHDUmyRudFcHVX9oyhAkEA/OV1OkjM3CLU +N3sqELdMmHq5QZCUihBmk3/N5OvGdqAFGBlEeewlepEVxkh7JnaNXAXrKHRVu/f/ +fbCQxH+qrwJBANeQERF97b9Sibp9xgolb749UWNlAdqmEpmlvmS202TdcaaT1msU +4rRLiQN3X9O9mq4LZMSVethrQAdX1whawpkCQQDk1yGf7xZpMJ8F4U5sN+F4rLyM +Rq8Sy8p2OBTwzCUXXK+fYeXjybsUUMr6VMYTRP2fQr/LKJIX+E5ZxvcIyFmDAkEA +yfjNVUNVaIbQTzEbRlRvT6MqR+PTCefC072NF9aJWR93JimspGZMR7viY6IM4lrr +vBkm0F5yXKaYtoiiDMzlOQJADqmEwXl0D72ZG/2KDg8b4QZEmC9i5gidpQwJXUc6 +hU+IVQoLxRq0fBib/36K9tcrrO5Ba4iEvDcNY+D8yGbUtA== +-----END RSA PRIVATE KEY----- \ No newline at end of file diff --git a/selfservice/strategy/saml/strategy/test/testdata/myservice.cert b/selfservice/strategy/saml/strategy/test/testdata/myservice.cert new file mode 100755 index 000000000000..a815f8f44742 --- /dev/null +++ b/selfservice/strategy/saml/strategy/test/testdata/myservice.cert @@ -0,0 +1,19 @@ +-----BEGIN C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5cbtUtOIbrZ6kdBs49O27xCTymaIuysidFtywwTaDdrc1g== +-----END CERTIFICATE----- diff --git a/selfservice/strategy/saml/strategy/test/testdata/myservice.key b/selfservice/strategy/saml/strategy/test/testdata/myservice.key new file mode 100755 index 000000000000..e7b461f2f228 --- /dev/null +++ b/selfservice/strategy/saml/strategy/test/testdata/myservice.key @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDjnp4eGltNpugk +P0i6tUhqR1vhjUK0zVxYSB4MH+jC76HXemqP7CT/UCUVQ0hgp/Mk2Y/4Kgm/mlK9 +R4lox0Du8pQIc8xjtI2hl1pfR4ZXhn1DtDqlKRX6F6hqaiOX4ur1UhW9afPitr3f +GO8knhsALIjPuT27faMBv6/dGHdrFWU99gmoLHSBT61wzFv8tzscfvKcCMUZzg2I +buo6oTaebNFqcrDh0wmGTOE3IVBuq13gOYTNXvReLHLO3GZsQ1V81286sJzfj94l +HirvDlgQYzBQg+Knv/PP+K2qyuTTHj9UXWUTEw6KF/x19iep0Xf5J3LCgF/lQLgB +TIVL/cWBAgMBAAECggEAAn9H/s6NN+Hf5B3pn1rDy56yzFuvYqpqG/HWmo1zEUht +vx5xstiFY2OutHgDgEP3b+0PHkrfxoFb7QWu5T5iYPy6UQlsMZ/WefJeJHN1btpj +321Hw24a9p5x05EMiOsNZtmasXRLH66fkKYGYaF2bF8QtS60Fa2AL1G6DTPqg3s4 +T+ijNYPr1xUk5GSh8Ea0DjLhzL6WgSHj+eBKgfEdYPDlOaQaYQuV2OJg9JyqxV6h +/Fa1HDc6RgpIhalLhP+9OqhSr9vmXSzEidzu+WTQSPpabwlVIae30Qh8XT9bYF5v +TElDXv5e5FwFmIJTnhAHyGlpnJ3KzaEHkmGbAxLOQQKBgQD2P4++d0WzrugKnfpz +hMpIVwk4jl1l2LUe3LoKEtF85lj6NjmvUNEPfJ0MIwKAjQYZ9AJWgCPP2/kjDBRv +dwwtSDIjFf79y810MNTGhAKv8nf7Lf5tSiJbvWgwtiiqF/ivUlxOKL9jqc6qj2s9 +psFoPOSAHQz6NqNpGyNza/7+CQKBgQDsojNWLJUXVzeUCMCzF+tn8lgs1aGrjHB7 +ZMHpr5nZCBdXjAzZR6yQH653Fa3OzNnVjq8CiO1ZdvbwW/KgVUHB4Mb/4kJ0Uxbm +WOF7zQjsMleoABFTi5mCcSqEK+u1qnrG8Ful9L6F8WhP7mdDmRXQM3f9rG2NDb1H +/OJuj/LpuQKBgQDK0+31Z069QtsUK62oSv9G+JG6yOC7S/Vbt1lxhLCSnTU620FG +W13n0K+W2JtuATq+U9M9JozY4ApkyMVoTnl0LtxFNA/1QlI3WyVXYlLIVAJpnSfN +I1wLjoZsYQ47lEUdO8yWAFAsqih1Km6duGXkEwvvTn5q9mhA4b6giprc6QKBgQCR +knMcd068ziXdxsitJHDoQHkoE8BiZYIpFuIIHcP6dPTPIdQhsusguqy8i7Sh/Pmh +XCaj25KQMBRX52jKY8iROfOSJSIWp6r1yAXnAEqV655rNqdyCvZD/dRW/SIDXz4q +tmDbJkYy5kDys0oJltqJe7A8eV/nn2UrLRIrTBj22QKBgQCFMmXVRqRje9k0Aqfe +KGYYCEPzeFzY4PzufwoOyhsGkLCwKthf43jXjWy53+u82Od1oKiNCjIhQHOtL720 +mTIhl2AzTJ1VMWoqUIHtGxhaIC3zhDjAaTMHZNDXFU78hPOhcBPtKikh3Hj2bfGG +TK1KTG49VMcWHmYJhJXwVevKAg== +-----END PRIVATE KEY----- diff --git a/selfservice/strategy/saml/strategy/test/testdata/registration.schema.json b/selfservice/strategy/saml/strategy/test/testdata/registration.schema.json new file mode 100644 index 000000000000..c7005d87ce8d --- /dev/null +++ b/selfservice/strategy/saml/strategy/test/testdata/registration.schema.json @@ -0,0 +1,16 @@ +{ + "$id": "https://example.com/registration.schema.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Person", + "type": "object", + "properties": { + "traits": { + "type": "object", + "properties": { + "bar": { + "type": "string" + } + } + } + } +} diff --git a/selfservice/strategy/saml/strategy/test/testdata/saml.jsonnet b/selfservice/strategy/saml/strategy/test/testdata/saml.jsonnet new file mode 100644 index 000000000000..87103e26bc6b --- /dev/null +++ b/selfservice/strategy/saml/strategy/test/testdata/saml.jsonnet @@ -0,0 +1,17 @@ +local claims = { + email_verified: false +} + std.extVar('claims'); + +{ + identity: { + traits: { + // Allowing unverified email addresses enables account + // enumeration attacks, especially if the value is used for + // e.g. verification or as a password login identifier. + // + // Therefore we only return the email if it (a) exists and (b) is marked verified + // by Discord. + [if "email" in claims && claims.email_verified then "email" else null]: claims.email, + }, + }, +} \ No newline at end of file diff --git a/selfservice/strategy/saml/strategy/test/testdata/saml_response.xml b/selfservice/strategy/saml/strategy/test/testdata/saml_response.xml new file mode 100644 index 000000000000..22ea0920a014 --- /dev/null +++ b/selfservice/strategy/saml/strategy/test/testdata/saml_response.xml @@ -0,0 +1,11 @@ +https://idp.testshib.org/idp/shibbolethMIIB7zCCAVgCCQDFzbKIp7b3MTANBgkqhkiG9w0BAQUFADA8MQswCQYDVQQGEwJVUzELMAkGA1UE +CAwCR0ExDDAKBgNVBAoMA2ZvbzESMBAGA1UEAwwJbG9jYWxob3N0MB4XDTEzMTAwMjAwMDg1MVoX +DTE0MTAwMjAwMDg1MVowPDELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAkdBMQwwCgYDVQQKDANmb28x +EjAQBgNVBAMMCWxvY2FsaG9zdDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA1PMHYmhZj308 +kWLhZVT4vOulqx/9ibm5B86fPWwUKKQ2i12MYtz07tzukPymisTDhQaqyJ8Kqb/6JjhmeMnEOdTv +SPmHO8m1ZVveJU6NoKRn/mP/BD7FW52WhbrUXLSeHVSKfWkNk6S4hk9MV9TswTvyRIKvRsw0X/gf +nqkroJcCAwEAATANBgkqhkiG9w0BAQUFAAOBgQCMMlIO+GNcGekevKgkakpMdAqJfs24ma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wZCYd5mZoxtBhNBWvY3ZOVD/21dIUlQanG1n6RygbmAwCHnIB4c7EH2CBYEMDToRQuAuIssviIfdaJglwDgHbLWKNUVDOdqeclBNZjfQfVXbVukPk8DfWLqj9pD4xAOzDeVQcdmg2aLvNKgpZsWs4d+6GlKrpS7qEGvoBkIFh/cVY7DMYrt/JXYuF6DpwB+HbfnuDFc2p47SPNhnmt/ez6/DACBPQ+tgpyWYXUsiviGSp72JNTzd8uFJJZNeKUJZw1c0UTjxdwigh5tL/hWhPl48DY937zymSr1xVqC3RV6wSIpuplH+hss/rsRPAp1/TfxvhJuFsoPbW0586y9YzqEHT4FUu6WSRy0gMJLP2sLqiiZXZ6kPicXsW7M55mV3ugbGQjB7YS7EVqsQzvJTiQbOlcPqwoKK7DTqaeCOXd8kH1tNoe7hjx/UNNdLQQ7IhrJIzxqTTgwcXYMCxhoezDsIHReTIymsHPkCurfteTQcbfwoKN5E9zC2hINOPmhAxLvONzaLXQGMqofuTbFshkB4eUj8U4vBCNp+60iCLnibt4rPuyoWKEHWBYa6FfIykxVKuXkfcb64dCdGCWjv7x1XqkbpHxQB80qhipoSo244pyhIsN91ASu1Q7L75LxGXibY3jb0Y4KZ5zIWsH4kVlvPhangohDO1J9gmL9inGr9hy5BHTQiMcktGoUgOIbFJ72381vYpPxn3ngBbp48mVZd0w6xV8RBaqR3l7CxI9vvMAPYPoXBB18ERoZypza8mAlzv2QxIkNGuRzFENh1SXegBfN7eiazZnwnhbyeMghJpnXzfvHACyjkdH3shRYcJ+oMiOSpInGxm/hxFQxHJZA0Ft/lza \ No newline at end of file diff --git a/selfservice/strategy/saml/strategy/test/testdata/samlkratos.crt b/selfservice/strategy/saml/strategy/test/testdata/samlkratos.crt new file mode 100755 index 000000000000..3dfdeb703e1c --- /dev/null +++ b/selfservice/strategy/saml/strategy/test/testdata/samlkratos.crt @@ -0,0 +1,21 @@ +-----BEGIN CERTIFICATE----- +MIIDazCCAlOgAwIBAgIUVREfiVXf4z/hq8AsbyN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r7CgELauyz3AXv6PNYLkyOCQP5gNB2NEMLJBRn5U4IhCHKzD +t1/BujsTuZV5r6aj3J9+ +-----END CERTIFICATE----- diff --git a/selfservice/strategy/saml/strategy/types.go b/selfservice/strategy/saml/strategy/types.go new file mode 100644 index 000000000000..3c8ad11cca2d --- /dev/null +++ b/selfservice/strategy/saml/strategy/types.go @@ -0,0 +1,54 @@ +package strategy + +import ( + "bytes" + "encoding/json" + + "github.com/ory/kratos/identity" + "github.com/ory/kratos/text" + "github.com/ory/kratos/ui/container" + "github.com/ory/kratos/ui/node" + "github.com/ory/kratos/x" + + "github.com/pkg/errors" +) + +type CredentialsConfig struct { + Providers []ProviderCredentialsConfig `json:"providers"` +} + +//Create an uniq identifier for user in database. Its look like "id + the id of the saml provider" +func NewCredentialsForSAML(subject string, provider string) (*identity.Credentials, error) { + var b bytes.Buffer + if err := json.NewEncoder(&b).Encode(CredentialsConfig{ + Providers: []ProviderCredentialsConfig{ + { + Subject: subject, + Provider: provider, + }}, + }); err != nil { + return nil, errors.WithStack(x.PseudoPanic. + WithDebugf("Unable to encode password options to JSON: %s", err)) + } + + return &identity.Credentials{ + Type: identity.CredentialsTypeSAML, + Identifiers: []string{uid(provider, subject)}, + Config: b.Bytes(), + }, nil +} + +func AddProvider(c *container.Container, providerID string, message *text.Message) { + c.GetNodes().Append( + node.NewInputField("provider", providerID, node.SAMLGroup, node.InputAttributeTypeSubmit).WithMetaLabel(message), + ) +} + +type ProviderCredentialsConfig struct { + Subject string `json:"subject"` + Provider string `json:"provider"` +} + +type FlowMethod struct { + *container.Container +} diff --git a/spec/api.json b/spec/api.json index 3bb775b9de8c..1a809c5aaae7 100755 --- a/spec/api.json +++ b/spec/api.json @@ -998,6 +998,23 @@ ], "type": "object" }, + "selfServiceSamlUrl": { + "properties": { + "saml_acs_url": { + "description": "SamlAcsURL is a post endpoint to handle SAML Response\n\nformat: uri", + "type": "string" + }, + "saml_metadata_url": { + "description": "SamlMetadataURL is a get endpoint to get the metadata\n\nformat: uri", + "type": "string" + } + }, + "required": [ + "saml_metadata_url", + "saml_acs_url" + ], + "type": "object" + }, "selfServiceSettingsFlow": { "description": "This flow is used when an identity wants to update settings\n(e.g. profile data, passwords, ...) in a selfservice manner.\n\nWe recommend reading the [User Settings Documentation](../self-service/flows/user-settings)", "properties": { diff --git a/spec/swagger.json b/spec/swagger.json index 0b07a3bf30d3..974bbfe80a76 100755 --- a/spec/swagger.json +++ b/spec/swagger.json @@ -1187,6 +1187,40 @@ } } }, + "/self-service/methods/saml/browser": { + "get": { + "description": "This endpoint allows to initialize a saml SSO connection by redirecting the user to the IDP. ", + "schemes": [ + "http", + "https" + ], + "tags": [ + "v0alpha2" + ], + "summary": "Initialize Authentication Flow for SAML", + "operationId": "initializeSelfServiceSamlFlowForBrowsers", + "responses": { + "200": { + "description": "selfServiceRegistrationFlow", + "schema": { + "$ref": "#/definitions/selfServiceRegistrationFlow" + } + }, + "400": { + "description": "jsonError", + "schema": { + "$ref": "#/definitions/jsonError" + } + }, + "500": { + "description": "jsonError", + "schema": { + "$ref": "#/definitions/jsonError" + } + } + } + } + }, "/self-service/recovery": { "post": { "description": "Use this endpoint to complete a recovery flow. This endpoint\nbehaves differently for API and browser flows and has several states:\n\n`choose_method` expects `flow` (in the URL query) and `email` (in the body) to be sent\nand works with API- and Browser-initiated flows.\nFor API clients and Browser clients with HTTP Header `Accept: application/json` it either returns a HTTP 200 OK when the form is valid and HTTP 400 OK when the form is invalid.\nand a HTTP 303 See Other redirect with a fresh recovery flow if the flow was otherwise invalid (e.g. expired).\nFor Browser clients without HTTP Header `Accept` or with `Accept: text/*` it returns a HTTP 303 See Other redirect to the Recovery UI URL with the Recovery Flow ID appended.\n`sent_email` is the success state after `choose_method` for the `link` method and allows the user to request another recovery email. It\nworks for both API and Browser-initiated flows and returns the same responses as the flow in `choose_method` state.\n`passed_challenge` expects a `token` to be sent in the URL query and given the nature of the flow (\"sending a recovery link\")\ndoes not have any API capabilities. The server responds with a HTTP 303 See Other redirect either to the Settings UI URL\n(if the link was valid) and instructs the user to update their password, or a redirect to the Recover UI URL with\na new Recovery Flow ID which contains an error message that the recovery link was invalid.\n\nMore information can be found at [Ory Kratos Account Recovery Documentation](../self-service/flows/account-recovery).", @@ -3318,6 +3352,23 @@ } } }, + "selfServiceSamlUrl": { + "type": "object", + "required": [ + "saml_metadata_url", + "saml_acs_url" + ], + "properties": { + "saml_acs_url": { + "description": "SamlAcsURL is a post endpoint to handle SAML Response\n\nformat: uri", + "type": "string" + }, + "saml_metadata_url": { + "description": "SamlMetadataURL is a get endpoint to get the metadata\n\nformat: uri", + "type": "string" + } + } + }, "selfServiceSettingsFlow": { "description": "This flow is used when an identity wants to update settings\n(e.g. profile data, passwords, ...) in a selfservice manner.\n\nWe recommend reading the [User Settings Documentation](../self-service/flows/user-settings)", "type": "object", diff --git a/ui/node/node.go b/ui/node/node.go index edc38c6c2488..d57d0daea25a 100644 --- a/ui/node/node.go +++ b/ui/node/node.go @@ -44,6 +44,7 @@ const ( TOTPGroup UiNodeGroup = "totp" LookupGroup UiNodeGroup = "lookup_secret" WebAuthnGroup UiNodeGroup = "webauthn" + SAMLGroup UiNodeGroup = "saml" ) func (g UiNodeGroup) String() string {