apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: kratos-app
  namespace: argocd
spec:
  syncPolicy:
    automated:
      prune: true
      enabled: true
  project: default
  source:
    chart: kratos
    repoURL: 'https://k8s.ory.sh/helm/charts'
    targetRevision: 0.58.0
    helm:
      valuesObject:
        deployment:
          extraVolumes:
            - name: kratos-custom-config
              configMap:
                name: kratos-config
          extraVolumeMounts:
            - name: kratos-custom-config
              mountPath: /etc/config/custom
              readOnly: true
          extraEnv:
            - name: DSN
              valueFrom:
                secretKeyRef:
                  name: postgres-kratos-app
                  key: uri
        kratos:
          # config db
          automization:
            enabled: true
          config:
            dsn: 
              valueFrom:
                secretKeyRef:
                  name: postgres-kratos-app
                  key: uri
            selfservice:
              methods:
                code:
                  enabled: true
                  passwordless_enabled: true
                  lifespan: 2m
                password:
                  enabled: true
              default_browser_return_url: "http://localhost:4433"
              flows:
                login:
                  ui_url: "http://localhost:5200/auth/login"
                registration:
                  after:
                    password:
                      hooks:
                        - hook: session
                    code:
                      hooks:
                        - hook: session
                  ui_url: "http://localhost:5200/auth/register"
                verification:
                  ui_url: "http://localhost:5200/auth/verify"
                  enabled: true
            identity:
              default_schema_id: default
              schemas:
                - id: default
                  url: file:///etc/config/custom/identity.schema.json
            courier:
              channels:
                - id: sms
                  type: http
                  request_config:
                    method: POST
                    url: https://webhook.site/b9e137a6-f184-47b5-ac43-50c95a95cd14
                    body: base64://ZnVuY3Rpb24oY3R4KSB7CiAgcmVjaXBpZW50OiBjdHgucmVjaXBpZW50LAogIHRlbXBsYXRlX3R5cGU6IGN0eC50ZW1wbGF0ZV90eXBlLAogIHRvOiBpZiAidGVtcGxhdGVfZGF0YSIgaW4gY3R4ICYmICJ0byIgaW4gY3R4LnRlbXBsYXRlX2RhdGEgdGhlbiBjdHgudGVtcGxhdGVfZGF0YS50byBlbHNlIG51bGwsCiAgcmVjb3ZlcnlfY29kZTogaWYgInRlbXBsYXRlX2RhdGEiIGluIGN0eCAmJiAicmVjb3ZlcnlfY29kZSIgaW4gY3R4LnRlbXBsYXRlX2RhdGEgdGhlbiBjdHgudGVtcGxhdGVfZGF0YS5yZWNvdmVyeV9jb2RlIGVsc2UgbnVsbCwKICByZWNvdmVyeV91cmw6IGlmICJ0ZW1wbGF0ZV9kYXRhIiBpbiBjdHggJiYgInJlY292ZXJ5X3VybCIgaW4gY3R4LnRlbXBsYXRlX2RhdGEgdGhlbiBjdHgudGVtcGxhdGVfZGF0YS5yZWNvdmVyeV91cmwgZWxzZSBudWxsLAogIHZlcmlmaWNhdGlvbl91cmw6IGlmICJ0ZW1wbGF0ZV9kYXRhIiBpbiBjdHggJiYgInZlcmlmaWNhdGlvbl91cmwiIGluIGN0eC50ZW1wbGF0ZV9kYXRhIHRoZW4gY3R4LnRlbXBsYXRlX2RhdGEudmVyaWZpY2F0aW9uX3VybCBlbHNlIG51bGwsCiAgdmVyaWZpY2F0aW9uX2NvZGU6IGlmICJ0ZW1wbGF0ZV9kYXRhIiBpbiBjdHggJiYgInZlcmlmaWNhdGlvbl9jb2RlIiBpbiBjdHgudGVtcGxhdGVfZGF0YSB0aGVuIGN0eC50ZW1wbGF0ZV9kYXRhLnZlcmlmaWNhdGlvbl9jb2RlIGVsc2UgbnVsbCwKICBzdWJqZWN0OiBjdHguc3ViamVjdCwKICBib2R5OiBjdHguYm9keQp9Cg==
                    headers:
                      content-type: application/json
              templates:
                verification_code:
                  valid:
                    sms:
                      body:
                        plaintext: "base64://WW91ciB2ZXJpZmljYXRpb24gY29kZSBpczoge3sgLlZlcmlmaWNhdGlvbkNvZGUgfX0="
                    email:
                      body:
                        plaintext: "base64://WW91ciB2ZXJpZmljYXRpb24gY29kZSBpczoge3sgLlZlcmlmaWNhdGlvbkNvZGUgfX0="
                login_code:
                  valid:
                    sms:
                      body:
                        plaintext: "base64://WW91ciBsb2dpbiBjb2RlIGlzOiB7eyAuTG9naW5Db2RlIH19"
                    email:
                      body:
                        plaintext: "base64://WW91ciB2ZXJpZmljYXRpb24gY29kZSBpczoge3sgLlZlcmlmaWNhdGlvbkNvZGUgfX0="

        image:
          repository: shadowlegend/ory-kratos
          tag: master-arm64

  destination:
    namespace: default
    server: 'https://kubernetes.default.svc'