Documentation
¶
Overview ¶
Package jwt is an Ambient plugin that enables jwt.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsWhitelisted ¶
IsWhitelisted returns true if the request is in the whitelist. If only an asterisk is found in the whitelist, allow all routes. If an asterisk is found in the page string, then whitelist only the matching paths.
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config contains the dependencies for the handler.
type GenericResponse ¶
type GenericResponse struct { // in: body Body struct { // Status contains the string of the HTTP status. // // Required: true Status string `json:"status"` // Message can contain a user friendly message. Message string `json:"message,omitempty"` } }
GenericResponse returns any status code.
type InternalServerErrorResponse ¶
type InternalServerErrorResponse struct {
GenericResponse
}
InternalServerErrorResponse returns 500. swagger:response InternalServerErrorResponse
type Plugin ¶
type Plugin struct { *ambient.PluginBase // contains filtered or unexported fields }
Plugin represents an Ambient plugin.
func New ¶
New an Ambient plugin that provides request logging middleware.
Example ¶
package main import ( "log" "time" "github.com/ambientkit/ambient" "github.com/ambientkit/ambient/pkg/ambientapp" "github.com/ambientkit/plugin/logger/zaplogger" "github.com/ambientkit/plugin/middleware/jwt" "github.com/ambientkit/plugin/pkg/uuid" "github.com/ambientkit/plugin/storage/memorystorage" ) func main() { plugins := &ambient.PluginLoader{ // Core plugins are implicitly trusted. Router: nil, TemplateEngine: nil, SessionManager: nil, // Trusted plugins are those that are typically needed to boot so they // will be enabled and given full access. TrustedPlugins: map[string]bool{}, Plugins: []ambient.Plugin{}, Middleware: []ambient.MiddlewarePlugin{ // Middleware - executes top to bottom. jwt.New([]byte(uuid.EncodedString(32)), time.Hour*1, []string{}), }, } _, _, err := ambientapp.NewApp("myapp", "1.0", zaplogger.New(), ambient.StoragePluginGroup{ Storage: memorystorage.New(), }, plugins) if err != nil { log.Fatalln(err.Error()) } }
Output:
func (*Plugin) GrantRequests ¶
func (p *Plugin) GrantRequests() []ambient.GrantRequest
GrantRequests returns a list of grants requested by the plugin.
func (*Plugin) Middleware ¶
Middleware returns router middleware.
func (*Plugin) PluginName ¶
PluginName returns the plugin name.
func (*Plugin) PluginVersion ¶
PluginVersion returns the plugin version.
type UnauthorizedResponse ¶
type UnauthorizedResponse struct {
}UnauthorizedResponse returns 401. swagger:response UnauthorizedResponse