(ctx context.Context, c *websocket.Conn, req WebRTCSessionRequest)
| 397 | } |
| 398 | |
| 399 | func 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 | |
| 430 | func handleSessionRequest( |
| 431 | ctx context.Context, |
no test coverage detected