Documentation
¶
Overview ¶
Package authgoblue provides JWT-based authentication middleware and services for Go applications.
Index ¶
- Constants
- Variables
- type AuthGoBlue
- func (a *AuthGoBlue) Config() Config
- func (a *AuthGoBlue) Email(c fiber.Ctx) (string, error)
- func (a *AuthGoBlue) HasPermission(c fiber.Ctx, permission string) (bool, error)
- func (a *AuthGoBlue) Permissions(c fiber.Ctx) ([]string, error)
- func (a *AuthGoBlue) Role(c fiber.Ctx) (string, error)
- func (a *AuthGoBlue) SetupLogin(provider providers.Provider)
- func (a *AuthGoBlue) SignIn(ctx context.Context, req login.Request) (*login.Result, error)
- func (a *AuthGoBlue) UserID(c fiber.Ctx) (string, error)
- func (a *AuthGoBlue) Username(c fiber.Ctx) (string, error)
- type Config
Constants ¶
View Source
const Version = "1.0.0"
Variables ¶
View Source
var ( // Config ErrSecretRequired = errors.New("github.com/qwerius/authgoblue: secret is required") ErrIssuerRequired = errors.New("github.com/qwerius/authgoblue: issuer is required") // JWT ErrInvalidToken = errors.New("github.com/qwerius/authgoblue: invalid token") ErrExpiredToken = errors.New("github.com/qwerius/authgoblue: token has expired") ErrInvalidClaims = errors.New("github.com/qwerius/authgoblue: invalid claims") ErrTokenTypeMismatch = errors.New("github.com/qwerius/authgoblue: invalid token type") // Authorization ErrForbidden = errors.New("github.com/qwerius/authgoblue: forbidden") // Context ErrUserNotFound = errors.New("github.com/qwerius/authgoblue: user not found in context") // Password ErrInvalidPassword = errors.New("github.com/qwerius/authgoblue: invalid password") ErrPasswordHash = errors.New("github.com/qwerius/authgoblue: failed to hash password") )
Functions ¶
This section is empty.
Types ¶
type AuthGoBlue ¶
type AuthGoBlue struct {
Token *token.Service
Password *password.Service
Context *ctx.Service
RoleService *role.Service
Permission *permission.Service
Revoke *revoke.Service
Session *session.Service
Middleware *middleware.Service
Providers *providers.Registry
Storage *storage.Registry
Hooks *hooks.Registry
Refresh *refresh.Service
Logout *logout.Service
LogoutHandler *logout.Handler
Login *login.Service
// contains filtered or unexported fields
}
func New ¶
func New(config Config) *AuthGoBlue
func (*AuthGoBlue) Config ¶
func (a *AuthGoBlue) Config() Config
func (*AuthGoBlue) HasPermission ¶
func (*AuthGoBlue) Permissions ¶
func (a *AuthGoBlue) Permissions( c fiber.Ctx, ) ([]string, error)
func (*AuthGoBlue) SetupLogin ¶
func (a *AuthGoBlue) SetupLogin( provider providers.Provider, )
SetupLogin menghubungkan user provider dengan login service.
Provider berasal dari aplikasi pengguna module. Bisa berasal dari database, LDAP, API, dll.
type Config ¶
type Config struct {
// Secret key untuk signing JWT
Secret string
// Nama aplikasi/service
Issuer string
// Durasi access token
AccessTokenTTL time.Duration
// Durasi refresh token
RefreshTokenTTL time.Duration
Header string
Prefix string
Cookie bool
CookieName string
// Session storage
// default MemoryStore
SessionStore session.Store
// Maximum active sessions per user
// default 5
MaxSessions int
// Token revoke storage
// default MemoryStore
RevokeStore revoke.Store
}
func DefaultConfig ¶
func DefaultConfig() Config
Source Files
¶
Click to show internal directories.
Click to hide internal directories.