{"record":{"id":"0a7256556e08cfa4","repo":"dromara/Sa-Token","slug":"http-digest","errorCode":null,"errorMessage":"未配置全局 Http Digest 认证参数","messagePattern":"未配置全局 Http Digest 认证参数","errorType":"validation","errorClass":"SaTokenException","httpStatus":null,"severity":"error","filePath":"sa-token-core/src/main/java/cn/dev33/satoken/httpauth/digest/SaHttpDigestTemplate.java","lineNumber":262,"sourceCode":"    }\n\n    /**\n     * 校验：根据提供的参数，校验不通过抛出异常\n     * @param username 用户名\n     * @param password 密码\n     * @param realm 领域\n     */\n    public void check(String username, String password, String realm) {\n        check(new SaHttpDigestModel(username, password, realm));\n    }\n\n    /**\n     * 校验：根据全局配置参数，校验不通过抛出异常\n     */\n    public void check() {\n        String httpDigest = SaManager.getConfig().getHttpDigest();\n        if(SaFoxUtil.isEmpty(httpDigest)){\n            throw new SaTokenException(\"未配置全局 Http Digest 认证参数\");\n        }\n        String[] arr = httpDigest.split(\":\");\n        if(arr.length != 2){\n            throw new SaTokenException(\"全局 Http Digest 认证参数配置错误，格式应如：username:password\");\n        }\n        check(arr[0], arr[1]);\n    }\n\n\n\n    // ----------------- 过期方法 -----------------\n\n    /**\n     * 根据注解 ( @SaCheckHttpDigest ) 鉴权\n     *\n     * @param at 注解对象\n     */\n    @Deprecated","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/dromara/Sa-Token/blob/ac2c7f6e94a78573cf0bcb932dd8b04e68fad189/sa-token-core/src/main/java/cn/dev33/satoken/httpauth/digest/SaHttpDigestTemplate.java#L244-L280","documentation":"SaTokenException thrown by the no-arg SaHttpDigestTemplate.check() when the global configuration item 'httpDigest' is empty. The no-arg check() is designed to validate against credentials stored in the global Sa-Token config (format username:password), so it refuses to run when that config is missing.","triggerScenarios":"Calling saTokenHttpDigestTemplate.check() (no arguments) while SaManager.getConfig().getHttpDigest() returns null or empty string. This happens when using @SaCheckHttpDigest with neither value nor username attributes, which makes the interceptor fall back to the global-config check().","commonSituations":"Adding @SaCheckHttpDigest to a controller without specifying value/username/realm and forgetting to set sa-token.http-digest in application.yml/properties; migrating config where the http-digest key was renamed or dropped; environment-specific config files (dev/prod) where only one defines the key.","solutions":["Set the global config, e.g. in application.yml: sa-token: http-digest: username:password (or sa-token.http-digest=username:password in properties)","Or specify credentials per-annotation: @SaCheckHttpDigest(username=\"admin\", password=\"123456\") or @SaCheckHttpDigest(\"admin:123456\")","Or call the explicit overload check(username, password) / check(model) instead of the no-arg check()"],"exampleFix":"// before\n@SaCheckHttpDigest\n@GetMapping(\"/data\")\npublic SaResult data() { ... }\n// application.yml has no http-digest -> exception\n\n// after\n# application.yml\nsa-token:\n  http-digest: admin:123456","handlingStrategy":"validation","validationCode":"String httpDigest = SaManager.getConfig().getHttpDigest();\nif (SaFoxUtil.isEmpty(httpDigest)) {\n    // fail fast at startup with a clear message, or skip the no-arg check()\n}","typeGuard":null,"tryCatchPattern":"try {\n    saTokenHttpDigestTemplate.check();\n} catch (SaTokenException e) {\n    if (\"未配置全局 Http Digest 认证参数\".equals(e.getMessage())) { /* config missing: fix config */ }\n    throw e;\n}","preventionTips":["Set sa-token.http-digest in config at the same time you add @SaCheckHttpDigest annotations","Prefer explicit credentials: @SaCheckHttpDigest(username=..., password=...) over relying on global config","Add a startup config assertion for required security settings"],"tags":["http-digest","configuration","sa-token"],"backgroundTag":null,"analyzedSha":"ac2c7f6e94a78573cf0bcb932dd8b04e68fad189","analyzedAt":"2026-08-14T14:36:10.271Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}