Hi Oliver,
Thanks a lot for the reply. I am trying to develop an authentication plugin
which expects some information other than username and password or rsa
keys, for example userDept=abc. For the authentication part I have extended
AbstractPasswordBasedSecurityRealm and overridden createCliAuthenticator()
method. Following is my createCliAuthenticator() method
@Override
public CliAuthenticator createCliAuthenticator(final CLICommand
command) {
return new CliAuthenticator() {
@Option(name="--userDept",usage="userDept")
public String userDept;
public Authentication authenticate() throws
AuthenticationException, IOException, InterruptedException {
Authentication auth =
command.getTransportAuthentication();
if (userDept!=null){
try {
log.info("userDept is "+userDept);
// do the operation with userDept
} catch (Exception e) {
throw new BadCredentialsException("Error
"+e.getMessage(),e);
}
}
String userName = (String)auth.getPrincipal();
Set<GrantedAuthority> groups = new
HashSet<GrantedAuthority>();
groups.add(SecurityRealm.AUTHENTICATED_AUTHORITY);
MyUserDetail userDetail = new MyUserDetail(userName,
"", userDept,
true, true, true, true,
groups.toArray(new
GrantedAuthority[groups.size()]),true);
return new
UsernamePasswordAuthenticationToken(userDetail, "", groups.toArray(new
GrantedAuthority[groups.size()]));
}
};
}
The userDept is available for me when im trying listJobs command
>java -jar jenkins-cli.jar -s http://localhost:8080/baas -i id_rsa
list-jobs --userDept abcd
But with the build command the userDept is not getting recognized.
Is there anything wrong with my implementation? Or is there a way any
session is maintained for CLI ? I have seen that
Stapler.getCurrentRequest() does not work for CLI.
--
You received this message because you are subscribed to the Google Groups
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.