MCPcopy Create free account
hub / github.com/koding/kite / HandleMachine

Method HandleMachine

kontrol/handlers.go:244–275  ·  view source on GitHub ↗
(r *kite.Request)

Source from the content-addressed store, hash-verified

242}
243
244func (k *Kontrol) HandleMachine(r *kite.Request) (interface{}, error) {
245 var args struct {
246 AuthType string
247 }
248
249 err := r.Args.One().Unmarshal(&args)
250 if err != nil {
251 return nil, err
252 }
253
254 var keyPair *KeyPair
255
256 if k.MachineAuthenticate != nil {
257 // an empty authType is ok, the implementer is responsible of it. It
258 // can care of it or it can return an error
259 if err := k.MachineAuthenticate(args.AuthType, r); err != nil {
260 k.Kite.Log.Error("machine authentication error: %s", err)
261
262 return nil, fmt.Errorf("cannot authenticate user: %s", err)
263 }
264
265 keyPair, err = k.KeyPair()
266 } else {
267 keyPair, err = k.pickKey(r)
268 }
269
270 if err != nil {
271 return nil, err
272 }
273
274 return k.registerUser(r.Client.Kite.Username, keyPair.Public, keyPair.Private)
275}
276
277func (k *Kontrol) HandleGetKey(r *kite.Request) (interface{}, error) {
278 // Only accept requests with kiteKey because we need this info

Callers

nothing calls this directly

Calls 6

KeyPairMethod · 0.95
pickKeyMethod · 0.95
registerUserMethod · 0.95
UnmarshalMethod · 0.80
OneMethod · 0.80
ErrorMethod · 0.65

Tested by

no test coverage detected