Yes, full groovy below, and all we have set in config,

cas.interrupt.core.trigger-mode=AFTER_SSO
cas.interrupt.groovy.location=file:/etc/cas/scripts/interrupt.groovy


import org.apereo.cas.interrupt.InterruptResponse

def run(final Object... args) {
    def principal = args[0]
    def attributes = args[1]
    def service = args[2]
    def registeredService = args[3]
    def requestContext = args[4]
    def logger = args[5]
    
    message = "Test message";
    redirect_to = [link1: ""];
    block = false;
    sso_enabled = true;
    interrupt_flow = false;
   
    if (interrupt_enabled) {
        if (registeredService) {
            svc_id = 0;
            if (registeredService.containsKey('id')) {
                svc_id = registeredService.id.intValue();
            }
            svc_list = [106, 108];
            url1 = "https://url......";;
            url2 =  "https://url......";;
            url3 =  "https://url......";;
           
            if 
(authentication.principal.attributes.containsKey('eduPersonAffiliation')) {
                edu_affiliation = 
principal.attributes.eduPersonAffiliation.join(", ");
                profile_list = ["faculty", "staff", "student"];
                if (profile_list.contains(edu_affiliation)) {
                    if (svc_list.contains(svc_id)) {
                        interrupt_flow = true;
                        if (svc_id == 106) {
                            redirect_to = [link1: url1];
                        }
                        if (svc_id == 108) {
                            redirect_to = [link1: url2];
                        }
                    }
                }
            }
        }
    }
    return new InterruptResponse(message: message, links: redirect_to, 
block: block, ssoEnabled: sso_enabled, interrupt: interrupt_flow, 
autoRedirect: true)
}

On Friday, February 17, 2023 at 7:19:09 AM UTC-6 Josh wrote:

