Skip to content

add support for custom project domain in user identity.#165

Merged
olivergondza merged 1 commit intojenkinsci:masterfrom
acontes:custom_project_domainname
Nov 21, 2017
Merged

add support for custom project domain in user identity.#165
olivergondza merged 1 commit intojenkinsci:masterfrom
acontes:custom_project_domainname

Conversation

@acontes
Copy link
Copy Markdown
Contributor

@acontes acontes commented Sep 6, 2017

The changes add the ability to connect to openstack instances having
the project's domain name different from the domain name.
It introduces an optional format for the user identity field while
remaining compatible with previous configurations of the
plugin.

@olivergondza
Copy link
Copy Markdown
Member

olivergondza commented Sep 7, 2017

I must admit I am confused by all the OS domains. So the domain we already have is for the domain user belongs to and the project-domain is the one the project belongs to and they can be different in general? With the latter being optional and used just to disambiguate colliding project names between project domains?

Can you please link relevant documentation to the field help to avoid the confusion?

@acontes
Copy link
Copy Markdown
Contributor Author

acontes commented Sep 7, 2017

In Openstack, both projects (tenant) and users must belong to a domain.
In a 'simple' configuration, projects and users are created within the same domain but nothing enforces it. For the sake of some security rules or different authentication mechanisms, projects and users can be created in different domains.

The fact that projects and users must be linked to a domain is documented in the Openstack documentation. Nothing specifies that they have to share the same domain.

In the code of the pull-request, I have decided to make the project's domain optional to maintain compatibility with the current implementation.

<ul>
<li>For v2 authentication use syntax <tt>TENANT_NAME:USER_NAME</tt></li>
<li>For v3 authentication use syntax <tt>PROJECT_NAME:USER_NAME:DOMAIN_NAME</tt></li>
<li>For v3 authentication use syntax <tt>[PROJECT_DOMAIN\]PROJECT_NAME:USER_NAME:DOMAIN_NAME</tt> PROJECT_DOMAIN is optional, use only when DOMAIN_NAME and PROJECT_DOMAIN differs</li>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

differ

@acontes acontes force-pushed the custom_project_domainname branch from b0c2194 to 3528f21 Compare September 8, 2017 05:01
@acontes
Copy link
Copy Markdown
Contributor Author

acontes commented Sep 8, 2017

typo fixed, thank you @Guillaumichaud for the review

@olivergondza
Copy link
Copy Markdown
Member

Right, that was my understanding too. Is there a specific reason to use backslash as a separator and not a :? Also, for user we use user:domain ordering and for project it would be domain:project. How about PROJECT_NAME:PROJECT_DOMAIN:USER_NAME:DOMAIN_NAME?

@olivergondza olivergondza reopened this Sep 8, 2017
@acontes
Copy link
Copy Markdown
Contributor Author

acontes commented Sep 8, 2017

fine by me, I will update the PR accordingly.

@pjdarton
Copy link
Copy Markdown
Member

pjdarton commented Sep 8, 2017

I think that all this foo:bar:optional stuff is just highlighting some tech-debt that we really ought to stuff all this in its own multi-field class. Not as part of this PR but I think we ought to do it...

When it becomes difficult to explain everything in the online help text, that indicates that it's overdue for being refactored ;-)

@olivergondza
Copy link
Copy Markdown
Member

@pjdarton, certainly. Though, I hesitate to do it because of all the ajax method signatures getting nasty. IIRC, one of yours that would be painfully affected.

@pjdarton
Copy link
Copy Markdown
Member

pjdarton commented Sep 8, 2017

Yes, the doCheck.../doFill... methods will get a lot more arguments but it's only us that'll see that - the end user will get a much cleaner experience.
It's certainly not something to be done while we've got some large PRs awaiting merger ;-)

@acontes acontes force-pushed the custom_project_domainname branch from 3528f21 to 3464964 Compare September 11, 2017 08:29
@acontes
Copy link
Copy Markdown
Contributor Author

acontes commented Sep 11, 2017

the updated version simplifies the identity string (as so the documentation) as the domain name for the project is now mandatory.
The migration to the new v3 schema is performed in the readResolve method.

