-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
7000.saml-security-realm.groovy
40 lines (34 loc) · 1.7 KB
/
7000.saml-security-realm.groovy
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
import jenkins.model.*
import hudson.security.*
import org.jenkinsci.plugins.saml.*
println "///////////////////////////////////////////////////////////////////////////"
println "Init Hook: SAML security realm"
println "///////////////////////////////////////////////////////////////////////////"
def instance = Jenkins.getInstance()
def spEntityId = "jenkins-saml-id"
def usernameAttributeName = "username"
def emailAttributeName = "email"
def groupsAttributeName = "groups"
def idpMetadata = """
XML PAYLOAD SAML METADATA
"""
def advConfig = new SamlAdvancedConfiguration(
false, // Boolean forceAuthn
"", // String authnContextClassRef,
spEntityId, // String spEntityId,
null // Integer maximumSessionLifetime
)
def securityRealm = new SamlSecurityRealm(
"", // String signOnUrl
idpMetadata, // String idpMetadata,
"", // String displayNameAttributeName,
groupsAttributeName, // String groupsAttributeName,
null, // Integer maximumAuthenticationLifetime,
usernameAttributeName, // String usernameAttributeName,
emailAttributeName, // String emailAttributeName,
"", // String logoutUrl,
advConfig, // SamlAdvancedConfiguration advancedConfiguration,
null // SamlEncryptionData encryptionData,
)
instance.setSecurityRealm(securityRealm)
instance.save()