Hee is my understanding of using MFA:
scenario 1: Disable MFA globally, and enable it at the service leve
a. configure in cas.properties
Nothing:
b. Enable 2FA at the service leve
{
"@class" : "org.apereo.cas.services.RegexRegisteredService",
"name" : "demo1",
"id" : 20001107,
"description" : "2FA demo site",
"attributeReleasePolicy" : {
"@class" : "org.apereo.cas.services.ReturnAllAttributeReleasePolicy"
},
"multifactorPolicy" : {
"@class" : "org.apereo.cas.services.DefaultRegisteredServiceMultifactorPolicy",
"multifactorAuthenticationProviders" : [ "java.util.LinkedHashSet", [ "mfa-gauth" ] ]
},
"evaluationOrder" : 1107
}
scenario 2: Enale MFA globally, and disable it for few services
a. Enable MFA globally
cas.authn.mfa.global-provider-id=mfa-gauth
b. Disable 2FA at the service leve
{
"@class" : "org.apereo.cas.services.RegexRegisteredService",
"name" : "demo1",
"id" : 20001107,
"description" : "2FA demo site",
"attributeReleasePolicy" : {
"@class" : "org.apereo.cas.services.ReturnAllAttributeReleasePolicy"
},
"multifactorPolicy" : {
"@class" : "org.apereo.cas.services.DefaultRegisteredServiceMultifactorPolicy",
"multifactorAuthenticationProviders" : [ "java.util.LinkedHashSet", [ "mfa-gauth" ] ],
"bypassEnabled" : "true"
},
"evaluationOrder" : 1107
}
scenario 3: By pass MFA by client IP
configure in cas.properties
cas.authn.mfa.gauth.bypass.http-request-remote-address=192.168.1.3
Notes: This is a configure item of gauth, it is effect only when mfa-gauth is selected.
scenario 4: Complex situation
For some complex usage, we can only use groovy script to archive our goal.
a. configure in cas.properties
cas.authn.mfa.groovyScript=file:/opt/castest/mfaGroovyTrigger.groovy
cat /opt/castest/mfaGroovyTrigger.groovy
import java.util.*
class SampleGroovyEventResolver {
def String run(final Object[] args) {
def service = args[0]
def registeredService = args[1]
def authentication = args[2]
def httpRequest = args[3]
def logger = args[4]
return "mfa-gauth"
}
def clientIP = httpRequest.getRemoteAddr()
if ( clientIP == "192.168.100.108" ) {
return "mfa-gauth"
}
}
return null
}
}
b. No special configure is needed at the service leve
delete multifactorPolicy at the service configure
notes: we need to disable other configure
#cas.authn.mfa.global-provider-id=mfa-gauth
#cas.authn.mfa.gauth.bypass.http-request-remote-address=192.168.1.3