Skip to content

Instantly share code, notes, and snippets.

@jonesbusy
Created April 7, 2021 19:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonesbusy/01ef4ea509102ecbfb4dc857a032ff44 to your computer and use it in GitHub Desktop.
Save jonesbusy/01ef4ea509102ecbfb4dc857a032ff44 to your computer and use it in GitHub Desktop.
nexus_ldap_system.groovy
import org.sonatype.nexus.capability.CapabilityReference
import org.sonatype.nexus.capability.CapabilityType
import org.sonatype.nexus.internal.capability.DefaultCapabilityReference
import org.sonatype.nexus.internal.capability.DefaultCapabilityRegistry
import org.sonatype.nexus.security.realm.RealmManager
// Remove proxy
core.removeHTTPProxy()
core.removeHTTPSProxy()
// Add proxy
core.httpProxy("proxy", 80)
core.httpsProxy("proxy", 80)
core.nonProxyHosts("localhost", "127.0.0.1");
// Disable outreach
def capabilityRegistry = container.lookup(DefaultCapabilityRegistry.class.name)
capabilityRegistry.all.findAll {it.context().type().toString().startsWith("Outreach")}.each {
capabilityRegistry.disable(it.context().id())
}
// Set base url
core.baseUrl("nexus-url")
// Enable realms
realmManager = container.lookup(RealmManager.class.name)
realmManager.enableRealm("NpmToken")
realmManager.enableRealm("DockerToken")
realmManager.enableRealm("LdapRealm")
// Enable anonymous access
security.setAnonymousAccess(true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment