github.com/mhilton/juju-juju@v0.0.0-20150901100907-a94dd2c73455/apiserver/authentication/authenticator.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 // FindEntityAuthenticator looks up the authenticator for the entity identified tag. 12 func FindEntityAuthenticator(entity state.Entity) (EntityAuthenticator, error) { 13 switch entity.(type) { 14 case *state.Machine, *state.Unit: 15 return &AgentAuthenticator{}, nil 16 case *state.User: 17 return &UserAuthenticator{}, nil 18 } 19 20 return nil, common.ErrBadRequest 21 }