[GitHub] tinkerpop pull request #833: TINKERPOP-1903 Migrated Credential DSL to annot...
Github user asfgit closed the pull request at: https://github.com/apache/tinkerpop/pull/833 ---
[GitHub] tinkerpop pull request #833: TINKERPOP-1903 Migrated Credential DSL to annot...
Github user dkuppitz commented on a diff in the pull request: https://github.com/apache/tinkerpop/pull/833#discussion_r181460071 --- Diff: gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/dsl/credential/CredentialTraversalDsl.java --- @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tinkerpop.gremlin.groovy.jsr223.dsl.credential; + +import org.apache.tinkerpop.gremlin.process.traversal.dsl.GremlinDsl; +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; +import org.apache.tinkerpop.gremlin.structure.Vertex; +import org.mindrot.jbcrypt.BCrypt; + +import static org.apache.tinkerpop.gremlin.groovy.jsr223.dsl.credential.CredentialGraphTokens.PROPERTY_PASSWORD; +import static org.apache.tinkerpop.gremlin.groovy.jsr223.dsl.credential.CredentialGraphTokens.PROPERTY_USERNAME; +import static org.apache.tinkerpop.gremlin.groovy.jsr223.dsl.credential.CredentialGraphTokens.VERTEX_LABEL_USER; + +/** + * A DSL for managing a "credentials graph" used by Gremlin Server for simple authentication functions. + * + * @author Stephen Mallette (http://stephen.genoprime.com) + */ +@GremlinDsl(traversalSource = "org.apache.tinkerpop.gremlin.groovy.jsr223.dsl.credential.CredentialTraversalSourceDsl") +public interface CredentialTraversalDslextends GraphTraversal.Admin{ +static final int BCRYPT_ROUNDS = 4; + +/** + * Finds all users. + */ +public default GraphTraversalusers() { +return (CredentialTraversal) hasLabel(VERTEX_LABEL_USER); +} + +/** + * Finds users by name. + */ +public default GraphTraversalusers(final String username) { --- End diff -- Since this method is called `users` and not `user`, it should look more like this: ```java public GraphTraversalusers(final String username, final String... more) { if (more.length == 0) { return this.clone().V().has(VERTEX_LABEL_USER, PROPERTY_USERNAME, username); } final int lastIndex; final String[] usernames = Arrays.copyOf(more, (lastIndex = more.length) + 1); usernames[lastIndex] = username; return this.clone().V().has(VERTEX_LABEL_USER, PROPERTY_USERNAME, P.within(usernames)); } ``` Likewise in `CredentialTraversalSourceDsl`. ---
[GitHub] tinkerpop pull request #833: TINKERPOP-1903 Migrated Credential DSL to annot...
Github user dkuppitz commented on a diff in the pull request: https://github.com/apache/tinkerpop/pull/833#discussion_r181456003 --- Diff: docs/src/reference/gremlin-applications.asciidoc --- @@ -1365,15 +1365,22 @@ Please see the example usage as follows: graph = TinkerGraph.open() graph.createIndex("username",Vertex.class) -credentials = credentials(graph) -credentials.createUser("stephen","password") -credentials.createUser("daniel","better-password") -credentials.createUser("marko","rainbow-dash") -credentials.findUser("marko").properties() -credentials.countUsers() -credentials.removeUser("daniel") -credentials.countUsers() - +credentials = graph.traversal(CredentialTraversalSource.class) +credentials.user("stephen","password") +credentials.user("daniel","better-password") +credentials.user("marko","rainbow-dash") +credentials.users("marko").valueMap() +credentials.users().count() +credentials.user("daniel").drop() --- End diff -- Ignoring that simply dropping my user account is probably not in line with the current GDPR, this should be `credentials.users("daniel").drop()`. ---
[GitHub] tinkerpop pull request #833: TINKERPOP-1903 Migrated Credential DSL to annot...
Github user dkuppitz commented on a diff in the pull request: https://github.com/apache/tinkerpop/pull/833#discussion_r181456678 --- Diff: docs/src/upgrade/release-3.3.x.asciidoc --- @@ -23,6 +23,33 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima == TinkerPop 3.3.2 +*Release Date: NOT OFFICIALLY RELEASED YET* + +Please see the link:https://github.com/apache/tinkerpop/blob/3.3.3/CHANGELOG.asciidoc#release-3-3-3[changelog] for a complete list of all the modifications that are part of this release. + +=== Upgrading for Users + + Credential DSL Changes + +The Credential DSL has been modified to work as a standard Java-based Gremlin DSL. The now deprecated old approach +used a "graph wrapping" style that was developed long before the +link:http://tinkerpop.apache.org/docs/current/reference/#gremlin-java-dsl[recommended method] for building DSLs was +published. Under this new model, the DSL is initialized via traversal as follows: + +[source,java] + +CredentialTraversalSource credentials = graph.traversal(CredentialTraversalSource.class) +credentials.user("stephen","password").iterate() +credentials.users("stephen").valueMap().next() +credentials.users().count().next() +credentials.user("stephen").drop().iterate() --- End diff -- ``` credentials.users("stephen").drop().iterate() ``` ---
[GitHub] tinkerpop pull request #833: TINKERPOP-1903 Migrated Credential DSL to annot...
GitHub user spmallette opened a pull request: https://github.com/apache/tinkerpop/pull/833 TINKERPOP-1903 Migrated Credential DSL to annotation processor https://issues.apache.org/jira/browse/TINKERPOP-1903 The old CredentialGraph approach to the Credential DSL has been deprecated in favor of the preferred method for DSL development which was published long after the original DSL was developed. All tests pass with `docker/build.sh -t -i` VOTE +1 You can merge this pull request into a Git repository by running: $ git pull https://github.com/apache/tinkerpop TINKERPOP-1903 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/tinkerpop/pull/833.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #833 commit 972a9cd48c765bc16b72f5917899b0855711c609 Author: Stephen MalletteDate: 2018-04-05T15:51:49Z TINKERPOP-1903 Migrated Credential DSL to annotation processor The old CredentialGraph approach to the Credential DSL has been deprecated in favor of the preferred method for DSL development which was published long after the original DSL was developed. ---