@@ -14,15 +14,14 @@ public static bool TryGet(ITrace trace, ISettings settings, InputArguments input
14
14
Uri tokenEndpointUri = null ;
15
15
var remoteUri = input . GetRemoteUri ( ) ;
16
16
17
- if ( input . WwwAuth . Any ( x => x . Contains ( "Basic realm=\" Gitea\" " ) ) )
17
+ if ( input . WwwAuth . Any ( x => x . Contains ( "Basic realm=\" Gitea\" " , StringComparison . OrdinalIgnoreCase ) ) )
18
18
{
19
19
trace . WriteLine ( $ "Using universal Gitea OAuth configuration") ;
20
20
// 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 ;
26
25
}
27
26
28
27
if ( settings . TryGetSetting (
@@ -158,5 +157,15 @@ public static bool TryGet(ITrace trace, ISettings settings, InputArguments input
158
157
public string DefaultUserName { get ; set ; }
159
158
160
159
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
+ }
161
170
}
162
171
}
0 commit comments