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

登录失败,请问 enc 参数应该填哪个 #28

Closed
ramondsq opened this issue Nov 29, 2023 · 16 comments
Closed

登录失败,请问 enc 参数应该填哪个 #28

ramondsq opened this issue Nov 29, 2023 · 16 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@ramondsq
Copy link

日志和配置文件如下,其他参数都按照请求对应填写了,只有 enc 参数不清楚该填哪个

log

2023-11-29 22:20:59 [INFO] 正在获取登录状态
2023-11-29 22:20:59 [DEBU] HTTP GET  http://172.16.245.50/cgi-bin/rad_user_info
2023-11-29 22:20:59 [DEBU] jQuery1701267659291280900({"client_ip":"10.24.20.229","ecode":0,"error":"not_online_error","error_msg":"","online_ip":"10.24.20.229","res":"not_online_error","srun_ver":"SRunCGIAuthIntfSvr V1.18 B20211028","st":1701267694})
2023-11-29 22:20:59 [DEBU] 认证客户端 ip:  10.24.20.229
2023-11-29 22:20:59 [INFO] 检测到用户未登录,开始尝试登录...
2023-11-29 22:20:59 [DEBU] 正在获取 Token
2023-11-29 22:20:59 [DEBU] HTTP GET  http://172.16.245.50/cgi-bin/get_challenge
2023-11-29 22:20:59 [DEBU] jQuery1701267659296699900({"challenge":"404b351fba3619454ccf7d70728ce46c06bee268662fcb8137da77861df9be59","client_ip":"10.24.20.229","ecode":0,"error":"ok","error_msg":"","expire":"60","online_ip":"10.24.20.229","res":"ok","srun_ver":"SRunCGIAuthIntfSvr V1.18 B20211028","st":1701267694})
2023-11-29 22:20:59 [DEBU] token:  404b351fba3619454ccf7d70728ce46c06bee268662fcb8137da77861df9be59
2023-11-29 22:20:59 [DEBU] 发送登录请求
2023-11-29 22:20:59 [DEBU] HTTP GET  http://172.16.245.50/cgi-bin/srun_portal
2023-11-29 22:20:59 [DEBU] jQuery1701267659300148000({"client_ip":"10.24.20.229","ecode":"E2806","error":"login_error","error_msg":"E2806: Products is not found (39).","online_ip":"10.24.20.229","res":"login_error","srun_ver":"SRunCGIAuthIntfSvr V1.18 B20211028","st":1701267694})
2023-11-29 22:20:59 [ERRO] 登录出错:  login_error

image
Snipaste_2023-11-29_22-28-10

@Mmx233
Copy link
Owner

Mmx233 commented Nov 30, 2023

enc 可能在网页的 query 中。Products is not found 可能是你的 usertype 或者登录地址不正确,有的学校宿舍网络和免费教育网络认证地址不一样,混用就会出现 Products is not found

@Mmx233
Copy link
Owner

Mmx233 commented Nov 30, 2023

如果哪里都找不到 enc 的话,我建议你将其置为空字符串

@ramondsq
Copy link
Author

如果哪里都找不到 enc 的话,我建议你将其置为空字符串

info 参数前面几个字符是 SRBX1 ,应该是对应 enc 参数的 srun_bx1 ?
image

@Mmx233
Copy link
Owner

Mmx233 commented Nov 30, 2023

程序中是固定的 SRBX1,我目前没见过有别的值,所以不清楚这个前缀具体意味着什么

@ramondsq
Copy link
Author

如果哪里都找不到 enc 的话,我建议你将其置为空字符串

尝试了把 enc 参数设置为空字符串,依旧是错误信息 E2806: Products is not found (39).

另外就是注意到登录成功后 rad_user_info 里包含了 product 相关信息,不知道是否有用

image

@Mmx233
Copy link
Owner

Mmx233 commented Nov 30, 2023

从你给的图片中的信息可以看出 usertype 的值是正确的,但是无法判断登录失败的原因。新的 release 1.4.5 中添加了 4 个新的可配置字段,我不确定这是否能解决你的问题,但你可以试试调整他们

@Mmx233
Copy link
Owner

Mmx233 commented Nov 30, 2023

我发现我不小心忽略了控制台的截图,你的配置确实没有问题。要找出问题在哪需要一些深入的研究

@ramondsq
Copy link
Author

ramondsq commented Dec 1, 2023

从你给的图片中的信息可以看出 usertype 的值是正确的,但是无法判断登录失败的原因。新的 release 1.4.5 中添加了 4 个新的可配置字段,我不确定这是否能解决你的问题,但你可以试试调整他们

试了一下 release 1.4.5 ,enc 参数无论是默认值还是空值依旧是相同的错误 E2806: Products is not found (39).

Condig.yaml

image

log

