setRedirectURL($config['redirect_uri']); $oidc->addScope($config['scopes']); $oidc->setResponseTypes([$config['response_type']]); // This will read the `code` query parameter, fetch the tokens // and validate everything. $oidc->authenticate(); // Fetch the OpenID Connect userinfo claims $claims = $oidc->requestUserInfo(); // → stdClass with the claims // Store what we need in the PHP session $_SESSION['authenticated'] = true; $_SESSION['name'] = $claims->name ?? $claims->given_name ?? $claims->family_name ?? ''; $_SESSION['email'] = $claims->email ?? ''; $_SESSION['groups'] = $claims->groups ?? []; // Redirect back to the home page header('Location: ../'); exit;