refactor: use htmx instead of dwn for vault client

This commit is contained in:
Prad Nukala
2024-09-25 20:11:30 -04:00
parent 7057332163
commit 0df3762f13
14 changed files with 53 additions and 58 deletions
-43
View File
@@ -1,43 +0,0 @@
package state
import (
"encoding/json"
"fmt"
"github.com/go-webauthn/webauthn/protocol"
"github.com/labstack/echo/v4"
)
func checkSubjectIsValid(e echo.Context) error {
credentialID := e.FormValue("credentialID")
return e.JSON(200, credentialID)
}
func handleCredentialAssertion(e echo.Context) error {
return e.JSON(200, "HandleCredentialAssertion")
}
func handleCredentialCreation(e echo.Context) error {
// Get the serialized credential data from the form
credentialDataJSON := e.FormValue("credentialData")
// Deserialize the JSON into a temporary struct
var ccr protocol.CredentialCreationResponse
err := json.Unmarshal([]byte(credentialDataJSON), &ccr)
if err != nil {
return e.JSON(500, err.Error())
}
//
// // Parse the CredentialCreationResponse
// parsedData, err := ccr.Parse()
// if err != nil {
// return e.JSON(500, err.Error())
// }
//
// // Create the Credential
// // credential := orm.NewCredential(parsedData, e.Request().Host, "")
//
// // Set additional fields
// credential.Controller = "" // Set this to the appropriate controller value
return e.JSON(200, fmt.Sprintf("REGISTER: %s", string(ccr.ID)))
}
-1
View File
@@ -1 +0,0 @@
package state
-23
View File
@@ -1,23 +0,0 @@
package state
import (
"github.com/labstack/echo/v4"
)
func grantAuthorization(e echo.Context) error {
// Implement authorization endpoint using passkey authentication
// Store session data in cache
return nil
}
func getJWKS(e echo.Context) error {
// Implement token endpoint
// Use cached session data for validation
return nil
}
func getToken(e echo.Context) error {
// Implement token endpoint
// Use cached session data for validation
return nil
}
-22
View File
@@ -1,22 +0,0 @@
package state
import (
"github.com/labstack/echo/v4"
middleware "github.com/onsonr/sonr/x/vault/client/dwn/middleware"
)
func RegisterHandlers(e *echo.Echo) {
g := e.Group("state")
g.POST("/login/:identifier", handleCredentialAssertion)
// g.GET("/discovery", state.GetDiscovery)
g.GET("/jwks", getJWKS)
g.GET("/token", getToken)
g.POST("/:origin/grant/:subject", grantAuthorization)
g.POST("/register/:subject", handleCredentialCreation)
g.POST("/register/:subject/check", checkSubjectIsValid)
}
func RegisterSync(e *echo.Echo) {
g := e.Group("sync")
g.Use(middleware.MacaroonMiddleware("test", "test"))
}
-1
View File
@@ -1 +0,0 @@
package state
-1
View File
@@ -1 +0,0 @@
package state