github.com/mhilton/juju-juju@v0.0.0-20150901100907-a94dd2c73455/apiserver/authentication/user.go (about)

     1  // Copyright 2014 Canonical Ltd. All rights reserved.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package authentication
     5  
     6  import (
     7  	"github.com/juju/juju/apiserver/common"
     8  	"github.com/juju/juju/state"
     9  )
    10  
    11  // UserIdentityProvider performs authentication for users.
    12  type UserAuthenticator struct {
    13  	AgentAuthenticator
    14  }
    15  
    16  var _ EntityAuthenticator = (*UserAuthenticator)(nil)
    17  
    18  // Authenticate authenticates the provided entity and returns an error on authentication failure.
    19  func (u *UserAuthenticator) Authenticate(entity state.Entity, password, nonce string) error {
    20  	if _, ok := entity.(*state.User); ok {
    21  		return u.AgentAuthenticator.Authenticate(entity, password, nonce)
    22  	}
    23  
    24  	return common.ErrBadRequest
    25  }