middleware

package
v0.0.0-...-3befcbb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2023 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const Key = "session"

Variables

View Source
var Store = NewCookieStore([]byte("session_secret"))

Functions

func Clear

func Clear(ctx context.Context) error

func FirebaseAuth

func FirebaseAuth(ctx context.Context, client *auth.Client, wallet string) (string, error)

FirebaseAuth authenticate a user.

func FirebaseInit

func FirebaseInit(ctx context.Context) (*auth.Client, error)

FirebaseInit returns a firebase auth client or an error if it fails.

func FirebaseVerify

func FirebaseVerify(ctx context.Context, client *auth.Client, sessionCookie string) error

FirebaseVerify verifies whether the custom token exists and not expired.

func IsAuthenticated

func IsAuthenticated(ctx context.Context, client *auth.Client) bool

IsAuthenticated.

func Logger

func Logger(nextHandler http.Handler) http.Handler

Writes the HTTP Querystring and Request Body to log for debugging.

func NewCookieStore

func NewCookieStore(keyPairs ...[]byte) sessions.Store

func Session

func Session(store sessions.Store) func(http.Handler) http.Handler

func SetSiwe

func SetSiwe(ctx context.Context, message string) error

func SetWalletAndToken

func SetWalletAndToken(ctx context.Context, walletAddress string, jwtToken string) error

Store WalletAddress and JWT Token from firebase in session.

func Siwe

func Siwe(ctx context.Context) (*siwe.Message, error)

func Token

func Token(ctx context.Context) (string, error)

Returns stored JWT IDToken from session

func Wallet

func Wallet(ctx context.Context) (string, error)

Session "wallet" should contain wallet address of user

Types

type SessionContext

type SessionContext struct {
	W http.ResponseWriter
	R *http.Request
	S sessions.Store
}

func SessionFor

func SessionFor(ctx context.Context) SessionContext

func (*SessionContext) Get

func (sc *SessionContext) Get(name string) (*sessions.Session, error)

func (*SessionContext) Save

func (sc *SessionContext) Save(ss *sessions.Session) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL