Skip to main content

Overview

For Third-Part Server, validate user with SeeAuth service, and return the user credentials for accessing his/her data.

Install

GitHub go.mod Go version (subdirectory of monorepo) GitHub release (with filter)

$ go get github.com/Taoist-Labs/see-auth-go

Usage

Use SeeDAOAuth(...) function to authenticate user with SeeAuth service.

// SeeDAOAuth authenticates with SeeAuth service
// `recipient` parameter is fixed to `0x0000000000000000000000000000000000000000`
// `seeAuth` parameter is the `SeeAuth` object, it is parsed from the http request body.
// It returns the wallet address if the authentication is successful, otherwise it returns an error
func SeeDAOAuth(recipient string, seeAuth *SeeAuth) (string, error)

For example(using Fiber framework):

package main

import (
seeauth "github.com/Taoist-Labs/see-auth-go"
"github.com/gofiber/fiber/v2"
)

func main() {
app := fiber.New()

app.Post("/seeauth", func(c *fiber.Ctx) error {
var req seeauth.SeeAuth
if err := c.BodyParser(&req); err != nil {
return err
}

wallet, err := seeauth.SeeDAOAuth("0x0000000000000000000000000000000000000000", &req)
if err != nil {
return err
}

return c.JSON(struct {
Wallet string `json:"wallet"`
Token string `json:"token"`
}{
Wallet: wallet,
Token: "jwt token",
})
})
}

Testing

Open https://seeauth-web.deno.dev/ and fill your seeauth api url at Third-Server-SeeAuth-Endpoint, and then click the With SeeAuth button to test.

seeauth