Any push fails with invalid header field value Bearer for key Authorization #5398

Closed
opened 2025-11-02 06:23:38 -06:00 by GiteaMirror · 3 comments
Owner

Originally created by @kristofre on GitHub (May 14, 2020).

  • Gitea version (or commit ref): 1.11.5
  • Git version:
  • Operating system: kubernetes 1.18, exposed via NGINX Ingress
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:

Description

Installed gitea using helm chart https://github.com/k8s-land/gitea-chart
Values below.

I can register and sign into gitea and create a repo.
However as soon as I try to add a file or modify a file (in gitea UI), I get the following error message:

The change was rejected by the server with the following message:
Gitea: Internal Server Error
Unable to contact gitea: Post http://0.0.0.0:3000/api/internal/hook/pre-receive/dynatrace/test: net/http: invalid header field value "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE1ODk0NTQxOTJ9.iWBvmOHvMVDnPNwVtNaAZ91gMBPljH-3lDVvM0_0HEE\n" for key Authorization
Please check githooks.

I believe the \n at the end of the bearer token might have something to do with it but I am not sure.

I have the same issue on the command line:

$ git push 
Username for 'http://gitea.192.168.50.10.xip.io': dynatrace
Password for 'http://dynatrace@gitea.192.168.50.10.xip.io':
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Writing objects: 100% (3/3), 247 bytes | 247.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: Gitea: Internal Server Error
remote: Unable to contact gitea: Post http://0.0.0.0:3000/api/internal/hook/pre-receive/dynatrace/test: net/http: invalid header field value "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE1ODk0NTQxOTJ9.iWBvmOHvMVDnPNwVtNaAZ91gMBPljH-3lDVvM0_0HEE\n" for key Authorization
To http://gitea.192.168.50.10.xip.io/dynatrace/test
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'http://gitea.192.168.50.10.xip.io/dynatrace/test'

Any help would be greatly appreciated!

## Gitea image
## ref: https://hub.docker.com/r/gitea/gitea/tags/
##

tags:
  mariadb: true

images:
  registry: docker.io
  gitea: "gitea/gitea:1.11.5"
  memcached: "memcached:1.5.19-alpine"
  pullPolicy: IfNotPresent
 
## Cache settings for memcache
memcached:
  maxItemMemory: 64
  verbosity: v
  extendedOptions: modern

## Configure the ingress resource that allows you to access the
## Gitea installation. Set up the URL
## ref: http://kubernetes.io/docs/user-guide/ingress/
##
ingress:
  enabled: true
  certManager: false
  hostname: gitea.192.168.50.10.xip.io
  annotations: {}
  secrets:

## This chart defaults to using an ingress for http, but change to LoadBalancer if using you cluster supports it
service:
  http:
    serviceType: ClusterIP
    port: 3000
    externalHost: gitea.192.168.50.10.xip.io

  ## SSH is commonly on port 22.. however.. you most likely already have port 22 being used by your node.
  ## so we use port 8022.
  ssh:
    serviceType: LoadBalancer
    port: 22
    externalPort: 8022
    externalHost: gitea.192.168.50.10.xip.io
    externalIPs: []

## Configure resource requests and limits
## ref: http://kubernetes.io/docs/user-guide/compute-resources/
##
resources:
  gitea:
    requests:
      memory: 500Mi
      cpu: 300m
    limits:
      memory: 2Gi
      cpu: 1
  memcached:
    requests:
      memory: 64Mi
      cpu: 50m

## Enable persistence using Persistent Volume Claims
## ref: http://kubernetes.io/docs/user-guide/persistent-volumes/
## ref:
##
persistence:
  enabled: true
  giteaSize: 10Gi
  accessMode: ReadWriteMany
  annotations:
    "helm.sh/resource-policy": keep

##
## MariaDB chart configuration
##
## https://github.com/helm/charts/blob/master/stable/mariadb/values.yaml
##
mariadb:
  enabled: true
  replication:
    enabled: false
  db:
    name: gitea
    user: gitea

  rootUser:
    password: ThisIsMySuperSecretPassword

  master:
    persistence:
      enabled: true
      accessMode: ReadWriteOnce
      size: 8Gi

config:
##  secretName: "<Existing Secret Name>"
##  secretKey: "<random>"  # Generate with 'gitea generate secret SECRET_KEY'
##  jwtSecret: "<random>"  # Generate with 'gitea generate secret JWT_SECRET'
##  lfsJwtSecret: "<random>"  # Generate with 'gitea generate secret LFS_JWT_SECRET'
##  internalToken: "<random>"  # Generate with 'gitea generate secret INTERNAL_TOKEN'
  disableInstaller: false
  offlineMode: false
  requireSignin: false
  disableRegistration: false
  openidSignin: true
  immutableConfig: false  # Regenerate config every time, and set as read-only

