Configure Azure Active Directory as Authentication Provider for Gitea
Gitea is an open source git hosting platform, written in Go forked from the Gogs project and seems to be highly inspired by GitHub. If you want to host your own git platform and want to use Azure Active Directory as an authentication provider - this post might help you.
Instead of managing credentials in your application you can use external authentication providers (AP) to deal with user authentication.
The most common scenario nowadays is the OAUTH protocol.
Using an AP not only makes your life as a service developer/admin easier but also the user because he can reuse his identity from other services. Gitea supports several authentication types and when it comes to OAUTH also several providers. The one we will use for including Azure Active Directory is the OpenID Connect provider that actually exposes a common standard for authentication providers to use, so applications like Gitea do not have to implement individual OAUTH providers. We will be using the OAuth 2.0 auth code grant. The first step is to create an application on Azure, head over to AAD - App Registrations in the portal and register a new application: For Azure to implement the correct authorization flow ( Scroll up on the same page and make sure you have a Redirect URI of type Finally we need to create a Client secret by going to the Manage → Certificates & secrets panel and add a new client secret. Make sure to copy the secret as it is created - you will not be able to access it later. For the configuration in Gitea you need the following values from your Azure App registration: On the Gitea administration page select Authentication Sources and create a new one: If you are having issues following this guide or find information being outdated feel free to leave a comment or reach out via Twitter 👋Authentication Providers
Creating an Azure AD application
<host>/user/oauth2/<Authentication Name>/callback
as a callback URL where <Authentication Name>
is a value you will specify in the next chapter e.g. AAD, Azure Authcode
) we need to change our application type to native
, this can be done via the Manage → Authentication blade in the Azure Portal. Set The default application type to Yes
. In case the UI changes make sure to look out for Device code flow and make sure it is configured to use this method.Web
set correctly.Caution:
https://login.microsoftonline.com/<tenant>/v2.0/.well-known/openid-configuration
where you can find your tenant also in the Overview tab as Directory (tenant) IDAdd Authentication Source in Gitea