Hi everyone, I want to create a basic authenticati...
# talk-kratos
w
Hi everyone, I want to create a basic authentication system using only username and password for both login and registration in Next.js 13. However, I am new to Kratos and facing some issues. If anyone could guide me, it would be very helpful. I want to create a self-service authentication. I have these files right now config file
Copy code
version: v0.13.0

dsn: memory

serve:
  public:
    base_url: <http://127.0.0.1:4433/>
    cors:
      enabled: true
      allow_credentials: true
      allowed_origins:
        - <http://127.0.0.1:4433>
        - http://*127.0.0.1:4433
        - <http://localhost:3000>
        - http://*.localhost:3000
      allowed_methods:
        - POST
        - GET
        - PUT
        - PATCH
        - DELETE
      allowed_headers:
        - Authorization
        - Cookie
        - Content-Type
        - X-Session-Token
        - X-Csrf-Token
      exposed_headers:
        - Content-Type
        - Set-Cookie
      debug: true
  admin:
    base_url: <http://0.0.0.0:4434/>

selfservice:
  default_browser_return_url: <http://localhost:3000/>
  allowed_return_urls:
    - <http://localhost:3000>

  methods:
    password:
      enabled: true

  flows:
    login:
      ui_url: <http://localhost:3000/auth/login>

    registration:
      ui_url: <http://localhost:3000/auth/registration>

    settings:
      ui_url: <http://localhost:3000/auth/settings>

    recovery:
      enabled: false
      
log:
  level: debug

secrets:
  cookie:
    - PLEASE-CHANGE-ME-I-AM-VERY-INSECURE

identity:
  default_schema_id: default
  schemas:
    - id: default
      url: file:///etc/config/kratos/identity.schema.json

courier:
  smtp:
    connection_uri: <smtps://test:test@mailslurper:1025/?skip_ssl_verify=true>
identity schema
Copy code
{
  "$id": "<https://schemas.ory.sh/presets/kratos/quickstart/username-password/identity.schema.json>",
  "$schema": "<http://json-schema.org/draft-07/schema#>",
  "title": "UsernamePassword",
  "type": "object",
  "properties": {
    "traits": {
      "type": "object",
      "properties": {
        "username": {
          "type": "string",
          "format": "string",
          "title": "username",
          "minLength": 8,
          "maxLength": 30,
          "<http://ory.sh/kratos|ory.sh/kratos>": {
            "credentials": {
              "password": {
                "identifier": true
              }
            }
          }
        }
      },
      "required": [
        "username"
      ],
      "additionalProperties": false
    }
  }
}
I have also added [...path].ts file in apis and i am using this command to run kratos
Copy code
command: ["kratos migrate sql up -y -e && kratos serve -c /etc/config/kratos/kratos.yml --watch-courier --sqa-opt-out"]