@@ -14,15 +14,14 @@ public static bool TryGet(ITrace trace, ISettings settings, InputArguments input
1414 Uri tokenEndpointUri = null ;
1515 var remoteUri = input . GetRemoteUri ( ) ;
1616
17- if ( input . WwwAuth . Any ( x => x . Contains ( "Basic realm=\" Gitea\" " ) ) )
17+ if ( input . WwwAuth . Any ( x => x . Contains ( "Basic realm=\" Gitea\" " , StringComparison . OrdinalIgnoreCase ) ) )
1818 {
1919 trace . WriteLine ( $ "Using universal Gitea OAuth configuration") ;
2020 // https://docs.gitea.com/next/development/oauth2-provider?_highlight=oauth#pre-configured-applications
21- config . ClientId = "e90ee53c-94e2-48ac-9358-a874fb9e0662" ;
22- // https://docs.gitea.com/next/development/oauth2-provider?_highlight=oauth#endpoints
23- authzEndpointUri = new Uri ( remoteUri , "/login/oauth/authorize" ) ;
24- tokenEndpointUri = new Uri ( remoteUri , "/login/oauth/access_token" ) ;
25- config . RedirectUri = new Uri ( "http://127.0.0.1" ) ;
21+ config . ClientId = WellKnown . GiteaClientId ;
22+ authzEndpointUri = new Uri ( remoteUri , WellKnown . GiteaAuthzEndpoint ) ;
23+ tokenEndpointUri = new Uri ( remoteUri , WellKnown . GiteaTokenEndpoint ) ;
24+ config . RedirectUri = WellKnown . LocalIPv4RedirectUri ;
2625 }
2726
2827 if ( settings . TryGetSetting (
@@ -158,5 +157,15 @@ public static bool TryGet(ITrace trace, ISettings settings, InputArguments input
158157 public string DefaultUserName { get ; set ; }
159158
160159 public bool SupportsDeviceCode => Endpoints . DeviceAuthorizationEndpoint != null ;
160+
161+ public static class WellKnown
162+ {
163+ // https://docs.gitea.com/next/development/oauth2-provider?_highlight=oauth#pre-configured-applications
164+ public const string GiteaClientId = "e90ee53c-94e2-48ac-9358-a874fb9e0662" ;
165+ // https://docs.gitea.com/next/development/oauth2-provider?_highlight=oauth#endpoints
166+ public const string GiteaAuthzEndpoint = "/login/oauth/authorize" ;
167+ public const string GiteaTokenEndpoint = "/login/oauth/access_token" ;
168+ public static Uri LocalIPv4RedirectUri = new Uri ( "http://127.0.0.1" ) ;
169+ }
161170 }
162171}
0 commit comments