Documentation
¶
Index ¶
- Constants
- Variables
- func AddTeamMember(ctx http.Context) http.Response
- func ConfirmTwoFactor(ctx http.Context) http.Response
- func CreateTeam(ctx http.Context) http.Response
- func CreateToken(ctx http.Context) http.Response
- func CurrentUser(ctx http.Context) http.Response
- func Dashboard(ctx http.Context) http.Response
- func DefaultConfig() map[string]any
- func DeleteAccount(ctx http.Context) http.Response
- func DeleteProfilePhoto(ctx http.Context) http.Response
- func DeleteTeam(ctx http.Context) http.Response
- func DeleteToken(ctx http.Context) http.Response
- func DisableTwoFactor(ctx http.Context) http.Response
- func EnableTwoFactor(ctx http.Context) http.Response
- func ForgotPassword(ctx http.Context) http.Response
- func GetDirection(locale string) string
- func GetRecoveryCodes(ctx http.Context) http.Response
- func GetSupportedLocales() []string
- func GetTeam(ctx http.Context) http.Response
- func GetTwoFactorQrCode(ctx http.Context) http.Response
- func Home(ctx http.Context) http.Response
- func IsRTL(locale string) bool
- func ListSessions(ctx http.Context) http.Response
- func ListTeams(ctx http.Context) http.Response
- func ListTokens(ctx http.Context) http.Response
- func Login(ctx http.Context) http.Response
- func Logout(ctx http.Context) http.Response
- func LogoutOtherBrowserSessions(ctx http.Context) http.Response
- func NewCsrfMiddleware() http.Middleware
- func NewJwtAuthMiddleware() http.Middleware
- func NewRateLimiterMiddleware() http.Middleware
- func RegenerateRecoveryCodes(ctx http.Context) http.Response
- func Register(ctx http.Context) http.Response
- func RegisterRoutes(router route.Route)
- func RegisterWebRoutes(router route.Route)
- func RemoveTeamMember(ctx http.Context) http.Response
- func Replace(s, old, new string) string
- func ResendEmailVerificationLink(ctx http.Context) http.Response
- func ResendVerificationEmail(ctx http.Context) http.Response
- func ResetPassword(ctx http.Context) http.Response
- func SendVerificationEmail(ctx http.Context) http.Response
- func ShowEmailVerificationNotice(ctx http.Context) http.Response
- func ShowForgotPasswordForm(ctx http.Context) http.Response
- func ShowLoginForm(ctx http.Context) http.Response
- func ShowProfile(ctx http.Context) http.Response
- func ShowRegisterForm(ctx http.Context) http.Response
- func ShowResetPasswordForm(ctx http.Context) http.Response
- func ShowSessionsPage(ctx http.Context) http.Response
- func Translate(key string, locale string) string
- func TranslateWithParams(key string, locale string, params map[string]string) string
- func UpdatePassword(ctx http.Context) http.Response
- func UpdateProfile(ctx http.Context) http.Response
- func UpdateTeam(ctx http.Context) http.Response
- func UploadProfilePhoto(ctx http.Context) http.Response
- func VerifyEmail(ctx http.Context) http.Response
- func WebDeleteAccount(ctx http.Context) http.Response
- func WebDestroySession(ctx http.Context) http.Response
- func WebForgotPassword(ctx http.Context) http.Response
- func WebLogin(ctx http.Context) http.Response
- func WebLogout(ctx http.Context) http.Response
- func WebRegister(ctx http.Context) http.Response
- func WebResetPassword(ctx http.Context) http.Response
- func WebUpdatePassword(ctx http.Context) http.Response
- func WebUpdateProfile(ctx http.Context) http.Response
- func WebVerifyEmail(ctx http.Context) http.Response
- type AuthHandler
- type Authenticatable
- type CreatePersonalAccessTokensTable
- type CreateTeamInvitationsTable
- type CreateTeamUserTable
- type CreateTeamsTable
- type CreateUsersTable
- type CsrfMiddleware
- type Jetstream
- type JetstreamPasswordResetTokensTable
- type JetstreamSessionsTable
- type JwtAuth
- type NewAccessToken
- type PersonalAccessToken
- type ProfileHandler
- type RateLimiter
- type RateLimiterConfig
- type ServiceProvider
- type Session
- type Team
- type TeamInvitation
- type TeamMemberResponse
- type TeamUser
- type TokenableUser
- type User
Constants ¶
const ( // FeatureRegistration enables the user registration endpoint. FeatureRegistration = "registration" // FeatureProfilePhotos enables profile photo upload support. FeatureProfilePhotos = "profile-photos" // FeatureApiTokens enables personal access token management. FeatureApiTokens = "api-tokens" // FeatureDeleteAccount enables the account deletion endpoint. FeatureDeleteAccount = "delete-account" // FeatureTwoFactorAuthentication enables two-factor authentication (TOTP). FeatureTwoFactorAuthentication = "two-factor-authentication" // FeatureTeams enables team management and multi-tenancy support. FeatureTeams = "teams" // FeatureBrowserSessions enables tracking and logging out active browser sessions. FeatureBrowserSessions = "browser-sessions" )
Feature constants define toggleable features in Jetstream.
const BindingJetstream = "goravel.jetstream"
BindingJetstream is the container binding key for the Jetstream manager.
Variables ¶
var ( // App holds the Goravel application instance. App foundation.Application // ConfigFacade provides access to application configuration. ConfigFacade config.Config // OrmFacade provides access to the ORM for database operations. OrmFacade orm.Orm // HashFacade provides access to password hashing. HashFacade hash.Hash // AuthFacade provides access to authentication. // It is a function because auth requires the HTTP context. AuthFacade func(ctx ...http.Context) auth.Auth )
Package-level facade variables, resolved during Boot.
var Translations = map[string]map[string]string{
"en": {
"auth.login": "Login",
"auth.register": "Register",
"auth.logout": "Logout",
"auth.forgot_password": "Forgot Password",
"auth.reset_password": "Reset Password",
"auth.confirm_password": "Confirm Password",
"auth.email": "Email Address",
"auth.password": "Password",
"auth.remember_me": "Remember Me",
"auth.dont_have_account": "Don't have an account?",
"auth.already_have_account": "Already have an account?",
"auth.create_account": "Create Account",
"auth.sign_in": "Sign In",
"auth.welcome_back": "Welcome Back",
"validation.required": "This field is required.",
"validation.email": "Please enter a valid email address.",
"validation.min_length": "Password must be at least 8 characters.",
"validation.confirmed": "Password confirmation does not match.",
"validation.these_credentials": "These credentials do not match our records.",
"dashboard.title": "Dashboard",
"dashboard.welcome": "Welcome back, :name!",
"dashboard.here_you": "Here's what's happening with your account.",
"profile.title": "Profile Information",
"profile.update": "Update Profile",
"profile.name": "Full Name",
"profile.save": "Save Changes",
"profile.updated": "Profile updated successfully.",
"password.title": "Update Password",
"password.current": "Current Password",
"password.new": "New Password",
"password.updated": "Password updated successfully.",
"password.dont_match": "The provided password does not match your current password.",
"verification.title": "Verify Email",
"verification.message": "Thanks for signing up! Before getting started, could you verify your email address.",
"verification.resend": "Resend Verification Email",
"verification.sent": "A new verification link has been sent to your email address.",
"verification.verified": "Email verified successfully.",
"reset.title": "Reset Password",
"reset.no_problem": "No problem. Just enter your email and we'll send you a reset link.",
"reset.email_link": "Email Password Reset Link",
"reset.sent": "We have emailed your password reset link.",
"sessions.title": "Browser Sessions",
"sessions.manage": "Manage and logout your active sessions on other browsers and devices.",
"sessions.active": "Active Sessions",
"sessions.current": "Current Session",
"sessions.logout_other": "Logout Other Browser Sessions",
"sessions.deleted": "Session deleted successfully.",
"danger.title": "Delete Account",
"danger.warning": "Permanently delete your account and all associated data.",
"danger.warning_download": "Before deleting your account, please download any data or information that you wish to retain.",
"danger.delete": "Delete Account",
"danger.deleted": "Account deleted successfully.",
"button.cancel": "Cancel",
"button.save": "Save",
"button.update": "Update",
"button.delete": "Delete",
"button.edit": "Edit",
"button.create": "Create",
"button.submit": "Submit",
"error.title": "Error",
"error.403": "Forbidden",
"error.404": "Page Not Found",
"error.500": "Server Error",
"error.unauthorized": "Unauthenticated.",
"error.forbidden": "You do not have permission to access this page.",
},
"ar": {
"auth.login": "تسجيل الدخول",
"auth.register": "التسجيل",
"auth.logout": "تسجيل الخروج",
"auth.forgot_password": "نسيت كلمة المرور",
"auth.reset_password": "إعادة تعيين كلمة المرور",
"auth.confirm_password": "تأكيد كلمة المرور",
"auth.email": "البريد الإلكتروني",
"auth.password": "كلمة المرور",
"auth.remember_me": "تذكرني",
"auth.dont_have_account": "ليس لديك حساب؟",
"auth.already_have_account": "لديك حساب بالفعل؟",
"auth.create_account": "إنشاء حساب",
"auth.sign_in": "تسجيل الدخول",
"auth.welcome_back": "مرحباً بعودتك",
"validation.required": "هذا الحقل مطلوب.",
"validation.email": "الرجاء إدخال بريد إلكتروني صحيح.",
"validation.min_length": "يجب أن تكون كلمة المرور 8 أحرف على الأقل.",
"validation.confirmed": "تأكيد كلمة المرور غير متطابق.",
"validation.these_credentials": "هذه البيانات لا تتطابق مع سجلاتنا.",
"dashboard.title": "لوحة التحكم",
"dashboard.welcome": "مرحباً بعودتك، :name!",
"dashboard.here_you": "إليك ما يحدث مع حسابك.",
"profile.title": "معلومات الملف الشخصي",
"profile.update": "تحديث الملف الشخصي",
"profile.name": "الاسم الكامل",
"profile.save": "حفظ التغييرات",
"profile.updated": "تم تحديث الملف الشخصي بنجاح.",
"password.title": "تحديث كلمة المرور",
"password.current": "كلمة المرور الحالية",
"password.new": "كلمة المرور الجديدة",
"password.updated": "تم تحديث كلمة المرور بنجاح.",
"password.dont_match": "كلمة المرور المقدمة لا تتطابق مع كلمة المرور الحالية.",
"verification.title": "التحقق من البريد الإلكتروني",
"verification.message": "شكراً لتسجيلك! قبل البدء، هل يمكنك التحقق من عنوان بريدك الإلكتروني.",
"verification.resend": "إعادة إرسال رابط التحقق",
"verification.sent": "تم إرسال رابط تحقق جديد إلى عنوان بريدك الإلكتروني.",
"verification.verified": "تم التحقق من البريد الإلكتروني بنجاح.",
"reset.title": "إعادة تعيين كلمة المرور",
"reset.no_problem": "لا مشكلة. فقط أدخل بريدك الإلكتروني وسنرسل لك رابط إعادة التعيين.",
"reset.email_link": "إرسال رابط إعادة تعيين كلمة المرور",
"reset.sent": "لقد أرسلنا رابط إعادة تعيين كلمة المرور إلى بريدك الإلكتروني.",
"sessions.title": "جلسات المتصفح",
"sessions.manage": "إدارة وتسجيل الخروج من جلساتك النشطة على المتصفحات والأجهزة الأخرى.",
"sessions.active": "الجلسات النشطة",
"sessions.current": "الجلسة الحالية",
"sessions.logout_other": "تسجيل الخروج من المتصفحات الأخرى",
"sessions.deleted": "تم حذف الجلسة بنجاح.",
"danger.title": "حذف الحساب",
"danger.warning": "حذف حسابك وجميع البيانات المرتبطة بشكل دائم.",
"danger.warning_download": "قبل حذف حسابك، يرجى تنزيل أي بيانات أو معلومات ترغب في الاحتفاظ بها.",
"danger.delete": "حذف الحساب",
"danger.deleted": "تم حذف الحساب بنجاح.",
"button.cancel": "إلغاء",
"button.save": "حفظ",
"button.update": "تحديث",
"button.delete": "حذف",
"button.edit": "تعديل",
"button.create": "إنشاء",
"button.submit": "إرسال",
"error.title": "خطأ",
"error.403": "محظور",
"error.404": "الصفحة غير موجودة",
"error.500": "خطأ في الخادم",
"error.unauthorized": "غير مصدق.",
"error.forbidden": "ليس لديك إذن للوصول إلى هذه الصفحة.",
},
"id": {
"auth.login": "Masuk",
"auth.register": "Daftar",
"auth.logout": "Keluar",
"auth.forgot_password": "Lupa Kata Sandi",
"auth.reset_password": "Reset Kata Sandi",
"auth.confirm_password": "Konfirmasi Kata Sandi",
"auth.email": "Alamat Email",
"auth.password": "Kata Sandi",
"auth.remember_me": "Ingat Saya",
"auth.dont_have_account": "Tidak punya akun?",
"auth.already_have_account": "Sudah punya akun?",
"auth.create_account": "Buat Akun",
"auth.sign_in": "Masuk",
"auth.welcome_back": "Selamat Datang Kembali",
"validation.required": "Kolom ini wajib diisi.",
"validation.email": "Silakan masukkan alamat email yang valid.",
"validation.min_length": "Kata sandi harus minimal 8 karakter.",
"validation.confirmed": "Konfirmasi kata sandi tidak cocok.",
"validation.these_credentials": "Kredensial ini tidak cocok dengan catatan kami.",
"dashboard.title": "Dasbor",
"dashboard.welcome": "Selamat datang kembali, :name!",
"dashboard.here_you": "Berikut yang terjadi dengan akun Anda.",
"profile.title": "Informasi Profil",
"profile.update": "Perbarui Profil",
"profile.name": "Nama Lengkap",
"profile.save": "Simpan Perubahan",
"profile.updated": "Profil berhasil diperbarui.",
"password.title": "Ubah Kata Sandi",
"password.current": "Kata Sandi Saat Ini",
"password.new": "Kata Sandi Baru",
"password.updated": "Kata sandi berhasil diperbarui.",
"password.dont_match": "Kata sandi yang diberikan tidak cocok dengan kata sandi Anda saat ini.",
"verification.title": "Verifikasi Email",
"verification.message": "Terima kasih telah mendaftar! Sebelum memulai, bisakah Anda memverifikasi alamat email Anda.",
"verification.resend": "Kirim Ulang Link Verifikasi",
"verification.sent": "Link verifikasi baru telah dikirim ke alamat email Anda.",
"verification.verified": "Email berhasil diverifikasi.",
"reset.title": "Reset Kata Sandi",
"reset.no_problem": "Tidak masalah. Cukup masukkan email Anda dan kami akan mengirim link reset.",
"reset.email_link": "Kirim Link Reset Kata Sandi",
"reset.sent": "Kami telah mengirim link reset kata sandi ke email Anda.",
"sessions.title": "Sesi Peramban",
"sessions.manage": "Kelola dan keluar dari sesi aktif Anda di peramban dan perangkat lain.",
"sessions.active": "Sesi Aktif",
"sessions.current": "Sesi Saat Ini",
"sessions.logout_other": "Keluar dari Peramban Lain",
"sessions.deleted": "Sesi berhasil dihapus.",
"danger.title": "Hapus Akun",
"danger.warning": "Hapus akun Anda dan semua data terkait secara permanen.",
"danger.warning_download": "Sebelum menghapus akun Anda, silakan unduh data atau informasi yang ingin Anda simpan.",
"danger.delete": "Hapus Akun",
"danger.deleted": "Akun berhasil dihapus.",
"button.cancel": "Batal",
"button.save": "Simpan",
"button.update": "Perbarui",
"button.delete": "Hapus",
"button.edit": "Edit",
"button.create": "Buat",
"button.submit": "Kirim",
"error.title": "Kesalahan",
"error.403": "Dilarang",
"error.404": "Halaman Tidak Ditemukan",
"error.500": "Kesalahan Server",
"error.unauthorized": "Tidak terautentikasi.",
"error.forbidden": "Anda tidak memiliki izin untuk mengakses halaman ini.",
},
}
Translations contains all Jetstream localization strings
Functions ¶
func AddTeamMember ¶
AddTeamMember invites a user to a team by email. POST /api/teams/{id}/members
func ConfirmTwoFactor ¶
ConfirmTwoFactor confirms 2FA setup by verifying a 6-digit code. POST /api/user/confirmed-two-factor-authentication
func CreateTeam ¶
CreateTeam creates a new team owned by the authenticated user. POST /api/teams
Request body:
{
"name": "string"
}
func CreateToken ¶
CreateToken creates a new personal access token for the authenticated user. POST /api/user/tokens
Request body:
{
"name": "string",
"abilities": ["string"] // optional, defaults to ["*"]
}
func CurrentUser ¶
CurrentUser returns the currently authenticated user's information. GET /api/user
func DefaultConfig ¶
DefaultConfig returns the default Jetstream configuration map. Users should copy this into their config/jetstream.go file, or use it directly: config.Add("jetstream", jetstream.DefaultConfig())
func DeleteAccount ¶
DeleteAccount deletes the authenticated user's account after password confirmation. DELETE /api/user
Request body:
{
"password": "string"
}
func DeleteProfilePhoto ¶
DeleteProfilePhoto removes the user's profile photo from storage and clears the DB field. DELETE /api/user/profile-photo
func DeleteTeam ¶
DeleteTeam deletes a team. DELETE /api/teams/{id}
func DeleteToken ¶
DeleteToken deletes a personal access token for the authenticated user. DELETE /api/user/tokens/{id}
func DisableTwoFactor ¶
DisableTwoFactor disables 2FA for the user. DELETE /api/user/two-factor-authentication
func EnableTwoFactor ¶
EnableTwoFactor generates a new TOTP secret & recovery codes for the user. POST /api/user/two-factor-authentication
func ForgotPassword ¶
ForgotPassword handles the forgot password request. POST /api/forgot-password
func GetDirection ¶
GetDirection returns the text direction for the given locale
func GetRecoveryCodes ¶
GetRecoveryCodes returns the user's recovery codes. GET /api/user/two-factor-recovery-codes
func GetSupportedLocales ¶
func GetSupportedLocales() []string
GetSupportedLocales returns a list of supported locales
func GetTeam ¶
GetTeam returns team details, owner, members, and pending invitations. GET /api/teams/{id}
func GetTwoFactorQrCode ¶
GetTwoFactorQrCode returns the QR code Data URI for scanning in Authenticator apps. GET /api/user/two-factor-qr-code
func ListSessions ¶
ListSessions returns all active tokens/sessions for the authenticated user, including IP addresses and User-Agent strings. GET /api/user/sessions
func ListTokens ¶
ListTokens returns all personal access tokens for the authenticated user. GET /api/user/tokens
func Login ¶
Login handles user authentication. POST /api/auth/login
Request body:
{
"email": "string",
"password": "string"
}
func Logout ¶
Logout handles user logout by invalidating the current JWT token. POST /api/auth/logout
func LogoutOtherBrowserSessions ¶
LogoutOtherBrowserSessions revokes all tokens/sessions for the user EXCEPT the current token. DELETE /api/user/other-browser-sessions
Request body:
{
"password": "string"
}
func NewCsrfMiddleware ¶
func NewCsrfMiddleware() http.Middleware
NewCsrfMiddleware returns a new CsrfMiddleware instance.
func NewJwtAuthMiddleware ¶
func NewJwtAuthMiddleware() http.Middleware
NewJwtAuthMiddleware returns a new JwtAuth middleware instance.
func NewRateLimiterMiddleware ¶
func NewRateLimiterMiddleware() http.Middleware
NewRateLimiterMiddleware returns a new RateLimiter middleware instance.
func RegenerateRecoveryCodes ¶
RegenerateRecoveryCodes generates new recovery codes for the user. POST /api/user/two-factor-recovery-codes
func Register ¶
Register handles user registration. POST /api/auth/register
Request body:
{
"name": "string",
"email": "string",
"password": "string",
"password_confirmation": "string"
}
func RegisterRoutes ¶
RegisterRoutes registers all Jetstream API routes on the given route instance. This is called automatically by the ServiceProvider during Boot.
func RegisterWebRoutes ¶
RegisterWebRoutes registers all Jetstream web routes (HTML views). These routes provide the UI pages for login, register, dashboard, and profile. Call this function in your routes/web.go file.
func RemoveTeamMember ¶
RemoveTeamMember removes a member from a team. DELETE /api/teams/{id}/members/{user_id}
func ResendEmailVerificationLink ¶
ResendEmailVerificationLink resends the verification email. POST /email/verification-notification
func ResendVerificationEmail ¶
ResendVerificationEmail resends the verification email. POST /api/email/resend
func ResetPassword ¶
ResetPassword handles the password reset request. POST /api/reset-password
func SendVerificationEmail ¶
SendVerificationEmail sends a verification email to the authenticated user. POST /api/email/verification-notification
func ShowEmailVerificationNotice ¶
ShowEmailVerificationNotice displays the email verification notice page. GET /email/verification-notification
func ShowForgotPasswordForm ¶
ShowForgotPasswordForm displays the forgot password page. GET /forgot-password
func ShowLoginForm ¶
ShowLoginForm displays the login page. GET /login
func ShowProfile ¶
ShowProfile displays the profile editing page. GET /profile
func ShowRegisterForm ¶
ShowRegisterForm displays the registration page. GET /register
func ShowResetPasswordForm ¶
ShowResetPasswordForm displays the reset password page. GET /reset-password/{token}
func ShowSessionsPage ¶
ShowSessionsPage displays the browser sessions management page. GET /user/sessions
func TranslateWithParams ¶
TranslateWithParams returns the translation with parameter replacement
func UpdatePassword ¶
UpdatePassword updates the authenticated user's password. PUT /api/user/password
Request body:
{
"current_password": "string",
"password": "string",
"password_confirmation": "string"
}
func UpdateProfile ¶
UpdateProfile updates the authenticated user's profile information. PUT /api/user/profile
Request body:
{
"name": "string",
"email": "string"
}
func UpdateTeam ¶
UpdateTeam updates a team's name. PUT /api/teams/{id}
func UploadProfilePhoto ¶
UploadProfilePhoto uploads a profile photo image to storage and updates the user's profile. POST /api/user/profile-photo
func VerifyEmail ¶
VerifyEmail verifies a user's email address. GET /api/email/verify/{id}/{hash}
func WebDeleteAccount ¶
WebDeleteAccount handles account deletion via web form. DELETE /user
func WebDestroySession ¶
WebDestroySession destroys a specific session. DELETE /user/sessions/{session_id}
func WebForgotPassword ¶
WebForgotPassword handles the forgot password form submission. POST /forgot-password
func WebRegister ¶
WebRegister handles user registration via web form. POST /register
func WebResetPassword ¶
WebResetPassword handles the reset password form submission. POST /reset-password
func WebUpdatePassword ¶
WebUpdatePassword handles password update via web form. PUT /user/password
func WebUpdateProfile ¶
WebUpdateProfile handles profile update via web form. PUT /user/profile-information
Types ¶
type AuthHandler ¶
type AuthHandler interface {
// Register handles user registration.
Register(ctx http.Context) http.Response
// Login handles user authentication.
Login(ctx http.Context) http.Response
// Logout handles user logout.
Logout(ctx http.Context) http.Response
}
AuthHandler defines custom authentication behavior. Implement this interface to override default auth logic.
type Authenticatable ¶
type Authenticatable interface {
// GetID returns the unique identifier for the user.
GetID() uint
// GetEmail returns the user's email address.
GetEmail() string
// GetPassword returns the user's hashed password.
GetPassword() string
}
Authenticatable defines the interface that your User model must implement to work with Jetstream authentication.
type CreatePersonalAccessTokensTable ¶
type CreatePersonalAccessTokensTable struct{}
CreatePersonalAccessTokensTable is the migration that creates the personal_access_tokens table.
func (*CreatePersonalAccessTokensTable) Down ¶
func (r *CreatePersonalAccessTokensTable) Down() error
func (*CreatePersonalAccessTokensTable) Signature ¶
func (r *CreatePersonalAccessTokensTable) Signature() string
func (*CreatePersonalAccessTokensTable) Up ¶
func (r *CreatePersonalAccessTokensTable) Up() error
type CreateTeamInvitationsTable ¶
type CreateTeamInvitationsTable struct{}
CreateTeamInvitationsTable is the migration that creates the team_invitations table.
func (*CreateTeamInvitationsTable) Down ¶
func (r *CreateTeamInvitationsTable) Down() error
func (*CreateTeamInvitationsTable) Signature ¶
func (r *CreateTeamInvitationsTable) Signature() string
func (*CreateTeamInvitationsTable) Up ¶
func (r *CreateTeamInvitationsTable) Up() error
type CreateTeamUserTable ¶
type CreateTeamUserTable struct{}
CreateTeamUserTable is the migration that creates the team_user pivot table.
func (*CreateTeamUserTable) Down ¶
func (r *CreateTeamUserTable) Down() error
func (*CreateTeamUserTable) Signature ¶
func (r *CreateTeamUserTable) Signature() string
func (*CreateTeamUserTable) Up ¶
func (r *CreateTeamUserTable) Up() error
type CreateTeamsTable ¶
type CreateTeamsTable struct{}
CreateTeamsTable is the migration that creates the teams table.
func (*CreateTeamsTable) Down ¶
func (r *CreateTeamsTable) Down() error
func (*CreateTeamsTable) Signature ¶
func (r *CreateTeamsTable) Signature() string
func (*CreateTeamsTable) Up ¶
func (r *CreateTeamsTable) Up() error
type CreateUsersTable ¶
type CreateUsersTable struct{}
CreateUsersTable is the migration that creates the users table.
func (*CreateUsersTable) Down ¶
func (r *CreateUsersTable) Down() error
func (*CreateUsersTable) Signature ¶
func (r *CreateUsersTable) Signature() string
func (*CreateUsersTable) Up ¶
func (r *CreateUsersTable) Up() error
type CsrfMiddleware ¶
type CsrfMiddleware struct{}
CsrfMiddleware provides CSRF protection for web routes. This middleware validates the CSRF token sent in requests to prevent cross-site request forgery attacks.
func (*CsrfMiddleware) Handle ¶
func (m *CsrfMiddleware) Handle(ctx http.Context)
Handle processes the incoming HTTP request and validates the CSRF token.
func (*CsrfMiddleware) Signature ¶
func (m *CsrfMiddleware) Signature() string
Signature returns the unique identifier for this middleware.
type Jetstream ¶
type Jetstream struct {
// contains filtered or unexported fields
}
Jetstream is the core manager that holds configuration and provides feature checking capabilities.
func NewJetstream ¶
NewJetstream creates a new Jetstream instance with the given config.
func (*Jetstream) GetAuthGuard ¶
GetAuthGuard returns the configured authentication guard name.
func (*Jetstream) GetRoutePrefix ¶
GetRoutePrefix returns the configured route prefix.
func (*Jetstream) HasFeature ¶
HasFeature checks if a given feature is enabled in the Jetstream configuration.
type JetstreamPasswordResetTokensTable ¶
type JetstreamPasswordResetTokensTable struct{}
CreatePasswordResetTokensTable creates the password_reset_tokens table.
func (*JetstreamPasswordResetTokensTable) Down ¶
func (r *JetstreamPasswordResetTokensTable) Down() error
func (*JetstreamPasswordResetTokensTable) Signature ¶
func (r *JetstreamPasswordResetTokensTable) Signature() string
func (*JetstreamPasswordResetTokensTable) Up ¶
func (r *JetstreamPasswordResetTokensTable) Up() error
type JetstreamSessionsTable ¶
type JetstreamSessionsTable struct{}
CreateSessionsTable creates the sessions table for web session tracking.
func (*JetstreamSessionsTable) Down ¶
func (r *JetstreamSessionsTable) Down() error
func (*JetstreamSessionsTable) Signature ¶
func (r *JetstreamSessionsTable) Signature() string
func (*JetstreamSessionsTable) Up ¶
func (r *JetstreamSessionsTable) Up() error
type JwtAuth ¶
type JwtAuth struct{}
JwtAuth is an HTTP middleware that verifies JWT tokens from the Authorization header. If the token is invalid or missing, it returns a 401 Unauthorized response.
type NewAccessToken ¶
type NewAccessToken struct {
AccessToken *PersonalAccessToken `json:"access_token"`
PlainTextToken string `json:"plain_text_token"`
}
NewAccessToken holds the result of creating a new personal access token. PlainTextToken is only available at creation time and is never stored.
type PersonalAccessToken ¶
type PersonalAccessToken struct {
orm.Model
UserID uint `gorm:"not null;index" json:"user_id"`
Name string `gorm:"not null" json:"name"`
Token string `gorm:"uniqueIndex;not null;size:64" json:"-"`
Abilities string `gorm:"type:text;default:'[\"*\"]'" json:"abilities"`
IPAddress string `gorm:"default:null" json:"ip_address,omitempty"`
UserAgent string `gorm:"default:null" json:"user_agent,omitempty"`
LastUsedAt string `gorm:"default:null" json:"last_used_at,omitempty"`
ExpiresAt string `gorm:"default:null" json:"expires_at,omitempty"`
}
PersonalAccessToken represents an API token or browser session issued to a user. Tokens are stored as SHA-256 hashes; the plain-text token is only returned once at creation time.
type ProfileHandler ¶
type ProfileHandler interface {
// UpdateProfile handles profile information updates.
UpdateProfile(ctx http.Context) http.Response
// UpdatePassword handles password changes.
UpdatePassword(ctx http.Context) http.Response
// DeleteAccount handles account deletion.
DeleteAccount(ctx http.Context) http.Response
}
ProfileHandler defines custom profile management behavior.
type RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
RateLimiter provides rate limiting functionality to prevent abuse.
func NewRateLimiterWithConfig ¶
func NewRateLimiterWithConfig(config RateLimiterConfig) *RateLimiter
NewRateLimiterWithConfig creates a new RateLimiter with the given configuration.
func (*RateLimiter) Cleanup ¶
func (r *RateLimiter) Cleanup()
Cleanup removes expired entries from the rate limiter.
func (*RateLimiter) GetRemaining ¶
func (r *RateLimiter) GetRemaining(identifier string) int
GetRemaining returns the number of remaining requests for the identifier.
func (*RateLimiter) Handle ¶
func (m *RateLimiter) Handle(ctx http.Context)
Handle processes the incoming HTTP request and enforces rate limiting.
func (*RateLimiter) IsLimited ¶
func (r *RateLimiter) IsLimited(identifier string) bool
IsLimited checks if the identifier has exceeded the rate limit.
func (*RateLimiter) RecordRequest ¶
func (r *RateLimiter) RecordRequest(identifier string)
RecordRequest records a request for the given identifier.
func (*RateLimiter) Signature ¶
func (m *RateLimiter) Signature() string
Signature returns the unique identifier for this middleware.
type RateLimiterConfig ¶
type RateLimiterConfig struct {
MaxRequests int // Maximum requests allowed in the window
Window time.Duration // Time window for rate limiting
}
RateLimiterConfig holds the configuration for the rate limiter.
func DefaultRateLimiterConfig ¶
func DefaultRateLimiterConfig() RateLimiterConfig
DefaultRateLimiterConfig returns the default rate limiter configuration.
type ServiceProvider ¶
type ServiceProvider struct{}
ServiceProvider registers Jetstream's services and routes into the Goravel application container.
Usage in bootstrap/providers.go:
&jetstream.ServiceProvider{}
func (*ServiceProvider) Boot ¶
func (r *ServiceProvider) Boot(app foundation.Application)
Boot resolves facade dependencies and registers routes. This is called after all service providers have been registered, ensuring that Auth, Hash, ORM, and Route are available.
func (*ServiceProvider) Register ¶
func (r *ServiceProvider) Register(app foundation.Application)
Register binds the Jetstream manager into the service container.
type Team ¶
type Team struct {
orm.Model
UserID uint `gorm:"not null;index" json:"user_id"` // Owner ID
Name string `gorm:"not null" json:"name"`
PersonalTeam bool `gorm:"default:false" json:"personal_team"`
}
Team represents a team/organization in Jetstream.
type TeamInvitation ¶
type TeamInvitation struct {
orm.Model
TeamID uint `gorm:"not null;index" json:"team_id"`
Email string `gorm:"not null" json:"email"`
Role string `gorm:"default:'editor'" json:"role"`
}
TeamInvitation represents a pending invitation to join a team.
type TeamMemberResponse ¶
type TeamMemberResponse struct {
ID uint `json:"id"`
Name string `json:"name"`
Email string `json:"email"`
Role string `json:"role"`
JoinedAt string `json:"joined_at"`
}
TeamMemberResponse represents a team member returned in API responses.
type TeamUser ¶
type TeamUser struct {
orm.Model
TeamID uint `gorm:"not null;index" json:"team_id"`
UserID uint `gorm:"not null;index" json:"user_id"`
Role string `gorm:"default:'editor'" json:"role"`
}
TeamUser is the pivot model linking users to teams with specific roles.
type TokenableUser ¶
type TokenableUser interface {
Authenticatable
}
TokenableUser extends Authenticatable with API token capabilities.
type User ¶
type User struct {
orm.Model
Name string `gorm:"not null" json:"name"`
Email string `gorm:"uniqueIndex;not null" json:"email"`
Password string `gorm:"not null" json:"-"`
EmailVerifiedAt *time.Time `gorm:"default:null" json:"email_verified_at,omitempty"`
ProfilePhotoPath string `gorm:"default:null" json:"profile_photo_path,omitempty"`
TwoFactorSecret string `gorm:"default:null" json:"-"`
TwoFactorRecoveryCodes string `gorm:"type:text;default:null" json:"-"`
TwoFactorConfirmedAt string `gorm:"default:null" json:"two_factor_confirmed_at,omitempty"`
CurrentTeamID uint `gorm:"default:null" json:"current_team_id,omitempty"`
}
User is the default user model provided by Jetstream. It embeds orm.Model which provides ID, CreatedAt, and UpdatedAt fields.
func (*User) GetPassword ¶
GetPassword returns the user's hashed password.
func (*User) HasTwoFactorEnabled ¶
HasTwoFactorEnabled checks if the user has 2FA enabled and confirmed.
func (*User) HasVerifiedEmail ¶
HasVerifiedEmail checks if the user has verified their email.
Source Files
¶
- auth_controller.go
- config.go
- contracts.go
- dashboard_web_controller.go
- email_verification_controller.go
- email_verification_web_controller.go
- helpers.go
- jetstream.go
- localization.go
- middleware.go
- middleware_csrf.go
- middleware_rate_limiter.go
- migrations.go
- password_reset_controller.go
- password_reset_web_controller.go
- personal_access_token.go
- photo_controller.go
- profile_controller.go
- profile_web_controller.go
- requests.go
- responses.go
- routes.go
- service_provider.go
- session_controller.go
- session_web_controller.go
- team.go
- team_controller.go
- token_controller.go
- two_factor_controller.go
- user.go