feat(auth): refactor authentication handling by removing redundant checks and introducing dynamic auth method determination

This commit is contained in:
Avinash Sridhar 2025-04-30 13:00:11 -04:00 • committed by Toby Padilla
commit f843bd4243

View file

@ -65,9 +65,20 @@ func PublishHandler(registry service.RegistryService, authService auth.Service)
token = authHeader[7:]
}
// Determine authentication method based on server name prefix
var authMethod model.AuthMethod
switch {
case strings.HasPrefix(serverDetail.Name, "io.github"):
authMethod = model.AuthMethodGitHub
// Additional cases can be added here for other prefixes
default:
// Keep the default auth method as AuthMethodNone
authMethod = model.AuthMethodNone
}
// Setup authentication info
a := model.Authentication{
Method: model.AuthMethodGitHub,
Method: authMethod,
Token: token,
RepoRef: serverDetail.Name,
}