auth_external.go 582 B

123456789101112131415161718192021222324252627
  1. package dbus
  2. import (
  3. "encoding/hex"
  4. )
  5. // AuthExternal returns an Auth that authenticates as the given user with the
  6. // EXTERNAL mechanism.
  7. func AuthExternal(user string) Auth {
  8. return authExternal{user}
  9. }
  10. // AuthExternal implements the EXTERNAL authentication mechanism.
  11. type authExternal struct {
  12. user string
  13. }
  14. func (a authExternal) FirstData() ([]byte, []byte, AuthStatus) {
  15. b := make([]byte, 2*len(a.user))
  16. hex.Encode(b, []byte(a.user))
  17. return []byte("EXTERNAL"), b, AuthOk
  18. }
  19. func (a authExternal) HandleData(b []byte) ([]byte, AuthStatus) {
  20. return nil, AuthError
  21. }