Issue Type: Bug Bug
Assignee: Unassigned
Components: core, groovy-plugin
Created: 15/Mar/15 4:55 AM
Description:

BACKGROUND OF ISSUE:
I am using groovy scripting console from jenkins to enable the global security of jenkins server.
I looked around jenkins code to see if there is already a method which i can call, instead I got a function called `disableSecurity` which disables the global security, as defined here:
https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/jenkins/model/Jenkins.java#L2160

This method basically sets the boolean variable called 'useSecurity' to false.

PROBLEM :
Now I actually wanted to see if there is a method where this private bool variable `useSecurity` is set to true.
Luckily i found the method `setAuthorizationStrategy` which no matter if nothing passed to this method, will set `useSecurity` to true always whenever it gets called.
Now in my groovy script im calling it like this:

import jenkins.model.*
def inst = Jenkins.getInstance()
inst.setAuthorizationStrategy()
inst.save()

But after i run the script, my security is still disabled.
Looking at code here : https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/jenkins/model/Jenkins.java#L2148
The method defined in above link is like this:

    public void setAuthorizationStrategy(AuthorizationStrategy a) {
        if (a == null)
            a = AuthorizationStrategy.UNSECURED;
        useSecurity = true;
        authorizationStrategy = a;
    }

I see this sets the value of useSecurity to true.
but upon execution, my security yet remains disabled.

WORKAROUND NEEDED: I would like to know if im lacking understanding of this code or there are some caveats im missing.
also if someone can please suggest me a way of enabling security from groovy, would really appreciate it.

SUGGESTED SOLUTION:
defined another method like "disableSecurity", call it "enableSecurity" , and in it , set the value of boolean 'useSecurity' to true.

Environment: Jenkins version latest 1.60
Operating system : OpenSuse
Installed plugins: Groovy, credentials , ssh,
Project: Jenkins
Priority: Major Major
Reporter: Imran Hayder
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira

--
You received this message because you are subscribed to the Google Groups "Jenkins Issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to