github.com/goravel/framework@v1.13.9/contracts/auth/auth.go (about) 1 package auth 2 3 import ( 4 "time" 5 6 "github.com/goravel/framework/contracts/http" 7 ) 8 9 //go:generate mockery --name=Auth 10 type Auth interface { 11 // Guard attempts to get the guard against the local cache. 12 Guard(name string) Auth 13 // Parse the given token. 14 Parse(ctx http.Context, token string) (*Payload, error) 15 // User returns the current authenticated user. 16 User(ctx http.Context, user any) error 17 // Login logs a user into the application. 18 Login(ctx http.Context, user any) (token string, err error) 19 // LoginUsingID logs the given user ID into the application. 20 LoginUsingID(ctx http.Context, id any) (token string, err error) 21 // Refresh the token for the current user. 22 Refresh(ctx http.Context) (token string, err error) 23 // Logout logs the user out of the application. 24 Logout(ctx http.Context) error 25 } 26 27 type Payload struct { 28 Guard string 29 Key string 30 ExpireAt time.Time 31 IssuedAt time.Time 32 }