github.com/goravel/framework@v1.13.9/auth/service_provider.go (about)

     1  package auth
     2  
     3  import (
     4  	"context"
     5  
     6  	"github.com/goravel/framework/auth/access"
     7  	"github.com/goravel/framework/auth/console"
     8  	contractconsole "github.com/goravel/framework/contracts/console"
     9  	"github.com/goravel/framework/contracts/foundation"
    10  )
    11  
    12  const BindingAuth = "goravel.auth"
    13  const BindingGate = "goravel.gate"
    14  
    15  type ServiceProvider struct {
    16  }
    17  
    18  func (database *ServiceProvider) Register(app foundation.Application) {
    19  	app.Singleton(BindingAuth, func(app foundation.Application) (any, error) {
    20  		config := app.MakeConfig()
    21  		return NewAuth(config.GetString("auth.defaults.guard"),
    22  			app.MakeCache(), config, app.MakeOrm()), nil
    23  	})
    24  	app.Singleton(BindingGate, func(app foundation.Application) (any, error) {
    25  		return access.NewGate(context.Background()), nil
    26  	})
    27  }
    28  
    29  func (database *ServiceProvider) Boot(app foundation.Application) {
    30  	database.registerCommands(app)
    31  }
    32  
    33  func (database *ServiceProvider) registerCommands(app foundation.Application) {
    34  	app.MakeArtisan().Register([]contractconsole.Command{
    35  		console.NewJwtSecretCommand(app.MakeConfig()),
    36  		console.NewPolicyMakeCommand(),
    37  	})
    38  }