mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-03 01:41:44 +00:00
feature/1109 grpc session model (#1141)
- **feat: remove Hway deployment** - **feat: introduce session middleware for requests** - **refactor: update path imports to use new pkg folder** - **feat: add gRPC client for interacting with services** - **feat: remove grpc client and use REST api** - **refactor: move from to** - **feat: add client views endpoint** - **feat: add webauthn support** - **closes: #1124** - **refactor: Improve PR labeler configuration** - **feat: add milestone discussion template** - **feat: remove OKR tracking issue template** - **feat: use gorilla sessions for session management** - **refactor: move pubkey related code to** - **<no value>** - **refactor: remove unused identifier type** - **feat: integrate Macaroon Keeper with Service Module** - **refactor: rename worker routes for clarity**
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"github.com/go-webauthn/webauthn/protocol"
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
// ╭───────────────────────────────────────────────────────────╮
|
||||
// │ Login Handlers │
|
||||
// ╰───────────────────────────────────────────────────────────╯
|
||||
|
||||
func LoginSubjectCheck(e echo.Context) error {
|
||||
return e.JSON(200, "HandleCredentialAssertion")
|
||||
}
|
||||
|
||||
func LoginSubjectStart(e echo.Context) error {
|
||||
opts := &protocol.PublicKeyCredentialRequestOptions{
|
||||
UserVerification: "preferred",
|
||||
Challenge: []byte("challenge"),
|
||||
}
|
||||
return e.JSON(200, opts)
|
||||
}
|
||||
|
||||
func LoginSubjectFinish(e echo.Context) error {
|
||||
var crr protocol.CredentialAssertionResponse
|
||||
if err := e.Bind(&crr); err != nil {
|
||||
return err
|
||||
}
|
||||
return e.JSON(200, crr)
|
||||
}
|
||||
|
||||
// ╭───────────────────────────────────────────────────────────╮
|
||||
// │ Register Handlers │
|
||||
// ╰───────────────────────────────────────────────────────────╯
|
||||
|
||||
func RegisterSubjectCheck(e echo.Context) error {
|
||||
credentialID := e.FormValue("credentialID")
|
||||
return e.JSON(200, credentialID)
|
||||
}
|
||||
|
||||
func RegisterSubjectStart(e echo.Context) error {
|
||||
opts := &protocol.PublicKeyCredentialCreationOptions{
|
||||
RelyingParty: protocol.RelyingPartyEntity{
|
||||
CredentialEntity: protocol.CredentialEntity{
|
||||
Name: "Sonr",
|
||||
},
|
||||
ID: "https://sonr.io",
|
||||
},
|
||||
}
|
||||
return e.JSON(200, opts)
|
||||
}
|
||||
|
||||
func RegisterSubjectFinish(e echo.Context) error {
|
||||
// Deserialize the JSON into a temporary struct
|
||||
var ccr protocol.CredentialCreationResponse
|
||||
if err := e.Bind(&ccr); err != nil {
|
||||
return err
|
||||
}
|
||||
//
|
||||
// // 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, "")
|
||||
return e.JSON(200, ccr)
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package handlers
|
||||
|
||||
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
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package handlers
|
||||
|
||||
import "github.com/labstack/echo/v4"
|
||||
|
||||
func GetDatabaseSchema(e echo.Context) error {
|
||||
// Implement database schema endpoint
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package routes
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
|
||||
"github.com/onsonr/sonr/pkg/nebula/components/auth"
|
||||
"github.com/onsonr/sonr/pkg/nebula/components/home"
|
||||
"github.com/onsonr/sonr/pkg/workers/handlers"
|
||||
)
|
||||
|
||||
func RegisterClientAPI(e *echo.Echo) {
|
||||
g1 := e.Group("api")
|
||||
g1.GET("/register/:subject/start", handlers.RegisterSubjectStart)
|
||||
g1.POST("/register/:subject/check", handlers.RegisterSubjectCheck)
|
||||
g1.POST("/register/:subject/finish", handlers.RegisterSubjectFinish)
|
||||
|
||||
g1.GET("/login/:subject/start", handlers.LoginSubjectStart)
|
||||
g1.POST("/login/:subject/check", handlers.LoginSubjectCheck)
|
||||
g1.POST("/login/:subject/finish", handlers.LoginSubjectFinish)
|
||||
|
||||
g1.GET("/jwks", handlers.GetJWKS)
|
||||
g1.GET("/token", handlers.GetToken)
|
||||
g1.POST("/:origin/grant/:subject", handlers.GrantAuthorization)
|
||||
}
|
||||
|
||||
func RegisterClientViews(e *echo.Echo) {
|
||||
e.GET("/home", home.Route)
|
||||
e.GET("/login", auth.LoginRoute)
|
||||
e.GET("/register", auth.RegisterRoute)
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package routes
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
|
||||
"github.com/onsonr/sonr/pkg/nebula/components/auth"
|
||||
"github.com/onsonr/sonr/pkg/nebula/components/home"
|
||||
)
|
||||
|
||||
func RegisterProxyAPI(e *echo.Echo) {
|
||||
}
|
||||
|
||||
func RegisterProxyViews(e *echo.Echo) {
|
||||
e.GET("/", home.Route)
|
||||
e.GET("/login", auth.LoginRoute)
|
||||
e.GET("/register", auth.RegisterRoute)
|
||||
}
|
||||
Reference in New Issue
Block a user