
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
github.com/containerSSH/auth
This library provides the server and client components for the authentication webhook
⚠⚠⚠ Warning: This is a developer documentation. ⚠⚠⚠
The user documentation for ContainerSSH is located at containerssh.io.
As a core component for your authentication server you will have to implement the Handler
interface:
type myHandler struct {
}
func (h *myHandler) OnPassword(
Username string,
Password []byte,
RemoteAddress string,
ConnectionID string,
) (bool, error) {
if Username == "foo" && string(Password) == "bar" {
return true, nil
}
if Username == "crash" {
// Simulate a database failure
return false, fmt.Errorf("database error")
}
return false, nil
}
func (h *myHandler) OnPubKey(
Username string,
// PublicKey is the public key in the authorized key format.
PublicKey string,
RemoteAddress string,
ConnectionID string,
) (bool, error) {
// Handle public key auth here
}
Then you can use this handler to create a simple web server using the http library. The server requires using the lifecycle facility from the service library. You can create the server as follows:
server := auth.NewServer(
http.ServerConfiguration{
Listen: "127.0.0.1:8080",
},
&myHandler{},
logger,
)
lifecycle := service.NewLifecycle(server)
go func() {
if err := lifecycle.Run(); err != nil {
// Handle error
}
}
// When done, shut down server with an optional context for the shutdown deadline
lifecycle.Stop(context.Background())
The logger
is a logger from the github.com/containerssh/log package. The server configuration optionally allows you to configure mutual TLS authentication. See the documentation for details.
You can also use the authentication handler with the native Go HTTP library:
func main() {
logger := log.New(...)
httpHandler := auth.NewHandler(&myHandler{}, logger)
http.Handle("/auth", httpHandler)
http.ListenAndServe(":8090", nil)
}
This library also provides a HTTP client for authentication servers. This library can be used as follows:
client := auth.NewHttpAuthClient(
auth.ClientConfig{
URL: "http://localhost:8080"
Password: true,
PubKey: false,
// This is the timeout for individual requests.
Timeout: 2 * time.Second,
// This is the overall timeout for the authentication process.
AuthTimeout: 60 * time.Second,
},
logger,
)
success, err := client.Password(
"foo",
[]byte("bar"),
"0123456789ABCDEF",
ip
) (bool, error)
success, err := client.PubKey(
"foo",
"ssh-rsa ...",
"0123456789ABCDEF",
ip
) (bool, error)
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.