> Thanks for the reply John.
>
> Are you using "def run(final Object... args) { }" as your function 
> definition?
>
> Like the original poster, I have reverted back to using the out of the box 
> example in the documentation for interrupts, however it's just not finding 
> it according to the DEBUG logs. 
>
> On Thursday, February 16, 2023 at 10:17:04 PM UTC-5 John wrote:
>
>> Works fine for us on 6.6.4, using something below
>>
>>     message = "Test message";
>>     redirect_to = [link1: ""];
>>     block = false;
>>     sso_enabled = true;
>>     interrupt_flow = false;
>>     
>>     if (interrupt_enabled) {
>>         if (registeredService) {
>>             svc_id = 0;
>>             if (registeredService.containsKey('id')) {
>>                 svc_id = registeredService.id.intValue();
>>             }
>>             svc_list = [106, 108];
>>             url1 = "https://url......";;
>>             url2 =  "https://url......";; 
>>             url3 =  "https://url......";; 
>>             
>>             if 
>> (authentication.principal.attributes.containsKey('eduPersonAffiliation')) {
>>                 edu_affiliation = 
>> principal.attributes.eduPersonAffiliation.join(", ");
>>                 profile_list = ["faculty", "staff", "student"];
>>                 if (profile_list.contains(edu_affiliation)) {
>>                     if (svc_list.contains(svc_id)) {
>>                         interrupt_flow = true;
>>                         if (svc_id == 106) {
>>                             redirect_to = [link1: url1];
>>                         }
>>                         if (svc_id == 108) {
>>                             redirect_to = [link1: url2];
>>                         }
>>                     }
>>                 }
>>             }
>>         }
>>     }
>>     return new InterruptResponse(message: message, links: redirect_to, 
>> block: block, ssoEnabled: sso_enabled, interrupt: interrupt_flow, 
>> autoRedirect: true)
>>
>> On Thursday, February 16, 2023 at 2:36:31 PM UTC-6 Josh wrote:
>>
>>> We're seeing the same thing on our end moving from 6.4.x to 6.6.x
>>>
>>> 2023-02-16 18:52:47,362 DEBUG 
>>> [org.apereo.cas.interrupt.webflow.actions.InquireInterruptAction] - 
>>> <Invoking interrupt inquirer using [GroovyScriptInterruptInquirer]>
>>> 2023-02-16 18:52:47,362 DEBUG 
>>> [org.apereo.cas.interrupt.BaseInterruptInquirer] - <Service [XYZ] is set to 
>>> allow interrupt notifications>
>>> 2023-02-16 18:52:47,362 DEBUG 
>>> [org.apereo.cas.interrupt.webflow.actions.InquireInterruptAction] - 
>>> <Webflow interrupt is skipped since no inquirer produced a response>
>>>
>>> Is anyone else experiencing this issue and have a fix?
>>>
>>> On Saturday, May 14, 2022 at 8:00:01 PM UTC-4 mago...@hacc.edu wrote:
>>>
>>>> Built CAS 6.5.3 with:
>>>> support-interrupt-webflow
>>>>
>>>> Added this line to the config:
>>>> cas.interrupt.groovy.location=/etc/cas/scripts/INTERRUPT.groovy
>>>>
>>>> It does not appear to be calling the groovy script at all. I even added 
>>>> an intentional coding error expecting to break CAS, and nothing. Any ideas?
>>>>
>>>> LOG:
>>>> 2022-05-14 19:53:37,426 DEBUG 
>>>> [org.apereo.cas.interrupt.webflow.actions.InquireInterruptAction] - 
>>>> <Invoking interrupt inquirer using [GroovyScriptInterruptInquirer]>
>>>> 2022-05-14 19:53:37,429 DEBUG 
>>>> [org.apereo.cas.interrupt.webflow.actions.InquireInterruptAction] - 
>>>> <Webflow interrupt is skipped since no inquirer produced a response>
>>>>
>>>>
>>>> SCRIPT:
>>>>
>>>> import org.apereo.cas.interrupt.InterruptResponse
>>>>
>>>> def run(final Object... args) {
>>>>     def principal = args[0]
>>>>     def attributes = args[1]
>>>>     def service = args[2]
>>>>     def registeredService = args[3]
>>>>     def requestContext = args[4]
>>>>     def logger = args[5]
>>>>
>>>>     logger.info("**principal - Attributes:")
>>>>     principal.properties.each {  logger.info("KEY: $it.key -> VALUE: 
>>>> $it.value") }
>>>>
>>>>     logger.info("**attributes - Attributes:")
>>>>     attributes.properties.each {  logger.info("KEY: $it.key -> VALUE: 
>>>> $it.value") }
>>>>
>>>>     logger.info("**service - Attributes:")
>>>>     service.properties.each {  logger.info("KEY: $it.key -> VALUE: 
>>>> $it.value") }
>>>>
>>>>     logger.info("**registeredService - Attributes:")
>>>>     registeredService.properties.each {  logger.info("KEY: $it.key -> 
>>>> VALUE: $it.value") }
>>>>
>>>>     logger.info("**requestContext - Attributes:")
>>>>     requestContext.properties.each {  logger.info("KEY: $it.key -> 
>>>> VALUE: $it.value") }
>>>>
>>>>     def block = false
>>>>     def ssoEnabled = false
>>>>
>>>>     return new InterruptResponse("Message", [link1:"google.com", 
>>>> link2:"yahoo.com"], block, ssoEnabled)
>>>>     
>>>>     /*return new InterruptResponse(message: message, redirectTo: 
>>>> redirectTo, block: block, ssoEnabled: ssoEnabled, autoRedirect: true, 
>>>> autoRedirectAfterSeconds: 1)*/
>>>> }
>>>>
>>>>

-- 
- Website: https://apereo.github.io/cas
- Gitter Chatroom: https://gitter.im/apereo/cas
- List Guidelines: https://goo.gl/1VRrw7
- Contributions: https://goo.gl/mh7qDG
--- 
You received this message because you are subscribed to the Google Groups "CAS 
Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cas-user+unsubscr...@apereo.org.
To view this discussion on the web visit 
https://groups.google.com/a/apereo.org/d/msgid/cas-user/6b54dc10-5e80-4076-a6b6-ce0bcf0a9934n%40apereo.org.

Reply via email to