@acontes
Copy link
Copy Markdown
Contributor Author

acontes commented Sep 22, 2017

Hello there, any comment/remark on the latest version ?
Is it fine on your side ?

@olivergondza olivergondza self-requested a review September 22, 2017 11:49
@acontes acontes force-pushed the custom_project_domainname branch from 3464964 to 90edaee Compare October 7, 2017 08:13
@acontes
Copy link
Copy Markdown
Contributor Author

acontes commented Oct 10, 2017

PR updated to the latest version of master.

@malice00
Copy link
Copy Markdown

I just tried these changes and they solved my authentication issues! I hope this can get merged and released soon?

@olivergondza
Copy link
Copy Markdown
Member

I agree with @pjdarton, that this is best refactored into (at least) 2 fields for project and username.

@Guillaumichaud
Copy link
Copy Markdown

@acontes Was the "Unresolveable build extension" error expected? :)

@acontes acontes force-pushed the custom_project_domainname branch from 90edaee to b38fa20 Compare November 4, 2017 21:06
@acontes
Copy link
Copy Markdown
Contributor Author

acontes commented Nov 4, 2017

rather than just adding a second field, I updated the code to use Jenkins' credentials and create two implementations ( one for v2 and one for v3 ). Adding a second field has the same impact on the API but is far less extensible.
As for the previous version of the pull-request, the migration from the former schema is performed in the readResolve method.

@acontes acontes force-pushed the custom_project_domainname branch from b38fa20 to 06d85c0 Compare November 4, 2017 21:23
Copy link
Copy Markdown
Member

@olivergondza olivergondza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea! I have added few minor comment on implementations side.

Is there some test that explicitly verifies the migration is performed correctly? IMO it is enough to extend existing "migration" tests to check the credentials object.

) throws FormValidation {
final String fingerprint = Util.getDigestOf(endPointUrl + '\n' + identity + '\n' + credential + '\n' + region);
if (auth == null) {
throw new RuntimeException("authentication is null");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not keeping the parameters @Nonnull then?

@@ -0,0 +1,3 @@
<div>
The credential to start the machine.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the credential to talk to openstack.

<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define"
xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
</j:jelly> No newline at end of file
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a config.jelly for the abstract class if it is overridden by all implementations?

@@ -0,0 +1,3 @@
<div>
The tenant associated to the user to start the machine.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find the "to start the machine" part in auth helps a bit confusing - it is needed for any interaction with openstack. I guess we can leave it out.

@@ -0,0 +1,3 @@
<div>
User name of the user to start the machine.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"to start the machine" is extremely confusing here.

public class JCloudsCloud extends Cloud implements SlaveOptions.Holder {

private static final Logger LOGGER = Logger.getLogger(JCloudsCloud.class.getName());
public String credentialId;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private

public final @Nonnull String identity;
public final @Nonnull Secret credential;

public /*final*/ @Nonnull String identity;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one should be @Deprecated as well, right?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... and transient.

OpenstackCredentials.add(migratedOpenstackCredential);
OpenstackCredentials.save();
} catch (IOException e) {
e.printStackTrace();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Send to logger, instead.

The changes add the ability to connect to openstack instances having
the project's domain name different from the domain name by changing
the format of the identity string.
The identity string using the new format are converted into the new
one using when the plugin is loaded.
@acontes acontes force-pushed the custom_project_domainname branch from 06d85c0 to fd0f931 Compare November 9, 2017 14:47
@acontes
Copy link
Copy Markdown
Contributor Author

acontes commented Nov 9, 2017

revised version of the PR to address all the comments.

  • Credential migration is verified in a new test.
  • @nonnull is back, not sure why I changed that initially
  • reworded the help on the fields

@olivergondza olivergondza self-assigned this Nov 10, 2017
@olivergondza olivergondza merged commit fd0f931 into jenkinsci:master Nov 21, 2017
olivergondza added a commit that referenced this pull request Nov 21, 2017
add support for custom project domain in user identity.
@olivergondza
Copy link
Copy Markdown
Member

Merged, thanks!

@twillouer
Copy link
Copy Markdown

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants