MCPcopy Index your code
hub / github.com/koding/kite / registerUser

Method registerUser

kontrol/kontrol.go:363–387  ·  view source on GitHub ↗
(username, publicKey, privateKey string)

Source from the content-addressed store, hash-verified

361}
362
363func (k *Kontrol) registerUser(username, publicKey, privateKey string) (kiteKey string, err error) {
364 id, err := uuid.NewV4()
365 if err != nil {
366 return "", err
367 }
368 claims := &kitekey.KiteClaims{
369 StandardClaims: jwt.StandardClaims{
370 Issuer: k.Kite.Kite().Username,
371 Subject: username,
372 IssuedAt: time.Now().Add(-k.tokenLeeway()).UTC().Unix(),
373 Id: id.String(),
374 },
375 KontrolURL: k.Kite.Config.KontrolURL,
376 KontrolKey: strings.TrimSpace(publicKey),
377 }
378
379 rsaPrivate, err := jwt.ParseRSAPrivateKeyFromPEM([]byte(privateKey))
380 if err != nil {
381 return "", err
382 }
383
384 k.Kite.Log.Info("Registered machine on user: %s", username)
385
386 return jwt.NewWithClaims(jwt.GetSigningMethod("RS256"), claims).SignedString(rsaPrivate)
387}
388
389// registerSelf adds Kontrol itself to the storage as a kite.
390func (k *Kontrol) registerSelf() {

Callers 3

HandleMachineMethod · 0.95
InitializeSelfMethod · 0.95
TestRegisterMachineFunction · 0.80

Calls 5

tokenLeewayMethod · 0.95
InfoMethod · 0.80
AddMethod · 0.65
KiteMethod · 0.45
StringMethod · 0.45

Tested by 1

TestRegisterMachineFunction · 0.64