Skip to main content


Using Casdoor for authentication in Gitea

Gitea is a community managed lightweight code hosting solution written in Go. It is published under the MIT license.

Gitea supports 3rd-party authentication including Oauth, which makes it possible to use Casdoor to authenticate it. Here is the tutorial for achieving this.


To configure Gitea to use Casdoor as identification provider, you need to have Gitea installed as well as access to administrator account.

For more information about how to download, install and run Gitea see

You are supposed to create an administrator account during installation. If you didn't, the administrator will be the first registered user. Please use this account proceed the following procedures.

1. Create an Casdoor application

Like this Create an Casdoor application

Please remember the client ID and client Secret for the next step.

Please don't fill in the callback url in this step. The url depends on the configurations on gitea in the next step. Later we will come back to set a correct callback url.

2. Configure Gitea to use Casdoor

Log in as administrator. Go to 'Site Administration' page via drop-down menu in the upper right corner. Then Switch to "Authentication Source" Page.

You are supposed to see something like this.

Authentication source page

Press the "Add Authentication Source" Button, and fill in the form like this.

Add authentication source

Please choose the authentication type as "oauth2".

Please input a name for this authentication source and remember this name. This name will be used for the callback_url in the next step.

Please choose the OpenID Connect Oauth2 Provider.

Fill in the Client ID and Client Secret remembered in the previous step.

Fill in the openid connect auto discovery url, which is supposed to be <your endpoint of casdoor>/.well-known/openid-configuration.

Fill in the other optional configuration items as you wish. And then submit it.

Submit the form.

3. Configure the callback url in casdoor

Go back to the application edit page in step 2, and add the following callback url:

<endpoint of gitea>/user/oauth2/<authentication source name>/callback

The <authentication source name>is the name for authentication source in Gitea in the previous step.

4. Have a try on Gitea

Logout the current administrator account.

You are supposed to see this in login page:

Gitea login page

Press the 'sign in with openid' button and you will be redirected to casdoor login page.

After login you will see this: After login

Follow the instructions and bind the casdoor account with a new gitea account or existing account.

Then everything will be working correctly.