## Common helm annotations
## Node labels and tolerations for pod assignment
## ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector
## ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#taints-and-tolerations-beta-feature
nodeSelector: {}
tolerations: []
affinity: {}

## Annotations for the deployment and nodes.
deploymentAnnotations: {}
podAnnotations: {}

...

Screenshots

Originally created by @kristofre on GitHub (May 14, 2020). <!-- NOTE: If your issue is a security concern, please send an email to security@gitea.io instead of opening a public issue --> <!-- 1. Please speak English, this is the language all maintainers can speak and write. 2. Please ask questions or configuration/deploy problems on our Discord server (https://discord.gg/gitea) or forum (https://discourse.gitea.io). 3. Please take a moment to check that your issue doesn't already exist. 4. Please give all relevant information below for bug reports, because incomplete details will be handled as an invalid report. --> - Gitea version (or commit ref): 1.11.5 - Git version: - Operating system: kubernetes 1.18, exposed via NGINX Ingress - Database (use `[x]`): - [ ] PostgreSQL - [X] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [X] No - [ ] Not relevant - Log gist: ## Description Installed gitea using helm chart https://github.com/k8s-land/gitea-chart Values below. I can register and sign into gitea and create a repo. However as soon as I try to add a file or modify a file (in gitea UI), I get the following error message: ``` The change was rejected by the server with the following message: Gitea: Internal Server Error Unable to contact gitea: Post http://0.0.0.0:3000/api/internal/hook/pre-receive/dynatrace/test: net/http: invalid header field value "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE1ODk0NTQxOTJ9.iWBvmOHvMVDnPNwVtNaAZ91gMBPljH-3lDVvM0_0HEE\n" for key Authorization Please check githooks. ``` I believe the `\n` at the end of the bearer token might have something to do with it but I am not sure. I have the same issue on the command line: ``` $ git push Username for 'http://gitea.192.168.50.10.xip.io': dynatrace Password for 'http://dynatrace@gitea.192.168.50.10.xip.io': Enumerating objects: 5, done. Counting objects: 100% (5/5), done. Writing objects: 100% (3/3), 247 bytes | 247.00 KiB/s, done. Total 3 (delta 0), reused 0 (delta 0) remote: Gitea: Internal Server Error remote: Unable to contact gitea: Post http://0.0.0.0:3000/api/internal/hook/pre-receive/dynatrace/test: net/http: invalid header field value "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE1ODk0NTQxOTJ9.iWBvmOHvMVDnPNwVtNaAZ91gMBPljH-3lDVvM0_0HEE\n" for key Authorization To http://gitea.192.168.50.10.xip.io/dynatrace/test ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'http://gitea.192.168.50.10.xip.io/dynatrace/test' ``` Any help would be greatly appreciated! ``` ## Gitea image ## ref: https://hub.docker.com/r/gitea/gitea/tags/ ## tags: mariadb: true images: registry: docker.io gitea: "gitea/gitea:1.11.5" memcached: "memcached:1.5.19-alpine" pullPolicy: IfNotPresent ## Cache settings for memcache memcached: maxItemMemory: 64 verbosity: v extendedOptions: modern ## Configure the ingress resource that allows you to access the ## Gitea installation. Set up the URL ## ref: http://kubernetes.io/docs/user-guide/ingress/ ## ingress: enabled: true certManager: false hostname: gitea.192.168.50.10.xip.io annotations: {} secrets: ## This chart defaults to using an ingress for http, but change to LoadBalancer if using you cluster supports it service: http: serviceType: ClusterIP port: 3000 externalHost: gitea.192.168.50.10.xip.io ## SSH is commonly on port 22.. however.. you most likely already have port 22 being used by your node. ## so we use port 8022. ssh: serviceType: LoadBalancer port: 22 externalPort: 8022 externalHost: gitea.192.168.50.10.xip.io externalIPs: [] ## Configure resource requests and limits ## ref: http://kubernetes.io/docs/user-guide/compute-resources/ ## resources: gitea: requests: memory: 500Mi cpu: 300m limits: memory: 2Gi cpu: 1 memcached: requests: memory: 64Mi cpu: 50m ## Enable persistence using Persistent Volume Claims ## ref: http://kubernetes.io/docs/user-guide/persistent-volumes/ ## ref: ## persistence: enabled: true giteaSize: 10Gi accessMode: ReadWriteMany annotations: "helm.sh/resource-policy": keep ## ## MariaDB chart configuration ## ## https://github.com/helm/charts/blob/master/stable/mariadb/values.yaml ## mariadb: enabled: true replication: enabled: false db: name: gitea user: gitea rootUser: password: ThisIsMySuperSecretPassword master: persistence: enabled: true accessMode: ReadWriteOnce size: 8Gi config: ## secretName: "<Existing Secret Name>" ## secretKey: "<random>" # Generate with 'gitea generate secret SECRET_KEY' ## jwtSecret: "<random>" # Generate with 'gitea generate secret JWT_SECRET' ## lfsJwtSecret: "<random>" # Generate with 'gitea generate secret LFS_JWT_SECRET' ## internalToken: "<random>" # Generate with 'gitea generate secret INTERNAL_TOKEN' disableInstaller: false offlineMode: false requireSignin: false disableRegistration: false openidSignin: true immutableConfig: false # Regenerate config every time, and set as read-only ## Common helm annotations ## Node labels and tolerations for pod assignment ## ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector ## ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#taints-and-tolerations-beta-feature nodeSelector: {} tolerations: [] affinity: {} ## Annotations for the deployment and nodes. deploymentAnnotations: {} podAnnotations: {} ``` ... ## Screenshots <!-- **If this issue involves the Web Interface, please include a screenshot** -->
Author
Owner

@Anganthier commented on GitHub (May 15, 2020):

I've got the same error running gitea 1.11.5 on a kubernetes 1.18 cluster but a postgreSQL on the backend. The gitea service is exposed via a netscaler adc reverse proxy.

I migrated from an older installation. The error will show up regardless if it is an "old" repository or a newly created repository.

I tried changing the log level in the gitea installation, but no error regarding this push will show up in the gitea log.

I also regenerated the hooks as described in the documentation:
./gitea admin regenerate hooks -c /data/gitea/conf/app.ini
-> No change

@Anganthier commented on GitHub (May 15, 2020): I've got the same error running gitea 1.11.5 on a kubernetes 1.18 cluster but a postgreSQL on the backend. The gitea service is exposed via a netscaler adc reverse proxy. I migrated from an older installation. The error will show up regardless if it is an "old" repository or a newly created repository. I tried changing the log level in the gitea installation, but no error regarding this push will show up in the gitea log. I also regenerated the hooks as described in the documentation: ./gitea admin regenerate hooks -c /data/gitea/conf/app.ini -> No change
Author
Owner

@zeripath commented on GitHub (May 15, 2020):

@kristofre The hint is here:

Unable to contact gitea: Post http://0.0.0.0:3000/api/internal/hook/pre-receive/dynatrace/test: net/http: invalid header field value "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE1ODk0NTQxOTJ9.iWBvmOHvMVDnPNwVtNaAZ91gMBPljH-3lDVvM0_0HEE\n" for key Authorization

You need to set the INTERNAL_ROOT_URL and INTERNAL_TOKEN appropriately. Gitea's serv / hook cannot communicate with the running Gitea server

@zeripath commented on GitHub (May 15, 2020): @kristofre The hint is here: ``` Unable to contact gitea: Post http://0.0.0.0:3000/api/internal/hook/pre-receive/dynatrace/test: net/http: invalid header field value "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE1ODk0NTQxOTJ9.iWBvmOHvMVDnPNwVtNaAZ91gMBPljH-3lDVvM0_0HEE\n" for key Authorization ``` You need to set the INTERNAL_ROOT_URL and INTERNAL_TOKEN appropriately. Gitea's serv / hook cannot communicate with the running Gitea server
Author
Owner

@cdrage commented on GitHub (May 15, 2020):

Unfortunately this was an error in the chart, see the PR here that broke it: https://github.com/k8s-land/gitea-chart/pull/13

We've reverted the PR and submitted a new chart version as per:

k8s/k8s-land/charts  master ✔                                                                                                                                                    0m  
▶ helm search repo k8s-land -l
NAME            CHART VERSION   APP VERSION     DESCRIPTION          
k8s-land/gitea  1.3.3           1.11.5          Git with a cup of tea
k8s-land/gitea  1.3.1           1.11.4          Git with a cup of tea
k8s-land/gitea  1.3.0           1.11.3          Git with a cup of tea
k8s-land/gitea  1.2.3           1.10.1          Git with a cup of tea
k8s-land/gitea  1.2.2           1.9.3           Git with a cup of tea
k8s-land/gitea  1.2.1           1.9.3           Git with a cup of tea

This issue can be closed.

PIng @kristofre @zeripath @Anganthier

@cdrage commented on GitHub (May 15, 2020): Unfortunately this was an error in the chart, see the PR here that broke it: https://github.com/k8s-land/gitea-chart/pull/13 We've reverted the PR and submitted a new chart version as per: ```sh k8s/k8s-land/charts master ✔ 0m ▶ helm search repo k8s-land -l NAME CHART VERSION APP VERSION DESCRIPTION k8s-land/gitea 1.3.3 1.11.5 Git with a cup of tea k8s-land/gitea 1.3.1 1.11.4 Git with a cup of tea k8s-land/gitea 1.3.0 1.11.3 Git with a cup of tea k8s-land/gitea 1.2.3 1.10.1 Git with a cup of tea k8s-land/gitea 1.2.2 1.9.3 Git with a cup of tea k8s-land/gitea 1.2.1 1.9.3 Git with a cup of tea ``` This issue can be closed. PIng @kristofre @zeripath @Anganthier
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#5398