我遇到了基本 groovy 脚本执行时间较长的问题:
cas.properties:
cas.authn.attribute-repository.groovy[0].location=file:/etc/cas/config/custom-attr.groovy
自定义属性.groovy:
import java.util.*
import java.text.SimpleDateFormat
import groovy.transform.Field
import javax.naming.directory.*
import java.util.Hashtable
import javax.naming.*
@Field File file = new File("/etc/cas/config/groovy_logs.txt")
def run(final Object... args) {
def (username,attributes,logger,properties,appContext) = args
logger.debug("[{}]: The received uid is [{}]", this.class.simpleName, username)
file.append "\n login: "+args[0]+" cas-id:"+args[1]['principal']+"\n"
file.append "\n version groove: "+GroovySystem.version+"\n"
// All attribute values must be defined as a collection wrapped in []
return [username:[username], likes:["6cheese", "7food"], id:[1234,2,3,4,5], another:["attribute"] ]
println GroovySystem.version
}
启动后已显示系统CAS参数:
CAS Version: 7.0.0-RC9
CAS Branch: master
CAS Commit Id: xxxxxxxxxxx
CAS Build Date/Time: 2023-11-25T07:12:15.881468Z
Spring Boot Version: 3.2.0
Spring Version: 6.1.0
Java Home: /usr/lib/jvm/zulu21-ca-amd64
Java Vendor: Azul Systems, Inc.
Java Version: 21.0.1
Servlet Version: 6.0.0
JVM Free Memory: 345 MB
JVM Maximum Memory: 4 GB
JVM Total Memory: 512 MB
OS Architecture: amd64
OS Name: Linux
OS Version: 5.4.0-167-generic
OS Date/Time: 2023-12-12T10:35:50.786113719
OS Temp Directory: /tmp
日志:
2023-12-12 10:41:41,731 DEBUG [org.apereo.cas.authentication.attribute.PrincipalAttributeRepositoryFetcher] - <Fetching person attributes for query [{principal=xxxxxx data xxxxxxx}]>
no activity in the log (just waiting )
2023-12-12 10:41:55,497 DEBUG [org.apereo.cas.authentication.principal.resolvers.InternalGroovyScriptDao] - <[custom-attr]: The received uid is [christmas_banny]>
2023-12-12 10:41:55,497 DEBUG [org.apereo.cas.authentication.principal.resolvers.InternalGroovyScriptDao] - <Groovy-based attributes found are [{username=[christmas_banny], likes=[6cheese, 7food], id=[1234, 2, 3, 4, 5], another=[attribute]}]>
只有当我们附加groovy而没有groovy身份验证工作顺利时才会出现此问题。 Groovy 很慢或等待,但假设 15sek 返回了额外的元数据。问题是什么或在哪里找到 15sek 超时的解决方案?
消除15sek .
这只是第一次还是一直如此? 对于串行化的 CAS 总是超过 10 秒,对于非串行化的 CAS 总是超过 5 秒。 5秒或10秒太多了。应该是毫秒。 对于这个基本脚本,我们没有与其他服务的任何连接
我已经在 cas.properties 中设置的 TRACE 模式下进行了铲斗挖掘,我发现问题可能是“创建 groovy 对象实例”
cas 日志:
2023-12-13 11:03:36,183 跟踪 [org.apereo.cas.util.scripting.ScriptingUtils] -
time out 14sek
2023-12-13 11:03:50,884 跟踪 [org.apereo.cas.util.scripting.ScriptingUtils] -