github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/apiserver/authentication/macaroon/authenticator.go (about)

     1  // Copyright 2023 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package macaroon
     5  
     6  import (
     7  	"context"
     8  
     9  	"github.com/go-macaroon-bakery/macaroon-bakery/v3/bakery"
    10  	"github.com/juju/names/v5"
    11  	"gopkg.in/macaroon.v2"
    12  
    13  	"github.com/juju/juju/apiserver/authentication"
    14  )
    15  
    16  // LocalMacaroonAuthenticator extends Authenticator with a method of
    17  // creating a local login macaroon. The authenticator is expected to
    18  // honour the resulting macaroon.
    19  type LocalMacaroonAuthenticator interface {
    20  	authentication.RequestAuthenticator
    21  
    22  	// CreateLocalLoginMacaroon creates a macaroon that may be
    23  	// provided to a user as proof that they have logged in with
    24  	// a valid username and password. This macaroon may then be
    25  	// used to obtain a discharge macaroon so that the user can
    26  	// log in without presenting their password for a set amount
    27  	// of time.
    28  	CreateLocalLoginMacaroon(context.Context, names.UserTag, bakery.Version) (*macaroon.Macaroon, error)
    29  }