Client library used to ease integration with the MAuth server.
It defines the following calls:
Version - Report the server's API version. Always an integer. Not SemVer.
AccountExists - Report whether an account exists.
AccountList - List of all account names.
AddAccount - Create a new account.
RemoveAccount - Delete an account.
ChangePassword - Change an account's password.
Authenticate - Authenticate an account by password. Returns a session token.
VerifySession - Verify that a given session token is recognized as a valid session with the server.
Installation:
go get github.com/mikattack/mauth_client
Example usage:
package main
import (
"log/slog"
"os"
"github.com/mikattack/mauth-client/mauth-client"
)
func main() {
client, err := mauth_client.New("/path/to/socket")
if err != nil {
slog.Error("failed to connect to server", "error", err)
os.Exit(1)
}
account := "ephemeral"
password := "ephemeral-password"
token, err := client.Authenticate(account, password)
if err != nil {
slog.Error("authentication failed", "error", err)
os.Exit(1)
}
if err = client.VerifySession(token); err != nil {
slog.Error("invalid session", "error", err)
os.Exit(1)
}
slog.Info("authenticated session established")
}