403 forbidden when login in harbor 2.0.1 in kubernetes cluster

8/6/2020

I am installed harbor v2.0.1 in kubernetes v1.18, now when I am login harbor, it give me this tips:

{"errors":[{"code":"FORBIDDEN","message":"CSRF token invalid"}]}

this is my traefik 2.2.1 ingress config(this is the docs I am reference):

spec:
  entryPoints:
    - web
  routes:
    - kind: Rule
      match: Host(`harbor-portal.dolphin.com`) && PathPrefix(`/c/`)
      services:
        - name: harbor-harbor-core
          port: 80
    - kind: Rule
      match: Host(`harbor-portal.dolphin.com`)
      services:
        - name: harbor-harbor-portal
          port: 80

I am check harbor core logs only show ping success message.Shoud I using https? I am learnging in local machine. Is https mandantory? I am searching from internet and find just a little resouce to talk aboout it.what should I do to make it work?

enter image description here

I read the source code, and tried in harbor core pod like this:

harbor [ /harbor ]$ curl --insecure -w '%{http_code}' -d 'principal=harbor&password=Harbor123456' http://localhost:8080/c/login   
{"errors":[{"code":"FORBIDDEN","message":"CSRF token invalid"}]}
-- Dolphin
kubernetes

1 Answer

3/9/2021

my expose type is nodePort. modify the values.yaml file, "externalURL: https" change to "externalURL: http"

before: externalURL: https://10.240.11.10:30002 after: externalURL: http://10.240.11.10:30002

and then reinstall the harbor

-- user296224
Source: StackOverflow