MCPcopy Create free account
hub / github.com/jetkvm/kvm / authenticateSession

Function authenticateSession

cloud.go:399–428  ·  view source on GitHub ↗
(ctx context.Context, c *websocket.Conn, req WebRTCSessionRequest)

Source from the content-addressed store, hash-verified

397}
398
399func authenticateSession(ctx context.Context, c *websocket.Conn, req WebRTCSessionRequest) error {
400 oidcCtx, cancelOIDC := context.WithTimeout(ctx, CloudOidcRequestTimeout)
401 defer cancelOIDC()
402 provider, err := oidc.NewProvider(oidcCtx, "https://accounts.google.com")
403 if err != nil {
404 _ = wsjson.Write(context.Background(), c, gin.H{
405 "error": fmt.Sprintf("failed to initialize OIDC provider: %v", err),
406 })
407 cloudLogger.Warn().Err(err).Msg("failed to initialize OIDC provider")
408 return err
409 }
410
411 oidcConfig := &oidc.Config{
412 SkipClientIDCheck: true,
413 }
414
415 verifier := provider.Verifier(oidcConfig)
416 idToken, err := verifier.Verify(oidcCtx, req.OidcGoogle)
417 if err != nil {
418 return err
419 }
420
421 googleIdentity := idToken.Audience[0] + ":" + idToken.Subject
422 if config.GoogleIdentity != googleIdentity {
423 _ = wsjson.Write(context.Background(), c, gin.H{"error": "google identity mismatch"})
424 return fmt.Errorf("google identity mismatch")
425 }
426
427 return nil
428}
429
430func handleSessionRequest(
431 ctx context.Context,

Callers 1

handleSessionRequestFunction · 0.85

Calls 3

WarnMethod · 0.80
ErrorfMethod · 0.80
WriteMethod · 0.45

Tested by

no test coverage detected