-
Notifications
You must be signed in to change notification settings - Fork 0
/
InMemoryAuthnHandlerConfig.java
58 lines (47 loc) · 1.96 KB
/
InMemoryAuthnHandlerConfig.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package org.apereo.cas.config;
import java.util.List;
import org.apereo.cas.authentication.AuthenticationEventExecutionPlan;
import org.apereo.cas.authentication.AuthenticationEventExecutionPlanConfigurer;
import org.apereo.cas.authentication.principal.PrincipalFactory;
import org.apereo.cas.configuration.CasConfigurationProperties;
import org.apereo.cas.services.ServicesManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.apereo.cas.authentication.AuthenticationHandler;
@Configuration("InMemoryAuthenticationEventExecutionPlanConfiguration")
@EnableConfigurationProperties( {CasConfigurationProperties.class})
public class InMemoryAuthnHandlerConfig implements AuthenticationEventExecutionPlanConfigurer {
@Autowired
private CasConfigurationProperties casProperties;
@Autowired
private PrincipalFactory principalFactory;
@Autowired
private ServicesManager servicesManager;
@Bean
public List<InMemoryUser> customUserList() {
return List.of(
// You can use a temporary email from https://temp-mail.org
new InMemoryUser("demo", "demo", "larab33568@digdy.com")
);
}
/* here in 4th parameter, we can set the order of this handler is executed by CAS,
if there are multiple authentication stratagies are avaible */
@Bean
public AuthenticationHandler inMemoryAuthenticationHandler() {
final InMemoryAuthnHandler handler =
new InMemoryAuthnHandler(
"DEMO-IN-MEMORY-AUTHN",
servicesManager,
principalFactory,
0,
customUserList()
);
return handler;
}
@Override
public void configureAuthenticationExecutionPlan(AuthenticationEventExecutionPlan plan) {
plan.registerAuthenticationHandler(inMemoryAuthenticationHandler());
}
}