Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] 不同网络环境需要不同的ac_id #38

Merged
merged 3 commits into from
Nov 6, 2021
Merged

Conversation

halozhy
Copy link
Contributor

@halozhy halozhy commented Nov 5, 2021

问题版本

ipgw v0.2.0-beta+2021-11-03T15:25:14+0000
操作系统:Windows 10 21H1 19043.1288

现象

在浑南图书馆 NEU 无线网环境下使用 ipgw 工具登录,显示已登录成功,但是 ping 不通公网,公网网页也无法打开

image-20211105143103108.png

问题定位

经本人测试,拉取最新 master 分支代码,将 /pkg/handler/ipgw.go 104 行 url 中的 ac_id=1 改为 ac_id=15 即可

resp, err := h.client.Get("https://pass.neu.edu.cn/tpass/login?service=http://ipgw.neu.edu.cn/srun_portal_sso?ac_id=1")

原因推测

在浑南图书馆 NEU 无线网环境下正常打开 ipgw 网关页面 https://ipgw.neu.edu.cn/ ,可见其 url 参数为 ac_id=15

image-20211105143358333.png

这个参数不可能凭空出现,抓包可见,访问 ipgw 网关主页面后,会先访问 https://ipgw.neu.edu.cn/index_1.html 这个页面,之后根据返回的302重定向来跳转至正确的 ac_id 带参页面

image-20211105143408766.png

代码修改

据此,我对代码进行了一次修改,在进行统一认证前先访问 https://ipgw.neu.edu.cn/index_1.html 拿到对应的 ac_id 参数,之后进行正常的统一认证登录。

目前经个人测试已经解决图书馆 NEU 无线网的登录问题,理论上也能自适应其它网络环境

@Neboer
Copy link

Neboer commented Nov 5, 2021

很棒,终于有人提出这个问题了。
我在两天之前更新ipgw-py-manager的时候也发现了这个问题,只不过我们南湖这里的无线网ac_id为16,这个参数貌似在不同网络环境下会变得不同。
Portal.js中对这个参数的解释是“校园网流量进位方式”,但是显然这个参数的意义远远不是如此,具体的含义还可以继续研究。
这个pr的质量很高,描述也非常清楚,非常谢谢!
希望白能尽快修复这个问题哦

@Neboer
Copy link

Neboer commented Nov 5, 2021

另外补充一下,ipgw还有一些操作的url参数里涉及到这个ac_id,比如注销。如果可以的话,是不是也要把其他用到这个参数的地方的代码一并改了?

@halozhy
Copy link
Contributor Author

halozhy commented Nov 5, 2021

我这边测试注销的时候没有发现这个问题,执行 ipgw logout 命令能够正常注销,也许这个参数对注销没有影响吧

@Neboer
Copy link

Neboer commented Nov 5, 2021

是这样啊,感觉学校这api做的还不够完善和统一啊。什么时候出一个api document,也算是了我们的心愿了。

是先锋的同学吗?真的很棒啊,加油😂

@halozhy
Copy link
Contributor Author

halozhy commented Nov 5, 2021

确实是浑南先锋的,感谢夸奖🥰

@amtoaer
Copy link
Member

amtoaer commented Nov 5, 2021

感谢修复!因为之前一直是在浑南五舍进行的测试,没有发现这个问题 XD (老宅男了

另外补充一下,ipgw 还有一些操作的 url 参数里涉及到这个 ac_id,比如注销。

在注销操作中,带有该参数的地址是作为Referer出现的,对操作本身没有影响。另外刚刚尝试去掉了Referer,注销操作依然可以成功.. 😂

@unbyte
Copy link
Member

unbyte commented Nov 5, 2021

棒,我去年收集过一份学校各建筑的id,但是忘记扔哪了😂

@amtoaer
Copy link
Member

amtoaer commented Nov 6, 2021

浑南五舍去除ac_id参数可以正常登录:

image

image

@halozhy
Copy link
Contributor Author

halozhy commented Nov 6, 2021

浑南五舍去除ac_id参数可以正常登录:

现在在浑南图书馆测了,去了 ac_id 不太行,
image
浑南五舍的 ac_id 浑南二舍一样,都是1,怀疑缺省条件下,这个参数默认值是1,所以在宿舍环境下可以缺省 ac_id 登陆成功

@unbyte unbyte changed the title [fix] 解决一个在浑南图书馆NEU无线网遇到的问题 [fix] 不同网络环境需要不同的ac_id Nov 6, 2021
@unbyte unbyte merged commit 4245181 into neucn:master Nov 6, 2021
@xuwhao
Copy link

xuwhao commented Nov 7, 2021

image
image
有人遇到过这两种问题吗 貌似手机登录 的逻辑又不一样?

@amtoaer
Copy link
Member

amtoaer commented Nov 7, 2021

@xuwhao 我仅遇到过 cas username is empty 的情况,主要是两个场景:

  1. 认证后过段时间再访问该地址(推测是 ticket 过期)
  2. 统一认证登录的 service 写错
    resp, err = h.client.Get("https://pass.neu.edu.cn/tpass/login?service=http://ipgw.neu.edu.cn/srun_portal_sso")
    如此处将 service 地址误写为 https ,用拿到的 ticket 请求 api 会出现该错误。

@unbyte
Copy link
Member

unbyte commented Nov 7, 2021

@xuwhao 网关后端需要用ticket向cas获取用户名,而ticket是签发给固定service url的,所以service url不一样,或者ticket过期都会导致这个问题。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants