Compare commits

...

3 Commits

Author SHA1 Message Date
Srujan S 3efa178928
Merge 760dc494d4 into 63b3ef0151 2025-02-12 16:42:24 +01:00
Andrew Nicholson 63b3ef0151
Enable "Boot Interface Subclass" for keyboard and mouse. (#113)
This is often required for the keyboard/mouse to be recognized in
BIOS/UEFI firmware.
2025-02-12 15:08:03 +01:00
Srujan S 760dc494d4
Update web.go
made changes to truncate to 70 characters
2025-01-10 19:18:32 -06:00
2 changed files with 36 additions and 31 deletions

4
usb.go
View File

@ -132,7 +132,7 @@ func writeGadgetConfig() error {
} }
err = writeGadgetAttrs(hid0Path, [][]string{ err = writeGadgetAttrs(hid0Path, [][]string{
{"protocol", "1"}, {"protocol", "1"},
{"subclass", "0"}, {"subclass", "1"},
{"report_length", "8"}, {"report_length", "8"},
}) })
if err != nil { if err != nil {
@ -152,7 +152,7 @@ func writeGadgetConfig() error {
} }
err = writeGadgetAttrs(hid1Path, [][]string{ err = writeGadgetAttrs(hid1Path, [][]string{
{"protocol", "2"}, {"protocol", "2"},
{"subclass", "0"}, {"subclass", "1"},
{"report_length", "6"}, {"report_length", "6"},
}) })
if err != nil { if err != nil {

9
web.go
View File

@ -237,6 +237,7 @@ func handleCreatePassword(c *gin.Context) {
// We only allow users with noPassword mode to set a new password // We only allow users with noPassword mode to set a new password
// Users with password mode are not allowed to set a new password without providing the old password // Users with password mode are not allowed to set a new password without providing the old password
// We have a PUT endpoint for changing the password, use that instead // We have a PUT endpoint for changing the password, use that instead
if config.LocalAuthMode != "noPassword" { if config.LocalAuthMode != "noPassword" {
c.JSON(http.StatusBadRequest, gin.H{"error": "Password mode is not enabled"}) c.JSON(http.StatusBadRequest, gin.H{"error": "Password mode is not enabled"})
return return
@ -248,7 +249,12 @@ func handleCreatePassword(c *gin.Context) {
return return
} }
hashedPassword, err := bcrypt.GenerateFromPassword([]byte(req.Password), bcrypt.DefaultCost) truncatedPassword := req.Password
if len(truncatedPassword) > 70 {
truncatedPassword = truncatedPassword[:70]
}
hashedPassword, err := bcrypt.GenerateFromPassword([]byte(truncatedPassword), bcrypt.DefaultCost)
if err != nil { if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to hash password"}) c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to hash password"})
return return
@ -262,7 +268,6 @@ func handleCreatePassword(c *gin.Context) {
return return
} }
// Set the cookie
c.SetCookie("authToken", config.LocalAuthToken, 7*24*60*60, "/", "", false, true) c.SetCookie("authToken", config.LocalAuthToken, 7*24*60*60, "/", "", false, true)
c.JSON(http.StatusCreated, gin.H{"message": "Password set successfully"}) c.JSON(http.StatusCreated, gin.H{"message": "Password set successfully"})