Groovy execution time is too slow in CAS 7.0.0-RC9.BUG?

77 views Asked by At

I have got problem with long execution time of basic groovy script:

cas.propierties:

cas.authn.attribute-repository.groovy[0].location=file:/etc/cas/config/custom-attr.groovy

custom-attr.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
}

System CAS params has been showed after startup :

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

Logs:

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]}]>

This problem has occurred only when we attached groovy without groovy authentication work smooth. Groovy is slow or wait but after let say 15sek returned additional metadata.What is the problem or where find out solution of 15sek timeout ?

To eliminate 15sek .

1

There are 1 answers

0
artur mis On

Is this only the very first time or always? It is always more than 10sec for contenerized cas or 5 sec for not contenerized cas . 5sec or 10sec is too much .It should be ms . For this basic script we don't have any connection to other services

I have made dipper digging in TRACE mode seted in cas.properties and i found out that problem can be "creating groovy object instannce"

cas logs:

2023-12-13 11:03:36,183 TRACE [org.apereo.cas.util.scripting.ScriptingUtils] - <Creating groovy object instance from class [/etc/cas/config/custom-attr.groovy]>

time out 14sek
 

2023-12-13 11:03:50,884 TRACE [org.apereo.cas.util.scripting.ScriptingUtils] - <Executing groovy script's [run] method, with parameters [[test, {principal=[test], credentialId=[test], credentialClass=[UsernamePasswordCredential], username=[test]}, org.apache.logging.slf4j.Log4jLogger@3e812f4a, org.apereo.cas.configuration.CasConfigurationProperties@646427f7, org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@2e6d76ba, started on Wed Dec 13 10:55:27 GMT+01:00 2023, parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@30af7377]]> 2023-12-13 11:03:50,897 DEBUG [org.apereo.cas.authentication.principal.resolvers.InternalGroovyScriptDao] - <[custom-attr]: The received uid is [test]> 2023-12-13 11:03:50,898 DEBUG [org.apereo.cas.authentication.principal.resolvers.InternalGroovyScriptDao]