Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Auth\Simple class creates unnecessary sessions

未关闭
#2,684 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
74/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
php

调研方向

从 src/SimpleSAML/Auth/Simple.php 开始,重点查看构造函数和 isAuthenticated(),然后阅读 src/SimpleSAML/Session.php 和 src/SimpleSAML/SessionHandlerPHP.php 中相关的会话处理。重现 issue 中的干净浏览器场景,并为构造 Auth\Simple 和检查身份验证添加或更新覆盖率。完成的标准是:在不存在会话时,不会创建 SimpleSAML Cookie 或新的会话文件。

由索引模型根据 Issue 内容生成。

描述

Specifics of your environment

Using SimpleSAMLphp 2.4.10-slim as an SP as documented, using default PHP sessions.

Describe the bug

The \SimpleSAML\Auth\Simple constructor creates a session even if one doesn't exist from before. This is not necessary if the class is only used to check isAuthenticated(), and causes unnecessary session files to be written on the host.

To Reproduce

$auth = new \SimpleSAML\Auth\Simple('default-sp');
if (!$auth->isAuthenticated()) {
    print('<a href="/login">Login</a>');
}

With the default SimpleSAMLphp configuration.
When visiting with a clean browser (private tab), a cookie SimpleSAML is set.

Expected behavior

No cookie was set because we didn't do anything, and there was no pre-existing session.

Additional context

The documentation suggests that the session is activated upon calling isAuthenticated(), but the session is already created in the constructor, and isAuthenticated() does nothing that can trigger a session to be created.

I didn't call \SimpleSAML\Session::getSessionFromRequest()->cleanup();, as there is no previous session it wouldn't have done anything.

主要语言
PHP
星标
1.1k
派生
704
平均合并
1 天 15 小时
30 天内合并 PR
4

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

simplesamlphp/simplesamlphp 的其他 Issue

查看 simplesamlphp/simplesamlphp 的全部 Issue

相似的 Issue

更多 PHP Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。