2023-12-01 09:56:05 [INFO] 正在获取登录状态
2023-12-01 09:56:05 [DEBU] HTTP GET  http://172.16.245.50/cgi-bin/rad_user_info
2023-12-01 09:56:05 [DEBU] jQuery1701395765127808000({"client_ip":"10.30.49.213","ecode":0,"error":"not_online_error","error_msg":"","online_ip":"10.30.49.213","res":"not_online_error","srun_ver":"SRunCGIAuthIntfSvr V1.18 B20211028","st":1701395765})
2023-12-01 09:56:05 [DEBU] 认证客户端 ip:  10.30.49.213
2023-12-01 09:56:05 [INFO] 检测到用户未登录,开始尝试登录...
2023-12-01 09:56:05 [DEBU] 正在获取 Token
2023-12-01 09:56:05 [DEBU] HTTP GET  http://172.16.245.50/cgi-bin/get_challenge
2023-12-01 09:56:05 [DEBU] jQuery1701395765143987000({"challenge":"fc2d515883d0ab14e00eea07f3a358f27b76b2679aec72f14f32f20f21f74341","client_ip":"10.30.49.213","ecode":0,"error":"ok","error_msg":"","expire":"35","online_ip":"10.30.49.213","res":"ok","srun_ver":"SRunCGIAuthIntfSvr V1.18 B20211028","st":1701395765})
2023-12-01 09:56:05 [DEBU] token:  fc2d515883d0ab14e00eea07f3a358f27b76b2679aec72f14f32f20f21f74341
2023-12-01 09:56:05 [DEBU] 发送登录请求
2023-12-01 09:56:05 [DEBU] HTTP GET  http://172.16.245.50/cgi-bin/srun_portal
2023-12-01 09:56:05 [DEBU] jQuery1701395765150509000({"client_ip":"10.30.49.213","ecode":"E2806","error":"login_error","error_msg":"E2806: Products is not found (39).","online_ip":"10.30.49.213","res":"login_error","srun_ver":"SRunCGIAuthIntfSvr V1.18 B20211028","st":1701395765})
2023-12-01 09:56:05 [ERRO] 登录出错:  login_error

以下是网页实现登陆逻辑的相关 js 文件,不知道是否有帮助。在此还是非常感谢 Mmx233 的帮助
jquery.srun.portal.js: https://pastebin.ubuntu.com/p/FRgz4N8Mwq/
main.js: https://pastebin.ubuntu.com/p/89vws8rYSv/

@Mmx233
Copy link
Owner

Mmx233 commented Dec 1, 2023

我对比了你的 jquery.srun.portal.js,除了多了一段 OAuth 以及一些显示方面的区别之外没有差异

你在正常登录时有对路径 /v1/srun_portal_oauth 的请求吗

    /**
     * oauth2 协议登录
     * Url:/v1/srun_portal_oauth
     */
    function oauth(url, params, callback) {
        $.get(autoBuildUrl(url) + "/v1/srun_portal_oauth" + params, callback);
    }

    /**
     * oauth Auth
     */
    $.OAuth = function (url, data, callback) {
        var urlParams = location.search;

        var ssoCallback = function (response) {
            if (response.Code === 200) {
                return callback({
                    error: 200,
                    message: "OK",
                    ac_id: response.ID
                });
            } else if (response.Code === 301) {
                location.href = response.Redirect
            }

            var message = error(0, response.Message);
            return callback({
                error: "fail",
                code: response.Code,
                redirect: response.Redirect,
                message: message
            });
        };
        oauth(url, urlParams, ssoCallback)
    };

    /**
     * double auth
     * Url: /v1/srun_portal_double
     */
    function ddiDoubleAuth(url, params, callback) {
        $.get(autoBuildUrl(url) + "/v1/srun_portal_double" + params, callback);
    }

    $.DdiDoubleAuth = function (url, callback) {
        var ddiCallback = function (response) {
            return callback({
                code: response.code,
                message: response.message
            })
        };
        ddiDoubleAuth(url, location.search, ddiCallback)
    };

@Mmx233
Copy link
Owner

Mmx233 commented Dec 1, 2023

根据你的 jquery.srun.portal.js,你的 enc 是 srun_bx1,enc 会影响 info 字段的编码结果

var enc = "s" + "run" + "_bx1", n = 200, type = 1;

@ramondsq
Copy link
Author

ramondsq commented Dec 1, 2023

我对比了你的 jquery.srun.portal.js,除了多了一段 OAuth 以及一些显示方面的区别之外没有差异

你在正常登录时有对路径 /v1/srun_portal_oauth 的请求吗

没有对 /v1/srun_portal_oauth 的请求

image

@Mmx233
Copy link
Owner

Mmx233 commented Dec 1, 2023

这样的话 srun_portal 的逻辑和表单是完全一致的,那问题是不是出在 get_challenge 这边呢,这个请求的表单是不是 callback username ip_

@ramondsq
Copy link
Author

ramondsq commented Dec 1, 2023

这样的话 srun_portal 的逻辑和表单是完全一致的,那问题是不是出在 get_challenge 这边呢,这个请求的表单是不是 callback username ip_

是的,如图

Snipaste_2023-12-01_16-15-50

@Mmx233
Copy link
Owner

Mmx233 commented Dec 1, 2023

我找到问题了,示例配置文件和实际配置文件不一致,你需要将 userType 的 T 大写或者使用程序自动自动生成的配置文件填写配置

@Mmx233 Mmx233 added bug Something isn't working good first issue Good for newcomers labels Dec 1, 2023
Mmx233 added a commit that referenced this issue Dec 1, 2023
@Mmx233
Copy link
Owner

Mmx233 commented Dec 1, 2023

新的 release 中修正这个字段为 user_type 并修复了一个 bug

@Mmx233 Mmx233 closed this as completed Dec 1, 2023
@ramondsq
Copy link
Author

ramondsq commented Dec 1, 2023

可以成功登陆了,感谢作者 Mmx233 帮助排查问题,配置如图,坐标 SWPU

Snipaste_2023-12-01_16-36-02

Snipaste_2023-12-01_16-36-49

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants