authactionecho

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package authactionecho provides Echo middleware for AuthAction JWT verification.

import (
    authaction "github.com/authaction/authaction-go-sdk"
    authactionecho "github.com/authaction/authaction-go-sdk/echo"
)

client, _ := authaction.New(authaction.Config{...})

e := echo.New()
e.Use(authactionecho.RequireAuth(client))

e.GET("/me", func(c echo.Context) error {
    claims, _ := authactionecho.ClaimsFromContext(c)
    return c.JSON(200, map[string]string{"sub": claims.Sub})
})

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClaimsFromContext

func ClaimsFromContext(ctx echo.Context) (*authaction.TokenPayload, bool)

ClaimsFromContext retrieves the verified token claims stored by middleware. Returns (nil, false) when no claims are present.

func OptionalAuth

func OptionalAuth(c *authaction.Client) echo.MiddlewareFunc

OptionalAuth returns an Echo middleware that attaches claims when a valid Bearer token is present, but allows unauthenticated requests through.

func RequireAuth

func RequireAuth(c *authaction.Client) echo.MiddlewareFunc

RequireAuth returns an Echo middleware that enforces a valid Bearer token. On missing or invalid token it returns an HTTP 401 error. On success the verified claims are stored in the Echo context and retrievable via ClaimsFromContext.

Types

This section is empty.

Jump to

Keyboard shortcuts

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