ory / kratos

The most scalable and customizable identity server on the market. Replace your Homegrown, Auth0, Okta, Firebase with better UX and DX. Has all the tablestakes: Passkeys, Social Sign In, Multi-Factor Auth, SMS, SAML, TOTP, and more. Written in Go, cloud native, headless, API-first. Available as a service on Ory Network and for self-hosters.
https://www.ory.sh/?utm_source=github&utm_medium=banner&utm_campaign=kratos
Apache License 2.0
11.24k stars 963 forks source link

Default email templates as well as custom ones add '\n' at the end of subject #2491

Closed alexeevaDariaIDT closed 2 years ago

alexeevaDariaIDT commented 2 years ago

Preflight checklist

Describe the bug

I was testing out "recovery flow" and noticed how valid and invalid 'recovery' emails get a '\n' at the end of the message subject.

Reproducing the bug

  1. Spin up a kratos version v0.9.0-alpha.2
  2. Enable verification via email
  3. Go to the /recovery page and pass the email
  4. Get the to the sent message, it will have an Account access attempted\n as subject

I'd expect the default and templated version of the mail to not add an extra symbol in the message subject.

Screen Shot 2022-05-27 at 18 02 23

Relevant log output

{"audience":"application","file":"/project/courier/smtp.go:189","func":"github.com/ory/kratos/courier.(*courier).dispatchEmail","level":"debug","message_id":"713cf496-2a8f-4011-8960-50f1502283eb","m │
│ essage_subject":"Account access attempted\n","message_template_type":"recovery_invalid","message_type":1,"msg":"Courier sent out message.","service_name":"Ory Kratos","service_version":"v0.9.0-alpha │
│ .2","time":"2022-05-27T14:44:24Z"}                                                                                                                                                                     │
│ {"audience":"application","file":"/project/courier/courier_dispatcher.go:37","func":"github.com/ory/kratos/courier.(*courier).DispatchMessage","level":"debug","message_id":"713cf496-2a8f-4011-8960-5 │
│ 0f1502283eb","message_subject":"Account access attempted\n","message_template_type":"recovery_invalid","message_type":1,"msg":"Courier sent out message.","service_name":"Ory Kratos","service_version │
│ ":"v0.9.0-alpha.2","time":"2022-05-27T14:44:24Z"}

Relevant configuration

{
                "$id": "https://schemas.ory.sh/presets/kratos/quickstart/email-password/identity.schema.json",
                "$schema": "http://json-schema.org/draft-07/schema#",
                "title": "Person",
                "type": "object",
                "properties": {
                  "traits": {
                    "type": "object",
                    "properties": {
                      "email": {
                        "type": "string",
                        "format": "email",
                        "title": "E-Mail",
                        "minLength": 3,
                        "ory.sh/kratos": {
                          "credentials": {
                            "password": {
                              "identifier": true
                            }
                          },
                          "verification": {
                            "via": "email"
                          },
                          "recovery": {
                            "via": "email"
                          }
                        }
                      },
                      "name": {
                        "type": "object",
                        "properties": {
                          "first": {
                            "title": "First Name",
                            "type": "string"
                          },
                          "last": {
                            "title": "Last Name",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "required": [
                      "email"
                    ],
                    "additionalProperties": false
                  }
                }
              }

Version

v0.9.0-alpha.2

On which operating system are you observing this issue?

macOS

In which environment are you deploying?

Kubernetes with Helm

Additional Context

No response

aeneasr commented 2 years ago

Thank you for the report, that does look like a bug. Any volunteers who want to take this up please take a look :)