clear non ascii char in user.extraname
Created by: supu2
What type of PR is this?
/kind bug
What this PR does / why we need it:
Enable auht oidc with keycloak, i encountered some user login issue like below. After sso login user faced empty page with status code 500. Some research over github i found same problem. Problem is sso return non ascii username like "Škoda" to console server . We need to replace non ascii char in user.extraname like this.
ctx.cookies.set('defaultUser', user.extraname.replace(/([^\x00-\xFF]|\s)/g,''))
<-- GET /oauth/redirect/sso?state=sso&session_state=31c552f9-dxxx 2021/08/24T14:55:50.403
TypeError: argument value is invalid
at new Cookie (/opt/kubesphere/console/server/server.js:20401:11)
at Cookies.set (/opt/kubesphere/console/server/server.js:20363:16)
at handleOAuthLogin (/opt/kubesphere/console/server/server.js:66532:17)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async /opt/kubesphere/console/server/server.js:36632:7
at async logger (/opt/kubesphere/console/server/server.js:33653:7)
at async /opt/kubesphere/console/server/server.js:28416:26
at async /opt/kubesphere/console/server/server.js:28416:26
at async /opt/kubesphere/console/server/server.js:28416:26
more details: https://github.com/koajs/koa/issues/740#issuecomment-221459155 https://tools.ietf.org/html/rfc7230#section-3.2
Which issue(s) this PR fixes:
Fixes #2189 (closed)
Does this PR introduced a user-facing change?
None