diff --git a/pom.xml b/pom.xml index e39882e40..deaf173bf 100644 --- a/pom.xml +++ b/pom.xml @@ -36,7 +36,7 @@ io.vertx vertx-ext-parent - 24 + 25 vertx-auth diff --git a/vertx-auth-common/src/main/asciidoc/groovy/index.adoc b/vertx-auth-common/src/main/asciidoc/groovy/index.adoc index 0f01eeb89..8a95098b1 100644 --- a/vertx-auth-common/src/main/asciidoc/groovy/index.adoc +++ b/vertx-auth-common/src/main/asciidoc/groovy/index.adoc @@ -14,7 +14,7 @@ To use this project, add the following dependency to the _dependencies_ section io.vertx vertx-auth-common - 3.4.0.Beta1 + 3.4.0-SNAPSHOT ---- @@ -22,7 +22,7 @@ To use this project, add the following dependency to the _dependencies_ section [source,groovy,subs="+attributes"] ---- -compile 'io.vertx:vertx-auth-common:3.4.0.Beta1' +compile 'io.vertx:vertx-auth-common:3.4.0-SNAPSHOT' ---- == Basic concepts diff --git a/vertx-auth-common/src/main/asciidoc/java/index.adoc b/vertx-auth-common/src/main/asciidoc/java/index.adoc index 416835e35..03a120a70 100644 --- a/vertx-auth-common/src/main/asciidoc/java/index.adoc +++ b/vertx-auth-common/src/main/asciidoc/java/index.adoc @@ -14,7 +14,7 @@ To use this project, add the following dependency to the _dependencies_ section io.vertx vertx-auth-common - 3.4.0.Beta1 + 3.4.0-SNAPSHOT ---- @@ -22,7 +22,7 @@ To use this project, add the following dependency to the _dependencies_ section [source,groovy,subs="+attributes"] ---- -compile 'io.vertx:vertx-auth-common:3.4.0.Beta1' +compile 'io.vertx:vertx-auth-common:3.4.0-SNAPSHOT' ---- == Basic concepts diff --git a/vertx-auth-common/src/main/asciidoc/js/index.adoc b/vertx-auth-common/src/main/asciidoc/js/index.adoc index bcb093399..75e14ae4d 100644 --- a/vertx-auth-common/src/main/asciidoc/js/index.adoc +++ b/vertx-auth-common/src/main/asciidoc/js/index.adoc @@ -14,7 +14,7 @@ To use this project, add the following dependency to the _dependencies_ section io.vertx vertx-auth-common - 3.4.0.Beta1 + 3.4.0-SNAPSHOT ---- @@ -22,7 +22,7 @@ To use this project, add the following dependency to the _dependencies_ section [source,groovy,subs="+attributes"] ---- -compile 'io.vertx:vertx-auth-common:3.4.0.Beta1' +compile 'io.vertx:vertx-auth-common:3.4.0-SNAPSHOT' ---- == Basic concepts diff --git a/vertx-auth-common/src/main/asciidoc/kotlin/index.adoc b/vertx-auth-common/src/main/asciidoc/kotlin/index.adoc new file mode 100644 index 000000000..5b8231f2b --- /dev/null +++ b/vertx-auth-common/src/main/asciidoc/kotlin/index.adoc @@ -0,0 +1,162 @@ += Vert.x Auth - Authentication and Authorisation + +This Vert.x component provides interfaces for authentication and authorisation that can be used from +your Vert.x applications and can be backed by different providers. + +Vert.x auth is also used by vertx-web to handle its authentication and authorisation. + +To use this project, add the following dependency to the _dependencies_ section of your build descriptor: + +* Maven (in your `pom.xml`): + +[source,xml,subs="+attributes"] +---- + + io.vertx + vertx-auth-common + 3.4.0-SNAPSHOT + +---- + +* Gradle (in your `build.gradle` file): + +[source,groovy,subs="+attributes"] +---- +compile 'io.vertx:vertx-auth-common:3.4.0-SNAPSHOT' +---- + +== Basic concepts + +_Authentication_ means verifying the identity of a user. + +_Authorisation_ means verifying a user has an authority. + +What the authority means is determined by the particular implementation and we don't mandate any particular model, +e.g. a permissions/roles model, to keep things very flexible. + +For some implementations an authority might represent a permission, for example the authority to access all printers, +or a specific printer. Other implementations must support roles too, and will often represent this by prefixing +the authority with something like `role:`, e.g. `role:admin`. Another implementation might have a completely +different model of representing authorities. + +To find out what a particular auth provider expects, consult the documentation for that auth provider.. + +== Authentication + +To authenticate a user you use `link:../../apidocs/io/vertx/ext/auth/AuthProvider.html#authenticate-io.vertx.core.json.JsonObject-io.vertx.core.Handler-[authenticate]`. + +The first argument is a JSON object which contains authentication information. What this actually contains depends +on the specific implementation; for a simple username/password based authentication it might contain something like: + +---- +{ + "username": "tim" + "password": "mypassword" +} +---- + +For an implementation based on JWT token or OAuth bearer tokens it might contain the token information. + +Authentication occurs asynchronously and the result is passed to the user on the result handler that was provided in +the call. The async result contains an instance of `link:../../apidocs/io/vertx/ext/auth/User.html[User]` which represents the authenticated +user and contains operations which allow the user to be authorised. + +Here's an example of authenticating a user using a simple username/password implementation: + +[source,java] +---- + +var authInfo = json { + obj( + "username" to "tim", + "password" to "mypassword" + ) +} + +authProvider.authenticate(authInfo, { res -> + if (res.succeeded()) { + + var user = res.result() + + println("User ${user.principal()} is now authenticated") + + } else { + res.cause().printStackTrace() + } +}) + +---- + +== Authorisation + +Once you have an `link:../../apidocs/io/vertx/ext/auth/User.html[User]` instance you can call methods on it to authorise it. + +to check if a user has a specific authority you use `link:../../apidocs/io/vertx/ext/auth/User.html#isAuthorised-java.lang.String-io.vertx.core.Handler-[isAuthorised]`. + +The results of all the above are provided asynchronously in the handler. + +Here's an example of authorising a user: + +[source,java] +---- + +user.isAuthorised("printers:printer1234", { res -> + if (res.succeeded()) { + + var hasAuthority = res.result() + + if (hasAuthority) { + println("User has the authority") + } else { + println("User does not have the authority") + } + + } else { + res.cause().printStackTrace() + } +}) + +---- + +And another example of authorising in a roles based model which uses `role:` as a prefix. + +Please note, as discussed above how the authority string is interpreted is completely determined by the underlying +implementation and Vert.x makes no assumptions here. + +=== Caching authorities + +The user object will cache any authorities so subsequently calls to check if it has the same authorities will result +in the underlying provider being called. + +In order to clear the internal cache you can use `link:../../apidocs/io/vertx/ext/auth/User.html#clearCache--[clearCache]`. + +=== The User Principal + +You can get the Principal corresponding to the authenticated user with `link:../../apidocs/io/vertx/ext/auth/User.html#principal--[principal]`. + +What this returns depends on the underlying implementation. + +== Creating your own auth implementation + +If you wish to create your own auth provider you should implement the `link:../../apidocs/io/vertx/ext/auth/AuthProvider.html[AuthProvider]` interface. + +We provide an abstract implementation of user called `link:../../apidocs/io/vertx/ext/auth/AbstractUser.html[AbstractUser]` which you can subclass +to make your user implementation. This contains the caching logic so you don't have to implement that yourself. + +If you wish your user objects to be clusterable you should make sure they implement `link:../../apidocs/io/vertx/core/shareddata/impl/ClusterSerializable.html[ClusterSerializable]`. + +== Pseudo Random Number Generator + +Since Secure Random from java can block during the aquisition of entropy from the system, we provide a simple wrapper +around it that can be used without the danger of blocking the event loop. + +By default this PRNG uses a mixed mode, blocking for seeding, non blocking for generating. The PRNG will also reseed +every 5 minutes with 64bits of new entropy. However this can all be configured using the system properties: + +* io.vertx.ext.auth.prng.algorithm e.g.: SHA1PRNG +* io.vertx.ext.auth.prng.seed.interval e.g.: 1000 (every second) +* io.vertx.ext.auth.prng.seed.bits e.g.: 128 + +Most users should not need to configure these values unless if you notice that the performance of your application is +being affected by the PRNG algorithm. +Julien VietTim Fox \ No newline at end of file diff --git a/vertx-auth-common/src/main/asciidoc/ruby/index.adoc b/vertx-auth-common/src/main/asciidoc/ruby/index.adoc index c91d5795d..3de89b389 100644 --- a/vertx-auth-common/src/main/asciidoc/ruby/index.adoc +++ b/vertx-auth-common/src/main/asciidoc/ruby/index.adoc @@ -14,7 +14,7 @@ To use this project, add the following dependency to the _dependencies_ section io.vertx vertx-auth-common - 3.4.0.Beta1 + 3.4.0-SNAPSHOT ---- @@ -22,7 +22,7 @@ To use this project, add the following dependency to the _dependencies_ section [source,groovy,subs="+attributes"] ---- -compile 'io.vertx:vertx-auth-common:3.4.0.Beta1' +compile 'io.vertx:vertx-auth-common:3.4.0-SNAPSHOT' ---- == Basic concepts diff --git a/vertx-auth-common/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule b/vertx-auth-common/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule deleted file mode 100644 index e77ff8fca..000000000 --- a/vertx-auth-common/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule +++ /dev/null @@ -1,4 +0,0 @@ -moduleName = io.vertx.ext.auth.User-module -moduleVersion = 1.0 -extensionClasses = io.vertx.groovy.ext.auth.AuthProvider_GroovyExtension, io.vertx.groovy.ext.auth.User_GroovyExtension -staticExtensionClasses = diff --git a/vertx-auth-common/src/main/resources/vertx-auth-common-js/auth_provider.js b/vertx-auth-common/src/main/resources/vertx-auth-common-js/auth_provider.js deleted file mode 100644 index 6757d24b4..000000000 --- a/vertx-auth-common/src/main/resources/vertx-auth-common-js/auth_provider.js +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2014 Red Hat, Inc. - * - * Red Hat 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. - */ - -/** @module vertx-auth-common-js/auth_provider */ -var utils = require('vertx-js/util/utils'); -var User = require('vertx-auth-common-js/user'); - -var io = Packages.io; -var JsonObject = io.vertx.core.json.JsonObject; -var JAuthProvider = Java.type('io.vertx.ext.auth.AuthProvider'); - -/** - - User-facing interface for authenticating users. - - @class -*/ -var AuthProvider = function(j_val) { - - var j_authProvider = j_val; - var that = this; - - /** - Authenticate a user. -

- The first argument is a JSON object containing information for authenticating the user. What this actually contains - depends on the specific implementation. In the case of a simple username/password based - authentication it is likely to contain a JSON object with the following structure: -

-     {
-       "username": "tim",
-       "password": "mypassword"
-     }
-   
- For other types of authentication it contain different information - for example a JWT token or OAuth bearer token. -

- If the user is successfully authenticated a {@link User} object is passed to the handler in an {@link AsyncResult}. - The user object can then be used for authorisation. - - @public - @param authInfo {Object} The auth information - @param resultHandler {function} The result handler - */ - this.authenticate = function(authInfo, resultHandler) { - var __args = arguments; - if (__args.length === 2 && (typeof __args[0] === 'object' && __args[0] != null) && typeof __args[1] === 'function') { - j_authProvider["authenticate(io.vertx.core.json.JsonObject,io.vertx.core.Handler)"](utils.convParamJsonObject(authInfo), function(ar) { - if (ar.succeeded()) { - resultHandler(utils.convReturnVertxGen(User, ar.result()), null); - } else { - resultHandler(null, ar.cause()); - } - }); - } else throw new TypeError('function invoked with invalid arguments'); - }; - - // A reference to the underlying Java delegate - // NOTE! This is an internal API and must not be used in user code. - // If you rely on this property your code is likely to break if we change it / remove it without warning. - this._jdel = j_authProvider; -}; - -AuthProvider._jclass = utils.getJavaClass("io.vertx.ext.auth.AuthProvider"); -AuthProvider._jtype = { - accept: function(obj) { - return AuthProvider._jclass.isInstance(obj._jdel); - }, - wrap: function(jdel) { - var obj = Object.create(AuthProvider.prototype, {}); - AuthProvider.apply(obj, arguments); - return obj; - }, - unwrap: function(obj) { - return obj._jdel; - } -}; -AuthProvider._create = function(jdel) { - var obj = Object.create(AuthProvider.prototype, {}); - AuthProvider.apply(obj, arguments); - return obj; -} -module.exports = AuthProvider; \ No newline at end of file diff --git a/vertx-auth-common/src/main/resources/vertx-auth-common-js/user.js b/vertx-auth-common/src/main/resources/vertx-auth-common-js/user.js deleted file mode 100644 index ee0361cbf..000000000 --- a/vertx-auth-common/src/main/resources/vertx-auth-common-js/user.js +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright 2014 Red Hat, Inc. - * - * Red Hat 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. - */ - -/** @module vertx-auth-common-js/user */ -var utils = require('vertx-js/util/utils'); -var AuthProvider = require('vertx-auth-common-js/auth_provider'); - -var io = Packages.io; -var JsonObject = io.vertx.core.json.JsonObject; -var JUser = Java.type('io.vertx.ext.auth.User'); - -/** - Represents an authenticates User and contains operations to authorise the user. -

- Please consult the documentation for a detailed explanation. - - @class -*/ -var User = function(j_val) { - - var j_user = j_val; - var that = this; - - /** - Is the user authorised to - - @public - @param authority {string} the authority - what this really means is determined by the specific implementation. It might represent a permission to access a resource e.g. `printers:printer34` or it might represent authority to a role in a roles based model, e.g. `role:admin`. - @param resultHandler {function} handler that will be called with an {@link AsyncResult} containing the value `true` if the they has the authority or `false` otherwise. - @return {User} the User to enable fluent use - */ - this.isAuthorised = function(authority, resultHandler) { - var __args = arguments; - if (__args.length === 2 && typeof __args[0] === 'string' && typeof __args[1] === 'function') { - j_user["isAuthorised(java.lang.String,io.vertx.core.Handler)"](authority, function(ar) { - if (ar.succeeded()) { - resultHandler(ar.result(), null); - } else { - resultHandler(null, ar.cause()); - } - }); - return that; - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - The User object will cache any authorities that it knows it has to avoid hitting the - underlying auth provider each time. Use this method if you want to clear this cache. - - @public - - @return {User} the User to enable fluent use - */ - this.clearCache = function() { - var __args = arguments; - if (__args.length === 0) { - j_user["clearCache()"](); - return that; - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - Get the underlying principal for the User. What this actually returns depends on the implementation. - For a simple user/password based auth, it's likely to contain a JSON object with the following structure: -

-     {
-       "username", "tim"
-     }
-   
- - @public - - @return {Object} JSON representation of the Principal - */ - this.principal = function() { - var __args = arguments; - if (__args.length === 0) { - return utils.convReturnJson(j_user["principal()"]()); - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - Set the auth provider for the User. This is typically used to reattach a detached User with an AuthProvider, e.g. - after it has been deserialized. - - @public - @param authProvider {AuthProvider} the AuthProvider - this must be the same type of AuthProvider that originally created the User - */ - this.setAuthProvider = function(authProvider) { - var __args = arguments; - if (__args.length === 1 && typeof __args[0] === 'object' && __args[0]._jdel) { - j_user["setAuthProvider(io.vertx.ext.auth.AuthProvider)"](authProvider._jdel); - } else throw new TypeError('function invoked with invalid arguments'); - }; - - // A reference to the underlying Java delegate - // NOTE! This is an internal API and must not be used in user code. - // If you rely on this property your code is likely to break if we change it / remove it without warning. - this._jdel = j_user; -}; - -User._jclass = utils.getJavaClass("io.vertx.ext.auth.User"); -User._jtype = { - accept: function(obj) { - return User._jclass.isInstance(obj._jdel); - }, - wrap: function(jdel) { - var obj = Object.create(User.prototype, {}); - User.apply(obj, arguments); - return obj; - }, - unwrap: function(obj) { - return obj._jdel; - } -}; -User._create = function(jdel) { - var obj = Object.create(User.prototype, {}); - User.apply(obj, arguments); - return obj; -} -module.exports = User; \ No newline at end of file diff --git a/vertx-auth-common/src/main/resources/vertx-auth-common/auth_provider.rb b/vertx-auth-common/src/main/resources/vertx-auth-common/auth_provider.rb deleted file mode 100644 index 859036d39..000000000 --- a/vertx-auth-common/src/main/resources/vertx-auth-common/auth_provider.rb +++ /dev/null @@ -1,59 +0,0 @@ -require 'vertx-auth-common/user' -require 'vertx/util/utils.rb' -# Generated from io.vertx.ext.auth.AuthProvider -module VertxAuthCommon - # - # User-facing interface for authenticating users. - class AuthProvider - # @private - # @param j_del [::VertxAuthCommon::AuthProvider] the java delegate - def initialize(j_del) - @j_del = j_del - end - # @private - # @return [::VertxAuthCommon::AuthProvider] the underlying java delegate - def j_del - @j_del - end - @@j_api_type = Object.new - def @@j_api_type.accept?(obj) - obj.class == AuthProvider - end - def @@j_api_type.wrap(obj) - AuthProvider.new(obj) - end - def @@j_api_type.unwrap(obj) - obj.j_del - end - def self.j_api_type - @@j_api_type - end - def self.j_class - Java::IoVertxExtAuth::AuthProvider.java_class - end - # Authenticate a user. - #

- # The first argument is a JSON object containing information for authenticating the user. What this actually contains - # depends on the specific implementation. In the case of a simple username/password based - # authentication it is likely to contain a JSON object with the following structure: - #

-    #    {
-    #      "username": "tim",
-    #      "password": "mypassword"
-    #    }
-    #  
- # For other types of authentication it contain different information - for example a JWT token or OAuth bearer token. - #

- # If the user is successfully authenticated a {::VertxAuthCommon::User} object is passed to the handler in an {AsyncResult}. - # The user object can then be used for authorisation. - # @param [Hash{String => Object}] authInfo The auth information - # @yield The result handler - # @return [void] - def authenticate(authInfo=nil) - if authInfo.class == Hash && block_given? - return @j_del.java_method(:authenticate, [Java::IoVertxCoreJson::JsonObject.java_class,Java::IoVertxCore::Handler.java_class]).call(::Vertx::Util::Utils.to_json_object(authInfo),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxAuthCommon::User) : nil) })) - end - raise ArgumentError, "Invalid arguments when calling authenticate(#{authInfo})" - end - end -end diff --git a/vertx-auth-common/src/main/resources/vertx-auth-common/user.rb b/vertx-auth-common/src/main/resources/vertx-auth-common/user.rb deleted file mode 100644 index 916469b26..000000000 --- a/vertx-auth-common/src/main/resources/vertx-auth-common/user.rb +++ /dev/null @@ -1,81 +0,0 @@ -require 'vertx-auth-common/auth_provider' -require 'vertx/util/utils.rb' -# Generated from io.vertx.ext.auth.User -module VertxAuthCommon - # Represents an authenticates User and contains operations to authorise the user. - #

- # Please consult the documentation for a detailed explanation. - class User - # @private - # @param j_del [::VertxAuthCommon::User] the java delegate - def initialize(j_del) - @j_del = j_del - end - # @private - # @return [::VertxAuthCommon::User] the underlying java delegate - def j_del - @j_del - end - @@j_api_type = Object.new - def @@j_api_type.accept?(obj) - obj.class == User - end - def @@j_api_type.wrap(obj) - User.new(obj) - end - def @@j_api_type.unwrap(obj) - obj.j_del - end - def self.j_api_type - @@j_api_type - end - def self.j_class - Java::IoVertxExtAuth::User.java_class - end - # Is the user authorised to - # @param [String] authority the authority - what this really means is determined by the specific implementation. It might represent a permission to access a resource e.g. `printers:printer34` or it might represent authority to a role in a roles based model, e.g. `role:admin`. - # @yield handler that will be called with an {AsyncResult} containing the value `true` if the they has the authority or `false` otherwise. - # @return [self] - def is_authorised(authority=nil) - if authority.class == String && block_given? - @j_del.java_method(:isAuthorised, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(authority,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) })) - return self - end - raise ArgumentError, "Invalid arguments when calling is_authorised(#{authority})" - end - # The User object will cache any authorities that it knows it has to avoid hitting the - # underlying auth provider each time. Use this method if you want to clear this cache. - # @return [self] - def clear_cache - if !block_given? - @j_del.java_method(:clearCache, []).call() - return self - end - raise ArgumentError, "Invalid arguments when calling clear_cache()" - end - # Get the underlying principal for the User. What this actually returns depends on the implementation. - # For a simple user/password based auth, it's likely to contain a JSON object with the following structure: - #

-    #    {
-    #      "username", "tim"
-    #    }
-    #  
- # @return [Hash{String => Object}] JSON representation of the Principal - def principal - if !block_given? - return @j_del.java_method(:principal, []).call() != nil ? JSON.parse(@j_del.java_method(:principal, []).call().encode) : nil - end - raise ArgumentError, "Invalid arguments when calling principal()" - end - # Set the auth provider for the User. This is typically used to reattach a detached User with an AuthProvider, e.g. - # after it has been deserialized. - # @param [::VertxAuthCommon::AuthProvider] authProvider the AuthProvider - this must be the same type of AuthProvider that originally created the User - # @return [void] - def set_auth_provider(authProvider=nil) - if authProvider.class.method_defined?(:j_del) && !block_given? - return @j_del.java_method(:setAuthProvider, [Java::IoVertxExtAuth::AuthProvider.java_class]).call(authProvider.j_del) - end - raise ArgumentError, "Invalid arguments when calling set_auth_provider(#{authProvider})" - end - end -end diff --git a/vertx-auth-htdigest/src/main/asciidoc/groovy/index.adoc b/vertx-auth-htdigest/src/main/asciidoc/groovy/index.adoc index 28af360d0..d60e03378 100644 --- a/vertx-auth-htdigest/src/main/asciidoc/groovy/index.adoc +++ b/vertx-auth-htdigest/src/main/asciidoc/groovy/index.adoc @@ -16,7 +16,7 @@ dependency to the _dependencies_ section of your build descriptor: io.vertx vertx-auth-htdigest - 3.4.0.Beta1 + 3.4.0-SNAPSHOT ---- @@ -24,7 +24,7 @@ dependency to the _dependencies_ section of your build descriptor: [source,groovy,subs="+attributes"] ---- -compile 'io.vertx:vertx-auth-htdigest:3.4.0.Beta1' +compile 'io.vertx:vertx-auth-htdigest:3.4.0-SNAPSHOT' ---- To create an instance you first need an .htdigest file. This file is created using the apache htdigest tool. @@ -33,7 +33,6 @@ Once you've got one of these you can create a `link:../../apidocs/io/vertx/ext/a [source,groovy] ---- -import io.vertx.ext.auth.htdigest.HtdigestAuth def authProvider = HtdigestAuth.create(vertx, ".htdigest") ---- diff --git a/vertx-auth-htdigest/src/main/asciidoc/java/index.adoc b/vertx-auth-htdigest/src/main/asciidoc/java/index.adoc index f7e6a1e0a..49a36b705 100644 --- a/vertx-auth-htdigest/src/main/asciidoc/java/index.adoc +++ b/vertx-auth-htdigest/src/main/asciidoc/java/index.adoc @@ -16,7 +16,7 @@ dependency to the _dependencies_ section of your build descriptor: io.vertx vertx-auth-htdigest - 3.4.0.Beta1 + 3.4.0-SNAPSHOT ---- @@ -24,7 +24,7 @@ dependency to the _dependencies_ section of your build descriptor: [source,groovy,subs="+attributes"] ---- -compile 'io.vertx:vertx-auth-htdigest:3.4.0.Beta1' +compile 'io.vertx:vertx-auth-htdigest:3.4.0-SNAPSHOT' ---- To create an instance you first need an .htdigest file. This file is created using the apache htdigest tool. diff --git a/vertx-auth-htdigest/src/main/asciidoc/js/index.adoc b/vertx-auth-htdigest/src/main/asciidoc/js/index.adoc index 31b8ef321..a6499e0e2 100644 --- a/vertx-auth-htdigest/src/main/asciidoc/js/index.adoc +++ b/vertx-auth-htdigest/src/main/asciidoc/js/index.adoc @@ -16,7 +16,7 @@ dependency to the _dependencies_ section of your build descriptor: io.vertx vertx-auth-htdigest - 3.4.0.Beta1 + 3.4.0-SNAPSHOT ---- @@ -24,7 +24,7 @@ dependency to the _dependencies_ section of your build descriptor: [source,groovy,subs="+attributes"] ---- -compile 'io.vertx:vertx-auth-htdigest:3.4.0.Beta1' +compile 'io.vertx:vertx-auth-htdigest:3.4.0-SNAPSHOT' ---- To create an instance you first need an .htdigest file. This file is created using the apache htdigest tool. diff --git a/vertx-auth-htdigest/src/main/asciidoc/kotlin/index.adoc b/vertx-auth-htdigest/src/main/asciidoc/kotlin/index.adoc new file mode 100644 index 000000000..0b27d35b3 --- /dev/null +++ b/vertx-auth-htdigest/src/main/asciidoc/kotlin/index.adoc @@ -0,0 +1,84 @@ +== .htdigest Auth Provider implementation + +We provide an implementation of `link:../../apidocs/io/vertx/ext/auth/AuthProvider.html[AuthProvider]` which uses the .digest file format +to perform authentication. + +The provider will not watch for updates to the file after loading. If you need dynamic +user management it would be more convenient to use dynamic providers such as jdbc or mongo providers. + +To use this project, add the following +dependency to the _dependencies_ section of your build descriptor: + +* Maven (in your `pom.xml`): + +[source,xml,subs="+attributes"] +---- + + io.vertx + vertx-auth-htdigest + 3.4.0-SNAPSHOT + +---- + +* Gradle (in your `build.gradle` file): + +[source,groovy,subs="+attributes"] +---- +compile 'io.vertx:vertx-auth-htdigest:3.4.0-SNAPSHOT' +---- + +To create an instance you first need an .htdigest file. This file is created using the apache htdigest tool. + +Once you've got one of these you can create a `link:../../apidocs/io/vertx/ext/auth/htdigest/HtdigestAuth.html[HtdigestAuth]` instance as follows: + +[source,kotlin] +---- +var authProvider = HtdigestAuth.create(vertx, ".htdigest") + +---- + +Once you've got your instance you can authenticate with it just like any `link:../../apidocs/io/vertx/ext/auth/AuthProvider.html[AuthProvider]`. + +The out of the box config assumes the usage of the file .htdigest in the root of the project. + +== Authentication + +When authenticating using this implementation, it assumes that the digest authorization header is parsed as a JSON +object which we refer from now on as authentication info: + +[source,kotlin] +---- +var authInfo = json { + obj( + "username" to "Mufasa", + "realm" to "testrealm@host.com", + "nonce" to "dcd98b7102dd2f0e8b11d0f600bfb0c093", + "method" to "GET", + "uri" to "/dir/index.html", + "response" to "6629fae49393a05397450978507c4ef1" + ) +} + +authProvider.authenticate(authInfo, { res -> + if (res.succeeded()) { + var user = res.result() + } else { + // Failed! + } +}) + +---- + +== Provider internal behavior + +The provider will load the specified .htdigest file at start time and will not watch for modifications. If you +require dynamic reloads, you will need to restart the provider. + +The implementation does not have any other state than the digest file itself, this means that validation and +generation of `nonce` strings and counters must be handled outside this provider. + +Finally `auth-int` `qop` is not supported to avoid having to consume potential large blobs of data in order to +validate the hash of the full request. This is usually also not present on modern web browsers. + +If validating if a user has a particular permission it will always return false since the htdigest file is a pure +authentication mechanism and not authorization. \ No newline at end of file diff --git a/vertx-auth-htdigest/src/main/asciidoc/ruby/index.adoc b/vertx-auth-htdigest/src/main/asciidoc/ruby/index.adoc index 9b01a734d..f5206303e 100644 --- a/vertx-auth-htdigest/src/main/asciidoc/ruby/index.adoc +++ b/vertx-auth-htdigest/src/main/asciidoc/ruby/index.adoc @@ -16,7 +16,7 @@ dependency to the _dependencies_ section of your build descriptor: io.vertx vertx-auth-htdigest - 3.4.0.Beta1 + 3.4.0-SNAPSHOT ---- @@ -24,7 +24,7 @@ dependency to the _dependencies_ section of your build descriptor: [source,groovy,subs="+attributes"] ---- -compile 'io.vertx:vertx-auth-htdigest:3.4.0.Beta1' +compile 'io.vertx:vertx-auth-htdigest:3.4.0-SNAPSHOT' ---- To create an instance you first need an .htdigest file. This file is created using the apache htdigest tool. diff --git a/vertx-auth-htdigest/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule b/vertx-auth-htdigest/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule deleted file mode 100644 index c2e695829..000000000 --- a/vertx-auth-htdigest/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule +++ /dev/null @@ -1,4 +0,0 @@ -moduleName = io.vertx.ext.auth.htdigest.HtdigestAuth-module -moduleVersion = 1.0 -extensionClasses = -staticExtensionClasses = diff --git a/vertx-auth-htdigest/src/main/resources/vertx-auth-htdigest-js/htdigest_auth.js b/vertx-auth-htdigest/src/main/resources/vertx-auth-htdigest-js/htdigest_auth.js deleted file mode 100644 index 06e86c88e..000000000 --- a/vertx-auth-htdigest/src/main/resources/vertx-auth-htdigest-js/htdigest_auth.js +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright 2014 Red Hat, Inc. - * - * Red Hat 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. - */ - -/** @module vertx-auth-htdigest-js/htdigest_auth */ -var utils = require('vertx-js/util/utils'); -var User = require('vertx-auth-common-js/user'); -var Vertx = require('vertx-js/vertx'); -var AuthProvider = require('vertx-auth-common-js/auth_provider'); - -var io = Packages.io; -var JsonObject = io.vertx.core.json.JsonObject; -var JHtdigestAuth = Java.type('io.vertx.ext.auth.htdigest.HtdigestAuth'); - -/** - An extension of AuthProvider which is using .htdigest file as store - - @class -*/ -var HtdigestAuth = function(j_val) { - - var j_htdigestAuth = j_val; - var that = this; - AuthProvider.call(this, j_val); - - /** - - @public - @param arg0 {Object} - @param arg1 {function} - */ - this.authenticate = function(arg0, arg1) { - var __args = arguments; - if (__args.length === 2 && (typeof __args[0] === 'object' && __args[0] != null) && typeof __args[1] === 'function') { - j_htdigestAuth["authenticate(io.vertx.core.json.JsonObject,io.vertx.core.Handler)"](utils.convParamJsonObject(arg0), function(ar) { - if (ar.succeeded()) { - arg1(utils.convReturnVertxGen(User, ar.result()), null); - } else { - arg1(null, ar.cause()); - } - }); - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - Return the currently used realm - - @public - - @return {string} the realm - */ - this.realm = function() { - var __args = arguments; - if (__args.length === 0) { - return j_htdigestAuth["realm()"](); - } else throw new TypeError('function invoked with invalid arguments'); - }; - - // A reference to the underlying Java delegate - // NOTE! This is an internal API and must not be used in user code. - // If you rely on this property your code is likely to break if we change it / remove it without warning. - this._jdel = j_htdigestAuth; -}; - -HtdigestAuth._jclass = utils.getJavaClass("io.vertx.ext.auth.htdigest.HtdigestAuth"); -HtdigestAuth._jtype = { - accept: function(obj) { - return HtdigestAuth._jclass.isInstance(obj._jdel); - }, - wrap: function(jdel) { - var obj = Object.create(HtdigestAuth.prototype, {}); - HtdigestAuth.apply(obj, arguments); - return obj; - }, - unwrap: function(obj) { - return obj._jdel; - } -}; -HtdigestAuth._create = function(jdel) { - var obj = Object.create(HtdigestAuth.prototype, {}); - HtdigestAuth.apply(obj, arguments); - return obj; -} -/** - Creates an instance of HtdigestAuth by using the given htfile file. - - @memberof module:vertx-auth-htdigest-js/htdigest_auth - @param vertx {Vertx} - @param htfile {string} the existing htfile. - @return {HtdigestAuth} the created instance of {@link HtdigestAuth}s - */ -HtdigestAuth.create = function() { - var __args = arguments; - if (__args.length === 1 && typeof __args[0] === 'object' && __args[0]._jdel) { - return utils.convReturnVertxGen(HtdigestAuth, JHtdigestAuth["create(io.vertx.core.Vertx)"](__args[0]._jdel)); - }else if (__args.length === 2 && typeof __args[0] === 'object' && __args[0]._jdel && typeof __args[1] === 'string') { - return utils.convReturnVertxGen(HtdigestAuth, JHtdigestAuth["create(io.vertx.core.Vertx,java.lang.String)"](__args[0]._jdel, __args[1])); - } else throw new TypeError('function invoked with invalid arguments'); -}; - -module.exports = HtdigestAuth; \ No newline at end of file diff --git a/vertx-auth-htdigest/src/main/resources/vertx-auth-htdigest/htdigest_auth.rb b/vertx-auth-htdigest/src/main/resources/vertx-auth-htdigest/htdigest_auth.rb deleted file mode 100644 index b8c712e9d..000000000 --- a/vertx-auth-htdigest/src/main/resources/vertx-auth-htdigest/htdigest_auth.rb +++ /dev/null @@ -1,66 +0,0 @@ -require 'vertx-auth-common/user' -require 'vertx/vertx' -require 'vertx-auth-common/auth_provider' -require 'vertx/util/utils.rb' -# Generated from io.vertx.ext.auth.htdigest.HtdigestAuth -module VertxAuthHtdigest - # An extension of AuthProvider which is using .htdigest file as store - class HtdigestAuth < ::VertxAuthCommon::AuthProvider - # @private - # @param j_del [::VertxAuthHtdigest::HtdigestAuth] the java delegate - def initialize(j_del) - super(j_del) - @j_del = j_del - end - # @private - # @return [::VertxAuthHtdigest::HtdigestAuth] the underlying java delegate - def j_del - @j_del - end - @@j_api_type = Object.new - def @@j_api_type.accept?(obj) - obj.class == HtdigestAuth - end - def @@j_api_type.wrap(obj) - HtdigestAuth.new(obj) - end - def @@j_api_type.unwrap(obj) - obj.j_del - end - def self.j_api_type - @@j_api_type - end - def self.j_class - Java::IoVertxExtAuthHtdigest::HtdigestAuth.java_class - end - # @param [Hash{String => Object}] arg0 - # @yield - # @return [void] - def authenticate(arg0=nil) - if arg0.class == Hash && block_given? - return @j_del.java_method(:authenticate, [Java::IoVertxCoreJson::JsonObject.java_class,Java::IoVertxCore::Handler.java_class]).call(::Vertx::Util::Utils.to_json_object(arg0),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxAuthCommon::User) : nil) })) - end - raise ArgumentError, "Invalid arguments when calling authenticate(#{arg0})" - end - # Creates an instance of HtdigestAuth by using the given htfile file. - # @param [::Vertx::Vertx] vertx - # @param [String] htfile the existing htfile. - # @return [::VertxAuthHtdigest::HtdigestAuth] the created instance of {::VertxAuthHtdigest::HtdigestAuth}s - def self.create(vertx=nil,htfile=nil) - if vertx.class.method_defined?(:j_del) && !block_given? && htfile == nil - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthHtdigest::HtdigestAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class]).call(vertx.j_del),::VertxAuthHtdigest::HtdigestAuth) - elsif vertx.class.method_defined?(:j_del) && htfile.class == String && !block_given? - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthHtdigest::HtdigestAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class]).call(vertx.j_del,htfile),::VertxAuthHtdigest::HtdigestAuth) - end - raise ArgumentError, "Invalid arguments when calling create(#{vertx},#{htfile})" - end - # Return the currently used realm - # @return [String] the realm - def realm - if !block_given? - return @j_del.java_method(:realm, []).call() - end - raise ArgumentError, "Invalid arguments when calling realm()" - end - end -end diff --git a/vertx-auth-jdbc/src/main/asciidoc/groovy/index.adoc b/vertx-auth-jdbc/src/main/asciidoc/groovy/index.adoc index 9e1b12b8c..ece3274ee 100644 --- a/vertx-auth-jdbc/src/main/asciidoc/groovy/index.adoc +++ b/vertx-auth-jdbc/src/main/asciidoc/groovy/index.adoc @@ -13,7 +13,7 @@ add the following dependency to the _dependencies_ section of your build descrip io.vertx vertx-auth-jdbc - 3.4.0.Beta1 + 3.4.0-SNAPSHOT ---- @@ -21,7 +21,7 @@ add the following dependency to the _dependencies_ section of your build descrip [source,groovy,subs="+attributes"] ---- -compile 'io.vertx:vertx-auth-jdbc:3.4.0.Beta1' +compile 'io.vertx:vertx-auth-jdbc:3.4.0-SNAPSHOT' ---- To create an instance you first need an instance of `link:../../apidocs/io/vertx/ext/jdbc/JDBCClient.html[JDBCClient]`. To learn how to create one @@ -31,8 +31,6 @@ Once you've got one of those you can create a `link:../../apidocs/io/vertx/ext/a [source,groovy] ---- -import io.vertx.ext.jdbc.JDBCClient -import io.vertx.ext.auth.jdbc.JDBCAuth def jdbcClient = JDBCClient.createShared(vertx, jdbcClientConfig) diff --git a/vertx-auth-jdbc/src/main/asciidoc/java/index.adoc b/vertx-auth-jdbc/src/main/asciidoc/java/index.adoc index 90fbdef04..2e65ede54 100644 --- a/vertx-auth-jdbc/src/main/asciidoc/java/index.adoc +++ b/vertx-auth-jdbc/src/main/asciidoc/java/index.adoc @@ -13,7 +13,7 @@ add the following dependency to the _dependencies_ section of your build descrip io.vertx vertx-auth-jdbc - 3.4.0.Beta1 + 3.4.0-SNAPSHOT ---- @@ -21,7 +21,7 @@ add the following dependency to the _dependencies_ section of your build descrip [source,groovy,subs="+attributes"] ---- -compile 'io.vertx:vertx-auth-jdbc:3.4.0.Beta1' +compile 'io.vertx:vertx-auth-jdbc:3.4.0-SNAPSHOT' ---- To create an instance you first need an instance of `link:../../apidocs/io/vertx/ext/jdbc/JDBCClient.html[JDBCClient]`. To learn how to create one diff --git a/vertx-auth-jdbc/src/main/asciidoc/js/index.adoc b/vertx-auth-jdbc/src/main/asciidoc/js/index.adoc index bd5c5f467..6bf5c6aa3 100644 --- a/vertx-auth-jdbc/src/main/asciidoc/js/index.adoc +++ b/vertx-auth-jdbc/src/main/asciidoc/js/index.adoc @@ -13,7 +13,7 @@ add the following dependency to the _dependencies_ section of your build descrip io.vertx vertx-auth-jdbc - 3.4.0.Beta1 + 3.4.0-SNAPSHOT ---- @@ -21,7 +21,7 @@ add the following dependency to the _dependencies_ section of your build descrip [source,groovy,subs="+attributes"] ---- -compile 'io.vertx:vertx-auth-jdbc:3.4.0.Beta1' +compile 'io.vertx:vertx-auth-jdbc:3.4.0-SNAPSHOT' ---- To create an instance you first need an instance of `link:../../jsdoc/module-vertx-jdbc-js_jdbc_client-JDBCClient.html[JDBCClient]`. To learn how to create one diff --git a/vertx-auth-jdbc/src/main/asciidoc/kotlin/index.adoc b/vertx-auth-jdbc/src/main/asciidoc/kotlin/index.adoc new file mode 100644 index 000000000..ab33c4285 --- /dev/null +++ b/vertx-auth-jdbc/src/main/asciidoc/kotlin/index.adoc @@ -0,0 +1,182 @@ +== JDBC Auth Provider implementation + +We provide an implementation of `link:../../apidocs/io/vertx/ext/auth/AuthProvider.html[AuthProvider]` which uses the Vert.x `link:../../apidocs/io/vertx/ext/jdbc/JDBCClient.html[JDBCClient]` +to perform authentication and authorisation against any JDBC compliant database. + +To use this project, +add the following dependency to the _dependencies_ section of your build descriptor: + +* Maven (in your `pom.xml`): + +[source,xml,subs="+attributes"] +---- + + io.vertx + vertx-auth-jdbc + 3.4.0-SNAPSHOT + +---- + +* Gradle (in your `build.gradle` file): + +[source,groovy,subs="+attributes"] +---- +compile 'io.vertx:vertx-auth-jdbc:3.4.0-SNAPSHOT' +---- + +To create an instance you first need an instance of `link:../../apidocs/io/vertx/ext/jdbc/JDBCClient.html[JDBCClient]`. To learn how to create one +of those please consult the documentation for the JDBC client. + +Once you've got one of those you can create a `link:../../apidocs/io/vertx/ext/auth/jdbc/JDBCAuth.html[JDBCAuth]` instance as follows: + +[source,kotlin] +---- + +var jdbcClient = JDBCClient.createShared(vertx, jdbcClientConfig) + +var authProvider = JDBCAuth.create(vertx, jdbcClient) + +---- + +Once you've got your instance you can authenticate and authorise with it just like any `link:../../apidocs/io/vertx/ext/auth/AuthProvider.html[AuthProvider]`. + +The out of the box config assumes certain queries for authentication and authorisation, these can easily be changed +with the operations `link:../../apidocs/io/vertx/ext/auth/jdbc/JDBCAuth.html#setAuthenticationQuery-java.lang.String-[setAuthenticationQuery]`, +`link:../../apidocs/io/vertx/ext/auth/jdbc/JDBCAuth.html#setPermissionsQuery-java.lang.String-[setPermissionsQuery]` and +`link:../../apidocs/io/vertx/ext/auth/jdbc/JDBCAuth.html#setRolesQuery-java.lang.String-[setRolesQuery]`, if you want to use them with a different +database schema. + +The default implementation assumes that the password is stored in the database as a SHA-512 hash after being +concatenated with a salt. It also assumes the salt is stored in the table too. + +The basic data definition for the storage should look like this: + +[source,sql] +---- +-- +-- Take this script with a grain of salt and adapt it to your RDBMS +-- +CREATE TABLE `user` ( + `username` VARCHAR(255) NOT NULL, + `password` VARCHAR(255) NOT NULL, + `password_salt` VARCHAR(255) NOT NULL +); + +CREATE TABLE `user_roles` ( + `username` VARCHAR(255) NOT NULL, + `role` VARCHAR(255) NOT NULL +); + +CREATE TABLE `roles_perms` ( + `role` VARCHAR(255) NOT NULL, + `perm` VARCHAR(255) NOT NULL +); + +ALTER TABLE user ADD CONSTRAINT `pk_username` PRIMARY KEY (username); +ALTER TABLE user_roles ADD CONSTRAINT `pk_user_roles` PRIMARY KEY (username, role); +ALTER TABLE roles_perms ADD CONSTRAINT `pk_roles_perms` PRIMARY KEY (role); + +ALTER TABLE user_roles ADD CONSTRAINT fk_username FOREIGN KEY (username) REFERENCES user(username); +ALTER TABLE user_roles ADD CONSTRAINT fk_roles FOREIGN KEY (role) REFERENCES roles_perms(role); + +---- + +If you want to override this behaviour you can do so by providing an alternative hash strategy and setting it with +`link:../../apidocs/io/vertx/ext/auth/jdbc/JDBCAuth.html#setHashStrategy-io.vertx.ext.auth.jdbc.JDBCHashStrategy-[setHashStrategy]`. + +WARNING: It is advised to always store your passwords as hashes in your database tables which have been created +with a salt which should be stored in the row too. A strong hashing algorithm should be used. It is strongly advised +never to store your passwords as plain text. + +== Hashing passwords + +Like any application there will be a time where you need to store new users into the database. Has you have learn +passwords are not stored in plain text but hashed according to the hashing strategy. The same strategy is required +to hash new password before storing it to the database. Doing it is a 3 step task. + +1. Generate a salt string +2. Hash the password given the salt string +3. Store it to the database + +[source,kotlin] +---- + +var salt = auth.generateSalt() +var hash = auth.computeHash("sausages", salt) +// save to the database +conn.updateWithParams("INSERT INTO user VALUES (?, ?, ?)", json { + array("tim", hash, salt) +}, { res -> + if (res.succeeded()) { + // success! + } +}) + +---- + +== Authentication + +When authenticating using this implementation, it assumes `username` and `password` fields are present in the +authentication info: + +[source,kotlin] +---- + +var authInfo = json { + obj( + "username" to "tim", + "password" to "sausages" + ) +} + +authProvider.authenticate(authInfo, { res -> + if (res.succeeded()) { + var user = res.result() + } else { + // Failed! + } +}) + +---- + +== Authorisation - Permission-Role Model + +Although Vert.x auth itself does not mandate any specific model of permissions (they are just opaque strings), this +implementation assumes a familiar user/role/permission model, where a user can have zero or more roles and a role +can have zero or more permissions. + +If validating if a user has a particular permission simply pass the permission into. +`link:../../apidocs/io/vertx/ext/auth/User.html#isAuthorised-java.lang.String-io.vertx.core.Handler-[isAuthorised]` as follows: + +[source,kotlin] +---- + +user.isAuthorised("commit_code", { res -> + if (res.succeeded()) { + var hasPermission = res.result() + } else { + // Failed to + } +}) + + +---- + +If validating that a user has a particular _role_ then you should prefix the argument with the role prefix. + +[source,kotlin] +---- + +user.isAuthorised("role:manager", { res -> + if (res.succeeded()) { + var hasRole = res.result() + } else { + // Failed to + } +}) + + +---- + +The default role prefix is `role:`. You can change this with `link:../../apidocs/io/vertx/ext/auth/jdbc/JDBCAuth.html#setRolePrefix-java.lang.String-[setRolePrefix]`. +Julien VietTim Fox \ No newline at end of file diff --git a/vertx-auth-jdbc/src/main/asciidoc/ruby/index.adoc b/vertx-auth-jdbc/src/main/asciidoc/ruby/index.adoc index 9640da6fe..3c462bb78 100644 --- a/vertx-auth-jdbc/src/main/asciidoc/ruby/index.adoc +++ b/vertx-auth-jdbc/src/main/asciidoc/ruby/index.adoc @@ -13,7 +13,7 @@ add the following dependency to the _dependencies_ section of your build descrip io.vertx vertx-auth-jdbc - 3.4.0.Beta1 + 3.4.0-SNAPSHOT ---- @@ -21,7 +21,7 @@ add the following dependency to the _dependencies_ section of your build descrip [source,groovy,subs="+attributes"] ---- -compile 'io.vertx:vertx-auth-jdbc:3.4.0.Beta1' +compile 'io.vertx:vertx-auth-jdbc:3.4.0-SNAPSHOT' ---- To create an instance you first need an instance of `link:../../yardoc/VertxJdbc/JDBCClient.html[JDBCClient]`. To learn how to create one diff --git a/vertx-auth-jdbc/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule b/vertx-auth-jdbc/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule deleted file mode 100644 index 93b14408f..000000000 --- a/vertx-auth-jdbc/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule +++ /dev/null @@ -1,4 +0,0 @@ -moduleName = io.vertx.ext.auth.jdbc.JDBCAuth-module -moduleVersion = 1.0 -extensionClasses = -staticExtensionClasses = diff --git a/vertx-auth-jdbc/src/main/resources/vertx-auth-jdbc-js/jdbc_auth.js b/vertx-auth-jdbc/src/main/resources/vertx-auth-jdbc-js/jdbc_auth.js deleted file mode 100644 index d13737cca..000000000 --- a/vertx-auth-jdbc/src/main/resources/vertx-auth-jdbc-js/jdbc_auth.js +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Copyright 2014 Red Hat, Inc. - * - * Red Hat 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. - */ - -/** @module vertx-auth-jdbc-js/jdbc_auth */ -var utils = require('vertx-js/util/utils'); -var User = require('vertx-auth-common-js/user'); -var JDBCClient = require('vertx-jdbc-js/jdbc_client'); -var Vertx = require('vertx-js/vertx'); -var AuthProvider = require('vertx-auth-common-js/auth_provider'); - -var io = Packages.io; -var JsonObject = io.vertx.core.json.JsonObject; -var JJDBCAuth = Java.type('io.vertx.ext.auth.jdbc.JDBCAuth'); - -/** - - @class -*/ -var JDBCAuth = function(j_val) { - - var j_jDBCAuth = j_val; - var that = this; - AuthProvider.call(this, j_val); - - /** - - @public - @param arg0 {Object} - @param arg1 {function} - */ - this.authenticate = function(arg0, arg1) { - var __args = arguments; - if (__args.length === 2 && (typeof __args[0] === 'object' && __args[0] != null) && typeof __args[1] === 'function') { - j_jDBCAuth["authenticate(io.vertx.core.json.JsonObject,io.vertx.core.Handler)"](utils.convParamJsonObject(arg0), function(ar) { - if (ar.succeeded()) { - arg1(utils.convReturnVertxGen(User, ar.result()), null); - } else { - arg1(null, ar.cause()); - } - }); - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - Set the authentication query to use. Use this if you want to override the default authentication query. - - @public - @param authenticationQuery {string} the authentication query - @return {JDBCAuth} a reference to this for fluency - */ - this.setAuthenticationQuery = function(authenticationQuery) { - var __args = arguments; - if (__args.length === 1 && typeof __args[0] === 'string') { - return utils.convReturnVertxGen(JDBCAuth, j_jDBCAuth["setAuthenticationQuery(java.lang.String)"](authenticationQuery)); - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - Set the roles query to use. Use this if you want to override the default roles query. - - @public - @param rolesQuery {string} the roles query - @return {JDBCAuth} a reference to this for fluency - */ - this.setRolesQuery = function(rolesQuery) { - var __args = arguments; - if (__args.length === 1 && typeof __args[0] === 'string') { - return utils.convReturnVertxGen(JDBCAuth, j_jDBCAuth["setRolesQuery(java.lang.String)"](rolesQuery)); - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - Set the permissions query to use. Use this if you want to override the default permissions query. - - @public - @param permissionsQuery {string} the permissions query - @return {JDBCAuth} a reference to this for fluency - */ - this.setPermissionsQuery = function(permissionsQuery) { - var __args = arguments; - if (__args.length === 1 && typeof __args[0] === 'string') { - return utils.convReturnVertxGen(JDBCAuth, j_jDBCAuth["setPermissionsQuery(java.lang.String)"](permissionsQuery)); - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - Set the role prefix to distinguish from permissions when checking for isPermitted requests. - - @public - @param rolePrefix {string} a Prefix e.g.: "role:" - @return {JDBCAuth} a reference to this for fluency - */ - this.setRolePrefix = function(rolePrefix) { - var __args = arguments; - if (__args.length === 1 && typeof __args[0] === 'string') { - return utils.convReturnVertxGen(JDBCAuth, j_jDBCAuth["setRolePrefix(java.lang.String)"](rolePrefix)); - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - Compute the hashed password given the unhashed password and the salt - - The implementation relays to the JDBCHashStrategy provided. - - @public - @param password {string} the unhashed password - @param salt {string} the salt - @return {string} the hashed password - */ - this.computeHash = function(password, salt) { - var __args = arguments; - if (__args.length === 2 && typeof __args[0] === 'string' && typeof __args[1] === 'string') { - return j_jDBCAuth["computeHash(java.lang.String,java.lang.String)"](password, salt); - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - Compute a salt string. - - The implementation relays to the JDBCHashStrategy provided. - - @public - - @return {string} a non null salt value - */ - this.generateSalt = function() { - var __args = arguments; - if (__args.length === 0) { - return j_jDBCAuth["generateSalt()"](); - } else throw new TypeError('function invoked with invalid arguments'); - }; - - // A reference to the underlying Java delegate - // NOTE! This is an internal API and must not be used in user code. - // If you rely on this property your code is likely to break if we change it / remove it without warning. - this._jdel = j_jDBCAuth; -}; - -JDBCAuth._jclass = utils.getJavaClass("io.vertx.ext.auth.jdbc.JDBCAuth"); -JDBCAuth._jtype = { - accept: function(obj) { - return JDBCAuth._jclass.isInstance(obj._jdel); - }, - wrap: function(jdel) { - var obj = Object.create(JDBCAuth.prototype, {}); - JDBCAuth.apply(obj, arguments); - return obj; - }, - unwrap: function(obj) { - return obj._jdel; - } -}; -JDBCAuth._create = function(jdel) { - var obj = Object.create(JDBCAuth.prototype, {}); - JDBCAuth.apply(obj, arguments); - return obj; -} -/** - Create a JDBC auth provider implementation - - @memberof module:vertx-auth-jdbc-js/jdbc_auth - @param vertx {Vertx} - @param client {JDBCClient} the JDBC client instance - @return {JDBCAuth} the auth provider - */ -JDBCAuth.create = function(vertx, client) { - var __args = arguments; - if (__args.length === 2 && typeof __args[0] === 'object' && __args[0]._jdel && typeof __args[1] === 'object' && __args[1]._jdel) { - return utils.convReturnVertxGen(JDBCAuth, JJDBCAuth["create(io.vertx.core.Vertx,io.vertx.ext.jdbc.JDBCClient)"](vertx._jdel, client._jdel)); - } else throw new TypeError('function invoked with invalid arguments'); -}; - -module.exports = JDBCAuth; \ No newline at end of file diff --git a/vertx-auth-jdbc/src/main/resources/vertx-auth-jdbc/jdbc_auth.rb b/vertx-auth-jdbc/src/main/resources/vertx-auth-jdbc/jdbc_auth.rb deleted file mode 100644 index 7ddf8e2f1..000000000 --- a/vertx-auth-jdbc/src/main/resources/vertx-auth-jdbc/jdbc_auth.rb +++ /dev/null @@ -1,115 +0,0 @@ -require 'vertx-auth-common/user' -require 'vertx-jdbc/jdbc_client' -require 'vertx/vertx' -require 'vertx-auth-common/auth_provider' -require 'vertx/util/utils.rb' -# Generated from io.vertx.ext.auth.jdbc.JDBCAuth -module VertxAuthJdbc - # Factory interface for creating {::VertxAuthCommon::AuthProvider} instances that use the Vert.x JDBC client - class JDBCAuth < ::VertxAuthCommon::AuthProvider - # @private - # @param j_del [::VertxAuthJdbc::JDBCAuth] the java delegate - def initialize(j_del) - super(j_del) - @j_del = j_del - end - # @private - # @return [::VertxAuthJdbc::JDBCAuth] the underlying java delegate - def j_del - @j_del - end - @@j_api_type = Object.new - def @@j_api_type.accept?(obj) - obj.class == JDBCAuth - end - def @@j_api_type.wrap(obj) - JDBCAuth.new(obj) - end - def @@j_api_type.unwrap(obj) - obj.j_del - end - def self.j_api_type - @@j_api_type - end - def self.j_class - Java::IoVertxExtAuthJdbc::JDBCAuth.java_class - end - # @param [Hash{String => Object}] arg0 - # @yield - # @return [void] - def authenticate(arg0=nil) - if arg0.class == Hash && block_given? - return @j_del.java_method(:authenticate, [Java::IoVertxCoreJson::JsonObject.java_class,Java::IoVertxCore::Handler.java_class]).call(::Vertx::Util::Utils.to_json_object(arg0),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxAuthCommon::User) : nil) })) - end - raise ArgumentError, "Invalid arguments when calling authenticate(#{arg0})" - end - # Create a JDBC auth provider implementation - # @param [::Vertx::Vertx] vertx - # @param [::VertxJdbc::JDBCClient] client the JDBC client instance - # @return [::VertxAuthJdbc::JDBCAuth] the auth provider - def self.create(vertx=nil,client=nil) - if vertx.class.method_defined?(:j_del) && client.class.method_defined?(:j_del) && !block_given? - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthJdbc::JDBCAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxExtJdbc::JDBCClient.java_class]).call(vertx.j_del,client.j_del),::VertxAuthJdbc::JDBCAuth) - end - raise ArgumentError, "Invalid arguments when calling create(#{vertx},#{client})" - end - # Set the authentication query to use. Use this if you want to override the default authentication query. - # @param [String] authenticationQuery the authentication query - # @return [::VertxAuthJdbc::JDBCAuth] a reference to this for fluency - def set_authentication_query(authenticationQuery=nil) - if authenticationQuery.class == String && !block_given? - return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:setAuthenticationQuery, [Java::java.lang.String.java_class]).call(authenticationQuery),::VertxAuthJdbc::JDBCAuth) - end - raise ArgumentError, "Invalid arguments when calling set_authentication_query(#{authenticationQuery})" - end - # Set the roles query to use. Use this if you want to override the default roles query. - # @param [String] rolesQuery the roles query - # @return [::VertxAuthJdbc::JDBCAuth] a reference to this for fluency - def set_roles_query(rolesQuery=nil) - if rolesQuery.class == String && !block_given? - return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:setRolesQuery, [Java::java.lang.String.java_class]).call(rolesQuery),::VertxAuthJdbc::JDBCAuth) - end - raise ArgumentError, "Invalid arguments when calling set_roles_query(#{rolesQuery})" - end - # Set the permissions query to use. Use this if you want to override the default permissions query. - # @param [String] permissionsQuery the permissions query - # @return [::VertxAuthJdbc::JDBCAuth] a reference to this for fluency - def set_permissions_query(permissionsQuery=nil) - if permissionsQuery.class == String && !block_given? - return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:setPermissionsQuery, [Java::java.lang.String.java_class]).call(permissionsQuery),::VertxAuthJdbc::JDBCAuth) - end - raise ArgumentError, "Invalid arguments when calling set_permissions_query(#{permissionsQuery})" - end - # Set the role prefix to distinguish from permissions when checking for isPermitted requests. - # @param [String] rolePrefix a Prefix e.g.: "role:" - # @return [::VertxAuthJdbc::JDBCAuth] a reference to this for fluency - def set_role_prefix(rolePrefix=nil) - if rolePrefix.class == String && !block_given? - return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:setRolePrefix, [Java::java.lang.String.java_class]).call(rolePrefix),::VertxAuthJdbc::JDBCAuth) - end - raise ArgumentError, "Invalid arguments when calling set_role_prefix(#{rolePrefix})" - end - # Compute the hashed password given the unhashed password and the salt - # - # The implementation relays to the JDBCHashStrategy provided. - # @param [String] password the unhashed password - # @param [String] salt the salt - # @return [String] the hashed password - def compute_hash(password=nil,salt=nil) - if password.class == String && salt.class == String && !block_given? - return @j_del.java_method(:computeHash, [Java::java.lang.String.java_class,Java::java.lang.String.java_class]).call(password,salt) - end - raise ArgumentError, "Invalid arguments when calling compute_hash(#{password},#{salt})" - end - # Compute a salt string. - # - # The implementation relays to the JDBCHashStrategy provided. - # @return [String] a non null salt value - def generate_salt - if !block_given? - return @j_del.java_method(:generateSalt, []).call() - end - raise ArgumentError, "Invalid arguments when calling generate_salt()" - end - end -end diff --git a/vertx-auth-jwt/src/main/asciidoc/groovy/index.adoc b/vertx-auth-jwt/src/main/asciidoc/groovy/index.adoc index 239cfe5e7..9d643af59 100644 --- a/vertx-auth-jwt/src/main/asciidoc/groovy/index.adoc +++ b/vertx-auth-jwt/src/main/asciidoc/groovy/index.adoc @@ -12,7 +12,7 @@ dependency to the _dependencies_ section of your build descriptor: io.vertx vertx-auth-jwt - 3.4.0.Beta1 + 3.4.0-SNAPSHOT ---- @@ -20,7 +20,7 @@ dependency to the _dependencies_ section of your build descriptor: [source,groovy,subs="+attributes"] ---- -compile 'io.vertx:vertx-auth-jwt:3.4.0.Beta1' +compile 'io.vertx:vertx-auth-jwt:3.4.0-SNAPSHOT' ---- JSON Web Token is a simple way to send information in the clear (usually in a URL) whose contents can be @@ -50,7 +50,6 @@ Here's an example of creating a JWT auth provider: [source,java] ---- -import io.vertx.ext.auth.jwt.JWTAuth def config = [ keyStore:[ @@ -70,7 +69,6 @@ do: [source,java] ---- -import io.vertx.ext.auth.jwt.JWTAuth def config = [ keyStore:[ @@ -145,7 +143,6 @@ case all you need to have is a public key im PEM format. [source,groovy] ---- -import io.vertx.ext.auth.jwt.JWTAuth def config = [ 'public-key':"BASE64-ENCODED-PUBLIC_KEY" diff --git a/vertx-auth-jwt/src/main/asciidoc/java/index.adoc b/vertx-auth-jwt/src/main/asciidoc/java/index.adoc index 12c2028fd..f06a8b0ec 100644 --- a/vertx-auth-jwt/src/main/asciidoc/java/index.adoc +++ b/vertx-auth-jwt/src/main/asciidoc/java/index.adoc @@ -12,7 +12,7 @@ dependency to the _dependencies_ section of your build descriptor: io.vertx vertx-auth-jwt - 3.4.0.Beta1 + 3.4.0-SNAPSHOT ---- @@ -20,7 +20,7 @@ dependency to the _dependencies_ section of your build descriptor: [source,groovy,subs="+attributes"] ---- -compile 'io.vertx:vertx-auth-jwt:3.4.0.Beta1' +compile 'io.vertx:vertx-auth-jwt:3.4.0-SNAPSHOT' ---- JSON Web Token is a simple way to send information in the clear (usually in a URL) whose contents can be diff --git a/vertx-auth-jwt/src/main/asciidoc/js/index.adoc b/vertx-auth-jwt/src/main/asciidoc/js/index.adoc index a6335e1e6..d217c5f09 100644 --- a/vertx-auth-jwt/src/main/asciidoc/js/index.adoc +++ b/vertx-auth-jwt/src/main/asciidoc/js/index.adoc @@ -12,7 +12,7 @@ dependency to the _dependencies_ section of your build descriptor: io.vertx vertx-auth-jwt - 3.4.0.Beta1 + 3.4.0-SNAPSHOT ---- @@ -20,7 +20,7 @@ dependency to the _dependencies_ section of your build descriptor: [source,groovy,subs="+attributes"] ---- -compile 'io.vertx:vertx-auth-jwt:3.4.0.Beta1' +compile 'io.vertx:vertx-auth-jwt:3.4.0-SNAPSHOT' ---- JSON Web Token is a simple way to send information in the clear (usually in a URL) whose contents can be diff --git a/vertx-auth-jwt/src/main/asciidoc/kotlin/index.adoc b/vertx-auth-jwt/src/main/asciidoc/kotlin/index.adoc new file mode 100644 index 000000000..bf37ea28d --- /dev/null +++ b/vertx-auth-jwt/src/main/asciidoc/kotlin/index.adoc @@ -0,0 +1,153 @@ +== The JWT auth provider + +This component contains an out of the box a JWT implementation. + +To use this project, add the following +dependency to the _dependencies_ section of your build descriptor: + +* Maven (in your `pom.xml`): + +[source,xml,subs="+attributes"] +---- + + io.vertx + vertx-auth-jwt + 3.4.0-SNAPSHOT + +---- + +* Gradle (in your `build.gradle` file): + +[source,groovy,subs="+attributes"] +---- +compile 'io.vertx:vertx-auth-jwt:3.4.0-SNAPSHOT' +---- + +JSON Web Token is a simple way to send information in the clear (usually in a URL) whose contents can be +verified to +be trusted. JWT are well suited for scenarios as: + +* In a Single Sign-On scenario where you want a separate authentication server that can then send user +information in a trusted way. +* Stateless API servers, very well suited for simple page applications. +* etc... + +Before deciding on using JWT, it's important to note that JWT does not encrypt the payload, it only signs it. You +should not send any secret information using JWT, rather you should send information that is not secret but needs to +be verified. For instance, sending a signed user id to indicate the user that should be logged in would work great! +Sending a user's password would be very, very bad. + +Its main advantages are: + +* It allows you to verify token authenticity. +* It has a json body to contain any variable amount of data you want. +* It's completely stateless. + +To create an instance of the provider you use `link:../../apidocs/io/vertx/ext/auth/jwt/JWTAuth.html[JWTAuth]`. You specify the configuration +in a JSON object. + +Here's an example of creating a JWT auth provider: + +[source,java] +---- + +var config = json { + obj("keyStore" to obj( + "path" to "keystore.jceks", + "type" to "jceks", + "password" to "secret" + )) +} + +var provider = JWTAuth.create(vertx, config) + +---- + +A typical flow of JWT usage is that in your application you have one end point that issues tokens, this end point +should be running in SSL mode, there after you verify the request user, say by its username and password you would +do: + +[source,java] +---- + +var config = json { + obj("keyStore" to obj( + "path" to "keystore.jceks", + "type" to "jceks", + "password" to "secret" + )) +} + +var provider = JWTAuth.create(vertx, config) + +// on the verify endpoint once you verify the identity of the user by its username/password +if ("paulo" == username && "super_secret" == password) { + var token = provider.generateToken(json { + obj("sub" to "paulo") + }, JWTOptions()) + // now for any request to protected resources you should pass this string in the HTTP header Authorization as: + // Authorization: Bearer +} + +---- + +// TODO show example of authentication and authorisation with JWT and explain how the permission string passed +// in authorisation maps to the claims in the JW token + + +=== The JWT keystore file + +This auth provider requires a keystore in the classpath or in the filesystem with either a +`https://docs.oracle.com/javase/8/docs/api/javax/crypto/Mac.html[javax.crypto.Mac]` +or a `https://docs.oracle.com/javase/8/docs/api/java/security/Signature.html[java.security.Signature]` in order to +sign and verify the generated tokens. + +The implementation will, by default, look for the following aliases, however not all are required to be present. As +a good practice `HS256` should be present: +---- +`HS256`:: HMAC using SHA-256 hash algorithm +`HS384`:: HMAC using SHA-384 hash algorithm +`HS512`:: HMAC using SHA-512 hash algorithm +`RS256`:: RSASSA using SHA-256 hash algorithm +`RS384`:: RSASSA using SHA-384 hash algorithm +`RS512`:: RSASSA using SHA-512 hash algorithm +`ES256`:: ECDSA using P-256 curve and SHA-256 hash algorithm +`ES384`:: ECDSA using P-384 curve and SHA-384 hash algorithm +`ES512`:: ECDSA using P-521 curve and SHA-512 hash algorithm +---- + +When no keystore is provided the implementation falls back in unsecure mode and signatures will not be verified, this +is useful for the cases where the payload if signed and or encrypted by external means. + +=== Generate a new Keystore file + +The only required tool to generate a keystore file is `keytool`, you can now specify which algorithms you need by +running: + +---- +keytool -genseckey -keystore keystore.jceks -storetype jceks -storepass secret -keyalg HMacSHA256 -keysize 2048 -alias HS256 -keypass secret +keytool -genseckey -keystore keystore.jceks -storetype jceks -storepass secret -keyalg HMacSHA384 -keysize 2048 -alias HS384 -keypass secret +keytool -genseckey -keystore keystore.jceks -storetype jceks -storepass secret -keyalg HMacSHA512 -keysize 2048 -alias HS512 -keypass secret +keytool -genkey -keystore keystore.jceks -storetype jceks -storepass secret -keyalg RSA -keysize 2048 -alias RS256 -keypass secret -sigalg SHA256withRSA -dname "CN=,OU=,O=,L=,ST=,C=" -validity 360 +keytool -genkey -keystore keystore.jceks -storetype jceks -storepass secret -keyalg RSA -keysize 2048 -alias RS384 -keypass secret -sigalg SHA384withRSA -dname "CN=,OU=,O=,L=,ST=,C=" -validity 360 +keytool -genkey -keystore keystore.jceks -storetype jceks -storepass secret -keyalg RSA -keysize 2048 -alias RS512 -keypass secret -sigalg SHA512withRSA -dname "CN=,OU=,O=,L=,ST=,C=" -validity 360 +keytool -genkeypair -keystore keystore.jceks -storetype jceks -storepass secret -keyalg EC -keysize 256 -alias ES256 -keypass secret -sigalg SHA256withECDSA -dname "CN=,OU=,O=,L=,ST=,C=" -validity 360 +keytool -genkeypair -keystore keystore.jceks -storetype jceks -storepass secret -keyalg EC -keysize 256 -alias ES384 -keypass secret -sigalg SHA384withECDSA -dname "CN=,OU=,O=,L=,ST=,C=" -validity 360 +keytool -genkeypair -keystore keystore.jceks -storetype jceks -storepass secret -keyalg EC -keysize 256 -alias ES512 -keypass secret -sigalg SHA512withECDSA -dname "CN=,OU=,O=,L=,ST=,C=" -validity 360 +---- + +=== Read only tokens + +If you need to consume JWT tokens issues by third parties you probably won't have the private key with you, in that +case all you need to have is a public key im PEM format. + +[source,kotlin] +---- + +var config = json { + obj("public-key" to "BASE64-ENCODED-PUBLIC_KEY") +} +var provider = JWTAuth.create(vertx, config) + +---- +Julien VietTim FoxPaulo Lopes \ No newline at end of file diff --git a/vertx-auth-jwt/src/main/asciidoc/ruby/index.adoc b/vertx-auth-jwt/src/main/asciidoc/ruby/index.adoc index c612e1522..69adc5ebd 100644 --- a/vertx-auth-jwt/src/main/asciidoc/ruby/index.adoc +++ b/vertx-auth-jwt/src/main/asciidoc/ruby/index.adoc @@ -12,7 +12,7 @@ dependency to the _dependencies_ section of your build descriptor: io.vertx vertx-auth-jwt - 3.4.0.Beta1 + 3.4.0-SNAPSHOT ---- @@ -20,7 +20,7 @@ dependency to the _dependencies_ section of your build descriptor: [source,groovy,subs="+attributes"] ---- -compile 'io.vertx:vertx-auth-jwt:3.4.0.Beta1' +compile 'io.vertx:vertx-auth-jwt:3.4.0-SNAPSHOT' ---- JSON Web Token is a simple way to send information in the clear (usually in a URL) whose contents can be diff --git a/vertx-auth-jwt/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule b/vertx-auth-jwt/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule deleted file mode 100644 index 17edd362d..000000000 --- a/vertx-auth-jwt/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule +++ /dev/null @@ -1,4 +0,0 @@ -moduleName = io.vertx.ext.auth.jwt.JWTAuth-module -moduleVersion = 1.0 -extensionClasses = io.vertx.groovy.ext.auth.jwt.JWTAuth_GroovyExtension -staticExtensionClasses = io.vertx.groovy.ext.auth.jwt.JWTAuth_GroovyStaticExtension diff --git a/vertx-auth-jwt/src/main/resources/vertx-auth-jwt-js/jwt_auth.js b/vertx-auth-jwt/src/main/resources/vertx-auth-jwt-js/jwt_auth.js deleted file mode 100644 index a861cdaf7..000000000 --- a/vertx-auth-jwt/src/main/resources/vertx-auth-jwt-js/jwt_auth.js +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright 2014 Red Hat, Inc. - * - * Red Hat 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. - */ - -/** @module vertx-auth-jwt-js/jwt_auth */ -var utils = require('vertx-js/util/utils'); -var User = require('vertx-auth-common-js/user'); -var Vertx = require('vertx-js/vertx'); -var AuthProvider = require('vertx-auth-common-js/auth_provider'); - -var io = Packages.io; -var JsonObject = io.vertx.core.json.JsonObject; -var JJWTAuth = Java.type('io.vertx.ext.auth.jwt.JWTAuth'); -var JWTOptions = Java.type('io.vertx.ext.auth.jwt.JWTOptions'); - -/** - - @class -*/ -var JWTAuth = function(j_val) { - - var j_jWTAuth = j_val; - var that = this; - AuthProvider.call(this, j_val); - - /** - - @public - @param arg0 {Object} - @param arg1 {function} - */ - this.authenticate = function(arg0, arg1) { - var __args = arguments; - if (__args.length === 2 && (typeof __args[0] === 'object' && __args[0] != null) && typeof __args[1] === 'function') { - j_jWTAuth["authenticate(io.vertx.core.json.JsonObject,io.vertx.core.Handler)"](utils.convParamJsonObject(arg0), function(ar) { - if (ar.succeeded()) { - arg1(utils.convReturnVertxGen(User, ar.result()), null); - } else { - arg1(null, ar.cause()); - } - }); - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - Generate a new JWT token. - - @public - @param claims {Object} Json with user defined claims for a list of official claims - @param options {Object} extra options for the generation - @return {string} JWT encoded token - */ - this.generateToken = function(claims, options) { - var __args = arguments; - if (__args.length === 2 && (typeof __args[0] === 'object' && __args[0] != null) && (typeof __args[1] === 'object' && __args[1] != null)) { - return j_jWTAuth["generateToken(io.vertx.core.json.JsonObject,io.vertx.ext.auth.jwt.JWTOptions)"](utils.convParamJsonObject(claims), options != null ? new JWTOptions(new JsonObject(Java.asJSONCompatible(options))) : null); - } else throw new TypeError('function invoked with invalid arguments'); - }; - - // A reference to the underlying Java delegate - // NOTE! This is an internal API and must not be used in user code. - // If you rely on this property your code is likely to break if we change it / remove it without warning. - this._jdel = j_jWTAuth; -}; - -JWTAuth._jclass = utils.getJavaClass("io.vertx.ext.auth.jwt.JWTAuth"); -JWTAuth._jtype = { - accept: function(obj) { - return JWTAuth._jclass.isInstance(obj._jdel); - }, - wrap: function(jdel) { - var obj = Object.create(JWTAuth.prototype, {}); - JWTAuth.apply(obj, arguments); - return obj; - }, - unwrap: function(obj) { - return obj._jdel; - } -}; -JWTAuth._create = function(jdel) { - var obj = Object.create(JWTAuth.prototype, {}); - JWTAuth.apply(obj, arguments); - return obj; -} -/** - Create a JWT auth provider - - @memberof module:vertx-auth-jwt-js/jwt_auth - @param vertx {Vertx} the Vertx instance - @param config {Object} the config - @return {JWTAuth} the auth provider - */ -JWTAuth.create = function(vertx, config) { - var __args = arguments; - if (__args.length === 2 && typeof __args[0] === 'object' && __args[0]._jdel && (typeof __args[1] === 'object' && __args[1] != null)) { - return utils.convReturnVertxGen(JWTAuth, JJWTAuth["create(io.vertx.core.Vertx,io.vertx.core.json.JsonObject)"](vertx._jdel, utils.convParamJsonObject(config))); - } else throw new TypeError('function invoked with invalid arguments'); -}; - -module.exports = JWTAuth; \ No newline at end of file diff --git a/vertx-auth-jwt/src/main/resources/vertx-auth-jwt/jwt_auth.rb b/vertx-auth-jwt/src/main/resources/vertx-auth-jwt/jwt_auth.rb deleted file mode 100644 index 4c23da258..000000000 --- a/vertx-auth-jwt/src/main/resources/vertx-auth-jwt/jwt_auth.rb +++ /dev/null @@ -1,66 +0,0 @@ -require 'vertx-auth-common/user' -require 'vertx/vertx' -require 'vertx-auth-common/auth_provider' -require 'vertx/util/utils.rb' -# Generated from io.vertx.ext.auth.jwt.JWTAuth -module VertxAuthJwt - # Factory interface for creating JWT based {::VertxAuthCommon::AuthProvider} instances. - class JWTAuth < ::VertxAuthCommon::AuthProvider - # @private - # @param j_del [::VertxAuthJwt::JWTAuth] the java delegate - def initialize(j_del) - super(j_del) - @j_del = j_del - end - # @private - # @return [::VertxAuthJwt::JWTAuth] the underlying java delegate - def j_del - @j_del - end - @@j_api_type = Object.new - def @@j_api_type.accept?(obj) - obj.class == JWTAuth - end - def @@j_api_type.wrap(obj) - JWTAuth.new(obj) - end - def @@j_api_type.unwrap(obj) - obj.j_del - end - def self.j_api_type - @@j_api_type - end - def self.j_class - Java::IoVertxExtAuthJwt::JWTAuth.java_class - end - # @param [Hash{String => Object}] arg0 - # @yield - # @return [void] - def authenticate(arg0=nil) - if arg0.class == Hash && block_given? - return @j_del.java_method(:authenticate, [Java::IoVertxCoreJson::JsonObject.java_class,Java::IoVertxCore::Handler.java_class]).call(::Vertx::Util::Utils.to_json_object(arg0),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxAuthCommon::User) : nil) })) - end - raise ArgumentError, "Invalid arguments when calling authenticate(#{arg0})" - end - # Create a JWT auth provider - # @param [::Vertx::Vertx] vertx the Vertx instance - # @param [Hash{String => Object}] config the config - # @return [::VertxAuthJwt::JWTAuth] the auth provider - def self.create(vertx=nil,config=nil) - if vertx.class.method_defined?(:j_del) && config.class == Hash && !block_given? - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthJwt::JWTAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxCoreJson::JsonObject.java_class]).call(vertx.j_del,::Vertx::Util::Utils.to_json_object(config)),::VertxAuthJwt::JWTAuth) - end - raise ArgumentError, "Invalid arguments when calling create(#{vertx},#{config})" - end - # Generate a new JWT token. - # @param [Hash{String => Object}] claims Json with user defined claims for a list of official claims - # @param [Hash] options extra options for the generation - # @return [String] JWT encoded token - def generate_token(claims=nil,options=nil) - if claims.class == Hash && options.class == Hash && !block_given? - return @j_del.java_method(:generateToken, [Java::IoVertxCoreJson::JsonObject.java_class,Java::IoVertxExtAuthJwt::JWTOptions.java_class]).call(::Vertx::Util::Utils.to_json_object(claims),Java::IoVertxExtAuthJwt::JWTOptions.new(::Vertx::Util::Utils.to_json_object(options))) - end - raise ArgumentError, "Invalid arguments when calling generate_token(#{claims},#{options})" - end - end -end diff --git a/vertx-auth-mongo/src/main/asciidoc/groovy/index.adoc b/vertx-auth-mongo/src/main/asciidoc/groovy/index.adoc index cbeb369f1..f1c833268 100644 --- a/vertx-auth-mongo/src/main/asciidoc/groovy/index.adoc +++ b/vertx-auth-mongo/src/main/asciidoc/groovy/index.adoc @@ -13,7 +13,7 @@ dependency to the _dependencies_ section of your build descriptor: io.vertx vertx-auth-mongo - 3.4.0.Beta1 + 3.4.0-SNAPSHOT ---- @@ -21,7 +21,7 @@ dependency to the _dependencies_ section of your build descriptor: [source,groovy,subs="+attributes"] ---- -compile 'io.vertx:vertx-auth-mongo:3.4.0.Beta1' +compile 'io.vertx:vertx-auth-mongo:3.4.0-SNAPSHOT' ---- To create an instance you first need an instance of `link:../../apidocs/io/vertx/ext/mongo/MongoClient.html[MongoClient]`. To learn how to create one @@ -31,8 +31,6 @@ Once you've got one of those you can create a `link:../../apidocs/io/vertx/ext/a [source,groovy] ---- -import io.vertx.ext.mongo.MongoClient -import io.vertx.ext.auth.mongo.MongoAuth def client = MongoClient.createShared(vertx, mongoClientConfig) def authProperties = [:] def authProvider = MongoAuth.create(client, authProperties) @@ -135,7 +133,6 @@ If validating that a user has a particular _role_ then you should prefix the arg [source,groovy] ---- -import io.vertx.ext.auth.mongo.MongoAuth user.isAuthorised("${MongoAuth.ROLE_PREFIX}manager", { res -> if (res.succeeded()) { diff --git a/vertx-auth-mongo/src/main/asciidoc/java/index.adoc b/vertx-auth-mongo/src/main/asciidoc/java/index.adoc index 72678f322..3869834ea 100644 --- a/vertx-auth-mongo/src/main/asciidoc/java/index.adoc +++ b/vertx-auth-mongo/src/main/asciidoc/java/index.adoc @@ -13,7 +13,7 @@ dependency to the _dependencies_ section of your build descriptor: io.vertx vertx-auth-mongo - 3.4.0.Beta1 + 3.4.0-SNAPSHOT ---- @@ -21,7 +21,7 @@ dependency to the _dependencies_ section of your build descriptor: [source,groovy,subs="+attributes"] ---- -compile 'io.vertx:vertx-auth-mongo:3.4.0.Beta1' +compile 'io.vertx:vertx-auth-mongo:3.4.0-SNAPSHOT' ---- To create an instance you first need an instance of `link:../../apidocs/io/vertx/ext/mongo/MongoClient.html[MongoClient]`. To learn how to create one diff --git a/vertx-auth-mongo/src/main/asciidoc/js/index.adoc b/vertx-auth-mongo/src/main/asciidoc/js/index.adoc index 829d61cff..4215320bc 100644 --- a/vertx-auth-mongo/src/main/asciidoc/js/index.adoc +++ b/vertx-auth-mongo/src/main/asciidoc/js/index.adoc @@ -13,7 +13,7 @@ dependency to the _dependencies_ section of your build descriptor: io.vertx vertx-auth-mongo - 3.4.0.Beta1 + 3.4.0-SNAPSHOT ---- @@ -21,7 +21,7 @@ dependency to the _dependencies_ section of your build descriptor: [source,groovy,subs="+attributes"] ---- -compile 'io.vertx:vertx-auth-mongo:3.4.0.Beta1' +compile 'io.vertx:vertx-auth-mongo:3.4.0-SNAPSHOT' ---- To create an instance you first need an instance of `link:../../jsdoc/module-vertx-mongo-js_mongo_client-MongoClient.html[MongoClient]`. To learn how to create one diff --git a/vertx-auth-mongo/src/main/asciidoc/kotlin/index.adoc b/vertx-auth-mongo/src/main/asciidoc/kotlin/index.adoc new file mode 100644 index 000000000..c2fbbf84b --- /dev/null +++ b/vertx-auth-mongo/src/main/asciidoc/kotlin/index.adoc @@ -0,0 +1,150 @@ +== Mongo Auth Provider implementation + +We provide an implementation of `link:../../apidocs/io/vertx/ext/auth/AuthProvider.html[AuthProvider]` which uses the Vert.x `link:../../apidocs/io/vertx/ext/mongo/MongoClient.html[MongoClient]` +to perform authentication and authorisation against a MongoDb. + +To use this project, add the following +dependency to the _dependencies_ section of your build descriptor: + +* Maven (in your `pom.xml`): + +[source,xml,subs="+attributes"] +---- + + io.vertx + vertx-auth-mongo + 3.4.0-SNAPSHOT + +---- + +* Gradle (in your `build.gradle` file): + +[source,groovy,subs="+attributes"] +---- +compile 'io.vertx:vertx-auth-mongo:3.4.0-SNAPSHOT' +---- + +To create an instance you first need an instance of `link:../../apidocs/io/vertx/ext/mongo/MongoClient.html[MongoClient]`. To learn how to create one +of those please consult the documentation for the MongoClient. + +Once you've got one of those you can create a `link:../../apidocs/io/vertx/ext/auth/mongo/MongoAuth.html[MongoAuth]` instance as follows: + +[source,kotlin] +---- +var client = MongoClient.createShared(vertx, mongoClientConfig) +var authProperties = json { + obj() +} +var authProvider = MongoAuth.create(client, authProperties) + +---- + +Once you've got your instance you can authenticate and authorise with it just like any `link:../../apidocs/io/vertx/ext/auth/AuthProvider.html[AuthProvider]`. + +The out of the box config assumes the usage of the collection with name "user", the username stored and read by field "username" +some others. + +In order to avoid duplicates of user names your "user" collection should have a unique index on "username". In order +to do this you should run the following snippet on your mongo server: + +---- +db.user.createIndex( { username: 1 }, { unique: true } ) +---- + +The reason you should add the index is that due to the nature of mongo doing a query first to verify if a username is +already taken and then insert a document cannot be run as an atomic action. Using the index the code will try to +insert the row and fail if duplicate. + +You can also change all the defaults for the mongo collection and column names using any of the methods: + +`link:../../apidocs/io/vertx/ext/auth/mongo/MongoAuth.html#setCollectionName-java.lang.String-[setCollectionName]` +`link:../../apidocs/io/vertx/ext/auth/mongo/MongoAuth.html#setUsernameField-java.lang.String-[setUsernameField]` +`link:../../apidocs/io/vertx/ext/auth/mongo/MongoAuth.html#setPasswordField-java.lang.String-[setPasswordField]` +`link:../../apidocs/io/vertx/ext/auth/mongo/MongoAuth.html#setPermissionField-java.lang.String-[setPermissionField]` +`link:../../apidocs/io/vertx/ext/auth/mongo/MongoAuth.html#setRoleField-java.lang.String-[setRoleField]` +if you want to adapt that to your needs. + +The default implementation assumes that the password is stored in the database as a SHA-512 hash after being +concatenated with a salt. It also assumes the salt is stored in the table too. The field, where the salt is +stored can be set by `link:../../apidocs/io/vertx/ext/auth/mongo/MongoAuth.html#setSaltField-java.lang.String-[setSaltField]`, the default is "salt". +You are able to change this behaviour by using `link:../../apidocs/io/vertx/ext/auth/mongo/HashStrategy.html#setSaltStyle-io.vertx.ext.auth.mongo.HashSaltStyle-[setSaltStyle]`. +The HashStrategy you can retrieve by `link:../../apidocs/io/vertx/ext/auth/mongo/MongoAuth.html#getHashStrategy--[getHashStrategy]`. +By using this, you are able to set: +`link:../../apidocs/io/vertx/ext/auth/mongo/HashSaltStyle.html#NO_SALT[NO_SALT]` by which passwords are not crypted and stored +in cleartext. ( see the warning below! ) +`link:../../apidocs/io/vertx/ext/auth/mongo/HashSaltStyle.html#COLUMN[COLUMN]`, which will create a salt per user and store this +inside the defined column of the user. ( see the warning below! ) +`link:../../apidocs/io/vertx/ext/auth/mongo/HashSaltStyle.html#EXTERNAL[EXTERNAL]`, which will store only the crypted password in the +database and will use a salt from external, which you will have to set by `link:../../apidocs/io/vertx/ext/auth/mongo/HashStrategy.html#setExternalSalt-java.lang.String-[setExternalSalt]` + +If you want to override this behaviour you can do so by providing an alternative hash strategy and setting it with + `link:../../apidocs/io/vertx/ext/auth/mongo/MongoAuth.html#setHashStrategy-io.vertx.ext.auth.mongo.HashStrategy-[setHashStrategy]` + +WARNING: It is strongly advised to use the `link:../../apidocs/io/vertx/ext/auth/mongo/HashSaltStyle.html#EXTERNAL[EXTERNAL]` option. +The NO_SALT option is existing for development phase only and even the COLUMN option is not recommended, cause +salt and password are stored inside the same place! + +== Authentication + +When authenticating using this implementation, it assumes `username` and `password` fields are present in the +authentication info: + +[source,kotlin] +---- +var authInfo = json { + obj( + "username" to "tim", + "password" to "sausages" + ) +} +authProvider.authenticate(authInfo, { res -> + if (res.succeeded()) { + var user = res.result() + } else { + // Failed! + } +}) + +---- +Instead of the `username` and `password` field names used in the previous snippet, you should use: +`link:../../apidocs/io/vertx/ext/auth/mongo/MongoAuth.html#setUsernameCredentialField-java.lang.String-[setUsernameCredentialField]` and +`link:../../apidocs/io/vertx/ext/auth/mongo/MongoAuth.html#setPasswordCredentialField-java.lang.String-[setPasswordCredentialField]` + +== Authorisation - Permission-Role Model + +Although Vert.x auth itself does not mandate any specific model of permissions (they are just opaque strings), this +implementation assumes a familiar user/role/permission model, where a user can have zero or more roles and a role +can have zero or more permissions. + +If validating if a user has a particular permission simply pass the permission into. +`link:../../apidocs/io/vertx/ext/auth/User.html#isAuthorised-java.lang.String-io.vertx.core.Handler-[isAuthorised]` as follows: + +[source,kotlin] +---- + +user.isAuthorised("commit_code", { res -> + if (res.succeeded()) { + var hasPermission = res.result() + } else { + // Failed to + } +}) + + +---- + +If validating that a user has a particular _role_ then you should prefix the argument with the role prefix. + +[source,kotlin] +---- + +user.isAuthorised("${MongoAuth.ROLE_PREFIX}manager", { res -> + if (res.succeeded()) { + var hasRole = res.result() + } else { + // Failed to + } +}) + + +---- \ No newline at end of file diff --git a/vertx-auth-mongo/src/main/asciidoc/ruby/index.adoc b/vertx-auth-mongo/src/main/asciidoc/ruby/index.adoc index b0a77aa1a..2becbcd61 100644 --- a/vertx-auth-mongo/src/main/asciidoc/ruby/index.adoc +++ b/vertx-auth-mongo/src/main/asciidoc/ruby/index.adoc @@ -13,7 +13,7 @@ dependency to the _dependencies_ section of your build descriptor: io.vertx vertx-auth-mongo - 3.4.0.Beta1 + 3.4.0-SNAPSHOT ---- @@ -21,7 +21,7 @@ dependency to the _dependencies_ section of your build descriptor: [source,groovy,subs="+attributes"] ---- -compile 'io.vertx:vertx-auth-mongo:3.4.0.Beta1' +compile 'io.vertx:vertx-auth-mongo:3.4.0-SNAPSHOT' ---- To create an instance you first need an instance of `link:../../yardoc/VertxMongo/MongoClient.html[MongoClient]`. To learn how to create one diff --git a/vertx-auth-mongo/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule b/vertx-auth-mongo/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule deleted file mode 100644 index 60c793b01..000000000 --- a/vertx-auth-mongo/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule +++ /dev/null @@ -1,4 +0,0 @@ -moduleName = io.vertx.ext.auth.mongo.MongoAuth-module -moduleVersion = 1.0 -extensionClasses = -staticExtensionClasses = io.vertx.groovy.ext.auth.mongo.MongoAuth_GroovyStaticExtension diff --git a/vertx-auth-mongo/src/main/resources/vertx-auth-mongo-js/hash_strategy.js b/vertx-auth-mongo/src/main/resources/vertx-auth-mongo-js/hash_strategy.js deleted file mode 100644 index 600cf6e26..000000000 --- a/vertx-auth-mongo/src/main/resources/vertx-auth-mongo-js/hash_strategy.js +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright 2014 Red Hat, Inc. - * - * Red Hat 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. - */ - -/** @module vertx-auth-mongo-js/hash_strategy */ -var utils = require('vertx-js/util/utils'); -var User = require('vertx-auth-common-js/user'); - -var io = Packages.io; -var JsonObject = io.vertx.core.json.JsonObject; -var JHashStrategy = Java.type('io.vertx.ext.auth.mongo.HashStrategy'); - -/** - Determines how the hashing is computed in the implementation You can implement this to provide a different hashing - strategy to the default. - - @class -*/ -var HashStrategy = function(j_val) { - - var j_hashStrategy = j_val; - var that = this; - - /** - Compute the hashed password given the unhashed password and the user - - @public - @param password {string} the unhashed password - @param user {User} the user to get the salt for. This paramter is needed, if the is declared to be used - @return {string} the hashed password - */ - this.computeHash = function(password, user) { - var __args = arguments; - if (__args.length === 2 && typeof __args[0] === 'string' && typeof __args[1] === 'object' && __args[1]._jdel) { - return j_hashStrategy["computeHash(java.lang.String,io.vertx.ext.auth.User)"](password, user._jdel); - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - Retrieve the password from the user, or as clear text or as hashed version, depending on the definition - - @public - @param user {User} the user to get the stored password for - @return {string} the password, either as hashed version or as cleartext, depending on the preferences - */ - this.getStoredPwd = function(user) { - var __args = arguments; - if (__args.length === 1 && typeof __args[0] === 'object' && __args[0]._jdel) { - return j_hashStrategy["getStoredPwd(io.vertx.ext.auth.User)"](user._jdel); - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - Retrieve the salt. The source of the salt can be the external salt or the propriate column of the given user, - depending on the defined HashSaltStyle - - @public - @param user {User} the user to get the salt for. This paramter is needed, if the is declared to be used - @return {string} null in case of the salt of the user or a defined external salt - */ - this.getSalt = function(user) { - var __args = arguments; - if (__args.length === 1 && typeof __args[0] === 'object' && __args[0]._jdel) { - return j_hashStrategy["getSalt(io.vertx.ext.auth.User)"](user._jdel); - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - Set an external salt. This method should be used in case of - - @public - @param salt {string} the salt, which shall be used - */ - this.setExternalSalt = function(salt) { - var __args = arguments; - if (__args.length === 1 && typeof __args[0] === 'string') { - j_hashStrategy["setExternalSalt(java.lang.String)"](salt); - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - Set the saltstyle as defined by HashSaltStyle. - - @public - @param saltStyle {Object} the HashSaltStyle to be used - */ - this.setSaltStyle = function(saltStyle) { - var __args = arguments; - if (__args.length === 1 && typeof __args[0] === 'string') { - j_hashStrategy["setSaltStyle(io.vertx.ext.auth.mongo.HashSaltStyle)"](io.vertx.ext.auth.mongo.HashSaltStyle.valueOf(saltStyle)); - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - Get the defined HashSaltStyle of the current instance - - @public - - @return {Object} the saltStyle - */ - this.getSaltStyle = function() { - var __args = arguments; - if (__args.length === 0) { - return utils.convReturnEnum(j_hashStrategy["getSaltStyle()"]()); - } else throw new TypeError('function invoked with invalid arguments'); - }; - - // A reference to the underlying Java delegate - // NOTE! This is an internal API and must not be used in user code. - // If you rely on this property your code is likely to break if we change it / remove it without warning. - this._jdel = j_hashStrategy; -}; - -HashStrategy._jclass = utils.getJavaClass("io.vertx.ext.auth.mongo.HashStrategy"); -HashStrategy._jtype = { - accept: function(obj) { - return HashStrategy._jclass.isInstance(obj._jdel); - }, - wrap: function(jdel) { - var obj = Object.create(HashStrategy.prototype, {}); - HashStrategy.apply(obj, arguments); - return obj; - }, - unwrap: function(obj) { - return obj._jdel; - } -}; -HashStrategy._create = function(jdel) { - var obj = Object.create(HashStrategy.prototype, {}); - HashStrategy.apply(obj, arguments); - return obj; -} -module.exports = HashStrategy; \ No newline at end of file diff --git a/vertx-auth-mongo/src/main/resources/vertx-auth-mongo-js/mongo_auth.js b/vertx-auth-mongo/src/main/resources/vertx-auth-mongo-js/mongo_auth.js deleted file mode 100644 index c326028db..000000000 --- a/vertx-auth-mongo/src/main/resources/vertx-auth-mongo-js/mongo_auth.js +++ /dev/null @@ -1,397 +0,0 @@ -/* - * Copyright 2014 Red Hat, Inc. - * - * Red Hat 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. - */ - -/** @module vertx-auth-mongo-js/mongo_auth */ -var utils = require('vertx-js/util/utils'); -var User = require('vertx-auth-common-js/user'); -var MongoClient = require('vertx-mongo-js/mongo_client'); -var HashStrategy = require('vertx-auth-mongo-js/hash_strategy'); -var AuthProvider = require('vertx-auth-common-js/auth_provider'); - -var io = Packages.io; -var JsonObject = io.vertx.core.json.JsonObject; -var JMongoAuth = Java.type('io.vertx.ext.auth.mongo.MongoAuth'); - -/** - - @class -*/ -var MongoAuth = function(j_val) { - - var j_mongoAuth = j_val; - var that = this; - AuthProvider.call(this, j_val); - - /** - - @public - @param arg0 {Object} - @param arg1 {function} - */ - this.authenticate = function(arg0, arg1) { - var __args = arguments; - if (__args.length === 2 && (typeof __args[0] === 'object' && __args[0] != null) && typeof __args[1] === 'function') { - j_mongoAuth["authenticate(io.vertx.core.json.JsonObject,io.vertx.core.Handler)"](utils.convParamJsonObject(arg0), function(ar) { - if (ar.succeeded()) { - arg1(utils.convReturnVertxGen(User, ar.result()), null); - } else { - arg1(null, ar.cause()); - } - }); - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - Set the name of the collection to be used. Defaults to DEFAULT_COLLECTION_NAME - - @public - @param collectionName {string} the name of the collection to be used for storing and reading user data - @return {MongoAuth} the current instance itself for fluent calls - */ - this.setCollectionName = function(collectionName) { - var __args = arguments; - if (__args.length === 1 && typeof __args[0] === 'string') { - j_mongoAuth["setCollectionName(java.lang.String)"](collectionName); - return that; - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - Set the name of the field to be used for the username. Defaults to DEFAULT_USERNAME_FIELD - - @public - @param fieldName {string} the name of the field to be used - @return {MongoAuth} the current instance itself for fluent calls - */ - this.setUsernameField = function(fieldName) { - var __args = arguments; - if (__args.length === 1 && typeof __args[0] === 'string') { - j_mongoAuth["setUsernameField(java.lang.String)"](fieldName); - return that; - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - Set the name of the field to be used for the password Defaults to DEFAULT_PASSWORD_FIELD - - @public - @param fieldName {string} the name of the field to be used - @return {MongoAuth} the current instance itself for fluent calls - */ - this.setPasswordField = function(fieldName) { - var __args = arguments; - if (__args.length === 1 && typeof __args[0] === 'string') { - j_mongoAuth["setPasswordField(java.lang.String)"](fieldName); - return that; - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - Set the name of the field to be used for the roles. Defaults to DEFAULT_ROLE_FIELD. Roles are expected to - be saved as JsonArray - - @public - @param fieldName {string} the name of the field to be used - @return {MongoAuth} the current instance itself for fluent calls - */ - this.setRoleField = function(fieldName) { - var __args = arguments; - if (__args.length === 1 && typeof __args[0] === 'string') { - j_mongoAuth["setRoleField(java.lang.String)"](fieldName); - return that; - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - Set the name of the field to be used for the permissions. Defaults to DEFAULT_PERMISSION_FIELD. - Permissions are expected to be saved as JsonArray - - @public - @param fieldName {string} the name of the field to be used - @return {MongoAuth} the current instance itself for fluent calls - */ - this.setPermissionField = function(fieldName) { - var __args = arguments; - if (__args.length === 1 && typeof __args[0] === 'string') { - j_mongoAuth["setPermissionField(java.lang.String)"](fieldName); - return that; - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - Set the name of the field to be used as property for the username in the method - {@link AuthProvider#authenticate}. Defaults to DEFAULT_CREDENTIAL_USERNAME_FIELD - - @public - @param fieldName {string} the name of the field to be used - @return {MongoAuth} the current instance itself for fluent calls - */ - this.setUsernameCredentialField = function(fieldName) { - var __args = arguments; - if (__args.length === 1 && typeof __args[0] === 'string') { - j_mongoAuth["setUsernameCredentialField(java.lang.String)"](fieldName); - return that; - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - Set the name of the field to be used as property for the password of credentials in the method - {@link AuthProvider#authenticate}. Defaults to DEFAULT_CREDENTIAL_PASSWORD_FIELD - - @public - @param fieldName {string} the name of the field to be used - @return {MongoAuth} the current instance itself for fluent calls - */ - this.setPasswordCredentialField = function(fieldName) { - var __args = arguments; - if (__args.length === 1 && typeof __args[0] === 'string') { - j_mongoAuth["setPasswordCredentialField(java.lang.String)"](fieldName); - return that; - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - Set the name of the field to be used for the salt. Only used when {@link HashStrategy#setSaltStyle} is - set to - - @public - @param fieldName {string} the name of the field to be used - @return {MongoAuth} the current instance itself for fluent calls - */ - this.setSaltField = function(fieldName) { - var __args = arguments; - if (__args.length === 1 && typeof __args[0] === 'string') { - j_mongoAuth["setSaltField(java.lang.String)"](fieldName); - return that; - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - The name of the collection used to store User objects inside. Defaults to DEFAULT_COLLECTION_NAME - - @public - - @return {string} the collectionName - */ - this.getCollectionName = function() { - var __args = arguments; - if (__args.length === 0) { - return j_mongoAuth["getCollectionName()"](); - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - Get the name of the field to be used for the username. Defaults to DEFAULT_USERNAME_FIELD - - @public - - @return {string} the usernameField - */ - this.getUsernameField = function() { - var __args = arguments; - if (__args.length === 0) { - return j_mongoAuth["getUsernameField()"](); - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - Get the name of the field to be used for the password Defaults to DEFAULT_PASSWORD_FIELD - - @public - - @return {string} the passwordField - */ - this.getPasswordField = function() { - var __args = arguments; - if (__args.length === 0) { - return j_mongoAuth["getPasswordField()"](); - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - Get the name of the field to be used for the roles. Defaults to DEFAULT_ROLE_FIELD. Roles are expected to - be saved as JsonArray - - @public - - @return {string} the roleField - */ - this.getRoleField = function() { - var __args = arguments; - if (__args.length === 0) { - return j_mongoAuth["getRoleField()"](); - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - Get the name of the field to be used for the permissions. Defaults to DEFAULT_PERMISSION_FIELD. - Permissions are expected to be saved as JsonArray - - @public - - @return {string} the permissionField - */ - this.getPermissionField = function() { - var __args = arguments; - if (__args.length === 0) { - return j_mongoAuth["getPermissionField()"](); - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - Get the name of the field to be used as property for the username in the method - {@link AuthProvider#authenticate}. Defaults to DEFAULT_CREDENTIAL_USERNAME_FIELD - - @public - - @return {string} the usernameCredentialField - */ - this.getUsernameCredentialField = function() { - var __args = arguments; - if (__args.length === 0) { - return j_mongoAuth["getUsernameCredentialField()"](); - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - Get the name of the field to be used as property for the password of credentials in the method - {@link AuthProvider#authenticate}. Defaults to DEFAULT_CREDENTIAL_PASSWORD_FIELD - - @public - - @return {string} the passwordCredentialField - */ - this.getPasswordCredentialField = function() { - var __args = arguments; - if (__args.length === 0) { - return j_mongoAuth["getPasswordCredentialField()"](); - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - Get the name of the field to be used for the salt. Only used when {@link HashStrategy#setSaltStyle} is - set to - - @public - - @return {string} the saltField - */ - this.getSaltField = function() { - var __args = arguments; - if (__args.length === 0) { - return j_mongoAuth["getSaltField()"](); - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - The HashStrategy which is used by the current instance - - @public - @param hashStrategy {HashStrategy} the {@link HashStrategy} to be set - @return {MongoAuth} the current instance itself for fluent calls - */ - this.setHashStrategy = function(hashStrategy) { - var __args = arguments; - if (__args.length === 1 && typeof __args[0] === 'object' && __args[0]._jdel) { - j_mongoAuth["setHashStrategy(io.vertx.ext.auth.mongo.HashStrategy)"](hashStrategy._jdel); - return that; - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - The HashStrategy which is used by the current instance - - @public - - @return {HashStrategy} the defined instance of {@link HashStrategy} - */ - this.getHashStrategy = function() { - var __args = arguments; - if (__args.length === 0) { - return utils.convReturnVertxGen(HashStrategy, j_mongoAuth["getHashStrategy()"]()); - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - Insert a new user into mongo in the convenient way - - @public - @param username {string} the username to be set - @param password {string} the passsword in clear text, will be adapted following the definitions of the defined {@link HashStrategy} - @param roles {Array.} a list of roles to be set - @param permissions {Array.} a list of permissions to be set - @param resultHandler {function} the ResultHandler will be provided with the id of the generated record - */ - this.insertUser = function(username, password, roles, permissions, resultHandler) { - var __args = arguments; - if (__args.length === 5 && typeof __args[0] === 'string' && typeof __args[1] === 'string' && typeof __args[2] === 'object' && __args[2] instanceof Array && typeof __args[3] === 'object' && __args[3] instanceof Array && typeof __args[4] === 'function') { - j_mongoAuth["insertUser(java.lang.String,java.lang.String,java.util.List,java.util.List,io.vertx.core.Handler)"](username, password, utils.convParamListBasicOther(roles), utils.convParamListBasicOther(permissions), function(ar) { - if (ar.succeeded()) { - resultHandler(ar.result(), null); - } else { - resultHandler(null, ar.cause()); - } - }); - } else throw new TypeError('function invoked with invalid arguments'); - }; - - // A reference to the underlying Java delegate - // NOTE! This is an internal API and must not be used in user code. - // If you rely on this property your code is likely to break if we change it / remove it without warning. - this._jdel = j_mongoAuth; -}; - -MongoAuth._jclass = utils.getJavaClass("io.vertx.ext.auth.mongo.MongoAuth"); -MongoAuth._jtype = { - accept: function(obj) { - return MongoAuth._jclass.isInstance(obj._jdel); - }, - wrap: function(jdel) { - var obj = Object.create(MongoAuth.prototype, {}); - MongoAuth.apply(obj, arguments); - return obj; - }, - unwrap: function(obj) { - return obj._jdel; - } -}; -MongoAuth._create = function(jdel) { - var obj = Object.create(MongoAuth.prototype, {}); - MongoAuth.apply(obj, arguments); - return obj; -} -/** - Creates an instance of MongoAuth by using the given and configuration object. An example for a - configuration object: - -
- JsonObject js = new JsonObject();
- js.put(MongoAuth.PROPERTY_COLLECTION_NAME, createCollectionName(MongoAuth.DEFAULT_COLLECTION_NAME));
- 
- - @memberof module:vertx-auth-mongo-js/mongo_auth - @param mongoClient {MongoClient} an instance of to be used for data storage and retrival - @param config {Object} the configuration object for the current instance. By this - @return {MongoAuth} the created instance of {@link MongoAuth}s - */ -MongoAuth.create = function(mongoClient, config) { - var __args = arguments; - if (__args.length === 2 && typeof __args[0] === 'object' && __args[0]._jdel && (typeof __args[1] === 'object' && __args[1] != null)) { - return utils.convReturnVertxGen(MongoAuth, JMongoAuth["create(io.vertx.ext.mongo.MongoClient,io.vertx.core.json.JsonObject)"](mongoClient._jdel, utils.convParamJsonObject(config))); - } else throw new TypeError('function invoked with invalid arguments'); -}; - -module.exports = MongoAuth; \ No newline at end of file diff --git a/vertx-auth-mongo/src/main/resources/vertx-auth-mongo/hash_strategy.rb b/vertx-auth-mongo/src/main/resources/vertx-auth-mongo/hash_strategy.rb deleted file mode 100644 index 7952038b7..000000000 --- a/vertx-auth-mongo/src/main/resources/vertx-auth-mongo/hash_strategy.rb +++ /dev/null @@ -1,90 +0,0 @@ -require 'vertx-auth-common/user' -require 'vertx/util/utils.rb' -# Generated from io.vertx.ext.auth.mongo.HashStrategy -module VertxAuthMongo - # Determines how the hashing is computed in the implementation You can implement this to provide a different hashing - # strategy to the default. - class HashStrategy - # @private - # @param j_del [::VertxAuthMongo::HashStrategy] the java delegate - def initialize(j_del) - @j_del = j_del - end - # @private - # @return [::VertxAuthMongo::HashStrategy] the underlying java delegate - def j_del - @j_del - end - @@j_api_type = Object.new - def @@j_api_type.accept?(obj) - obj.class == HashStrategy - end - def @@j_api_type.wrap(obj) - HashStrategy.new(obj) - end - def @@j_api_type.unwrap(obj) - obj.j_del - end - def self.j_api_type - @@j_api_type - end - def self.j_class - Java::IoVertxExtAuthMongo::HashStrategy.java_class - end - # Compute the hashed password given the unhashed password and the user - # @param [String] password the unhashed password - # @param [::VertxAuthCommon::User] user the user to get the salt for. This paramter is needed, if the is declared to be used - # @return [String] the hashed password - def compute_hash(password=nil,user=nil) - if password.class == String && user.class.method_defined?(:j_del) && !block_given? - return @j_del.java_method(:computeHash, [Java::java.lang.String.java_class,Java::IoVertxExtAuth::User.java_class]).call(password,user.j_del) - end - raise ArgumentError, "Invalid arguments when calling compute_hash(#{password},#{user})" - end - # Retrieve the password from the user, or as clear text or as hashed version, depending on the definition - # @param [::VertxAuthCommon::User] user the user to get the stored password for - # @return [String] the password, either as hashed version or as cleartext, depending on the preferences - def get_stored_pwd(user=nil) - if user.class.method_defined?(:j_del) && !block_given? - return @j_del.java_method(:getStoredPwd, [Java::IoVertxExtAuth::User.java_class]).call(user.j_del) - end - raise ArgumentError, "Invalid arguments when calling get_stored_pwd(#{user})" - end - # Retrieve the salt. The source of the salt can be the external salt or the propriate column of the given user, - # depending on the defined HashSaltStyle - # @param [::VertxAuthCommon::User] user the user to get the salt for. This paramter is needed, if the is declared to be used - # @return [String] null in case of the salt of the user or a defined external salt - def get_salt(user=nil) - if user.class.method_defined?(:j_del) && !block_given? - return @j_del.java_method(:getSalt, [Java::IoVertxExtAuth::User.java_class]).call(user.j_del) - end - raise ArgumentError, "Invalid arguments when calling get_salt(#{user})" - end - # Set an external salt. This method should be used in case of - # @param [String] salt the salt, which shall be used - # @return [void] - def set_external_salt(salt=nil) - if salt.class == String && !block_given? - return @j_del.java_method(:setExternalSalt, [Java::java.lang.String.java_class]).call(salt) - end - raise ArgumentError, "Invalid arguments when calling set_external_salt(#{salt})" - end - # Set the saltstyle as defined by HashSaltStyle. - # @param [:NO_SALT,:COLUMN,:EXTERNAL] saltStyle the HashSaltStyle to be used - # @return [void] - def set_salt_style(saltStyle=nil) - if saltStyle.class == Symbol && !block_given? - return @j_del.java_method(:setSaltStyle, [Java::IoVertxExtAuthMongo::HashSaltStyle.java_class]).call(Java::IoVertxExtAuthMongo::HashSaltStyle.valueOf(saltStyle.to_s)) - end - raise ArgumentError, "Invalid arguments when calling set_salt_style(#{saltStyle})" - end - # Get the defined HashSaltStyle of the current instance - # @return [:NO_SALT,:COLUMN,:EXTERNAL] the saltStyle - def get_salt_style - if !block_given? - return @j_del.java_method(:getSaltStyle, []).call().name.intern - end - raise ArgumentError, "Invalid arguments when calling get_salt_style()" - end - end -end diff --git a/vertx-auth-mongo/src/main/resources/vertx-auth-mongo/mongo_auth.rb b/vertx-auth-mongo/src/main/resources/vertx-auth-mongo/mongo_auth.rb deleted file mode 100644 index 6b2975518..000000000 --- a/vertx-auth-mongo/src/main/resources/vertx-auth-mongo/mongo_auth.rb +++ /dev/null @@ -1,248 +0,0 @@ -require 'vertx-auth-common/user' -require 'vertx-mongo/mongo_client' -require 'vertx-auth-mongo/hash_strategy' -require 'vertx-auth-common/auth_provider' -require 'vertx/util/utils.rb' -# Generated from io.vertx.ext.auth.mongo.MongoAuth -module VertxAuthMongo - # An extension of AuthProvider which is using as store - class MongoAuth < ::VertxAuthCommon::AuthProvider - # @private - # @param j_del [::VertxAuthMongo::MongoAuth] the java delegate - def initialize(j_del) - super(j_del) - @j_del = j_del - end - # @private - # @return [::VertxAuthMongo::MongoAuth] the underlying java delegate - def j_del - @j_del - end - @@j_api_type = Object.new - def @@j_api_type.accept?(obj) - obj.class == MongoAuth - end - def @@j_api_type.wrap(obj) - MongoAuth.new(obj) - end - def @@j_api_type.unwrap(obj) - obj.j_del - end - def self.j_api_type - @@j_api_type - end - def self.j_class - Java::IoVertxExtAuthMongo::MongoAuth.java_class - end - # @param [Hash{String => Object}] arg0 - # @yield - # @return [void] - def authenticate(arg0=nil) - if arg0.class == Hash && block_given? - return @j_del.java_method(:authenticate, [Java::IoVertxCoreJson::JsonObject.java_class,Java::IoVertxCore::Handler.java_class]).call(::Vertx::Util::Utils.to_json_object(arg0),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxAuthCommon::User) : nil) })) - end - raise ArgumentError, "Invalid arguments when calling authenticate(#{arg0})" - end - # Creates an instance of MongoAuth by using the given and configuration object. An example for a - # configuration object: - # - #
-    #  JsonObject js = new JsonObject();
-    #  js.put(MongoAuth.PROPERTY_COLLECTION_NAME, createCollectionName(MongoAuth.DEFAULT_COLLECTION_NAME));
-    #  
- # @param [::VertxMongo::MongoClient] mongoClient an instance of to be used for data storage and retrival - # @param [Hash{String => Object}] config the configuration object for the current instance. By this - # @return [::VertxAuthMongo::MongoAuth] the created instance of {::VertxAuthMongo::MongoAuth}s - def self.create(mongoClient=nil,config=nil) - if mongoClient.class.method_defined?(:j_del) && config.class == Hash && !block_given? - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthMongo::MongoAuth.java_method(:create, [Java::IoVertxExtMongo::MongoClient.java_class,Java::IoVertxCoreJson::JsonObject.java_class]).call(mongoClient.j_del,::Vertx::Util::Utils.to_json_object(config)),::VertxAuthMongo::MongoAuth) - end - raise ArgumentError, "Invalid arguments when calling create(#{mongoClient},#{config})" - end - # Set the name of the collection to be used. Defaults to DEFAULT_COLLECTION_NAME - # @param [String] collectionName the name of the collection to be used for storing and reading user data - # @return [self] - def set_collection_name(collectionName=nil) - if collectionName.class == String && !block_given? - @j_del.java_method(:setCollectionName, [Java::java.lang.String.java_class]).call(collectionName) - return self - end - raise ArgumentError, "Invalid arguments when calling set_collection_name(#{collectionName})" - end - # Set the name of the field to be used for the username. Defaults to DEFAULT_USERNAME_FIELD - # @param [String] fieldName the name of the field to be used - # @return [self] - def set_username_field(fieldName=nil) - if fieldName.class == String && !block_given? - @j_del.java_method(:setUsernameField, [Java::java.lang.String.java_class]).call(fieldName) - return self - end - raise ArgumentError, "Invalid arguments when calling set_username_field(#{fieldName})" - end - # Set the name of the field to be used for the password Defaults to DEFAULT_PASSWORD_FIELD - # @param [String] fieldName the name of the field to be used - # @return [self] - def set_password_field(fieldName=nil) - if fieldName.class == String && !block_given? - @j_del.java_method(:setPasswordField, [Java::java.lang.String.java_class]).call(fieldName) - return self - end - raise ArgumentError, "Invalid arguments when calling set_password_field(#{fieldName})" - end - # Set the name of the field to be used for the roles. Defaults to DEFAULT_ROLE_FIELD. Roles are expected to - # be saved as JsonArray - # @param [String] fieldName the name of the field to be used - # @return [self] - def set_role_field(fieldName=nil) - if fieldName.class == String && !block_given? - @j_del.java_method(:setRoleField, [Java::java.lang.String.java_class]).call(fieldName) - return self - end - raise ArgumentError, "Invalid arguments when calling set_role_field(#{fieldName})" - end - # Set the name of the field to be used for the permissions. Defaults to DEFAULT_PERMISSION_FIELD. - # Permissions are expected to be saved as JsonArray - # @param [String] fieldName the name of the field to be used - # @return [self] - def set_permission_field(fieldName=nil) - if fieldName.class == String && !block_given? - @j_del.java_method(:setPermissionField, [Java::java.lang.String.java_class]).call(fieldName) - return self - end - raise ArgumentError, "Invalid arguments when calling set_permission_field(#{fieldName})" - end - # Set the name of the field to be used as property for the username in the method - # {::VertxAuthCommon::AuthProvider#authenticate}. Defaults to DEFAULT_CREDENTIAL_USERNAME_FIELD - # @param [String] fieldName the name of the field to be used - # @return [self] - def set_username_credential_field(fieldName=nil) - if fieldName.class == String && !block_given? - @j_del.java_method(:setUsernameCredentialField, [Java::java.lang.String.java_class]).call(fieldName) - return self - end - raise ArgumentError, "Invalid arguments when calling set_username_credential_field(#{fieldName})" - end - # Set the name of the field to be used as property for the password of credentials in the method - # {::VertxAuthCommon::AuthProvider#authenticate}. Defaults to DEFAULT_CREDENTIAL_PASSWORD_FIELD - # @param [String] fieldName the name of the field to be used - # @return [self] - def set_password_credential_field(fieldName=nil) - if fieldName.class == String && !block_given? - @j_del.java_method(:setPasswordCredentialField, [Java::java.lang.String.java_class]).call(fieldName) - return self - end - raise ArgumentError, "Invalid arguments when calling set_password_credential_field(#{fieldName})" - end - # Set the name of the field to be used for the salt. Only used when {::VertxAuthMongo::HashStrategy#set_salt_style} is - # set to - # @param [String] fieldName the name of the field to be used - # @return [self] - def set_salt_field(fieldName=nil) - if fieldName.class == String && !block_given? - @j_del.java_method(:setSaltField, [Java::java.lang.String.java_class]).call(fieldName) - return self - end - raise ArgumentError, "Invalid arguments when calling set_salt_field(#{fieldName})" - end - # The name of the collection used to store User objects inside. Defaults to DEFAULT_COLLECTION_NAME - # @return [String] the collectionName - def get_collection_name - if !block_given? - return @j_del.java_method(:getCollectionName, []).call() - end - raise ArgumentError, "Invalid arguments when calling get_collection_name()" - end - # Get the name of the field to be used for the username. Defaults to DEFAULT_USERNAME_FIELD - # @return [String] the usernameField - def get_username_field - if !block_given? - return @j_del.java_method(:getUsernameField, []).call() - end - raise ArgumentError, "Invalid arguments when calling get_username_field()" - end - # Get the name of the field to be used for the password Defaults to DEFAULT_PASSWORD_FIELD - # @return [String] the passwordField - def get_password_field - if !block_given? - return @j_del.java_method(:getPasswordField, []).call() - end - raise ArgumentError, "Invalid arguments when calling get_password_field()" - end - # Get the name of the field to be used for the roles. Defaults to DEFAULT_ROLE_FIELD. Roles are expected to - # be saved as JsonArray - # @return [String] the roleField - def get_role_field - if !block_given? - return @j_del.java_method(:getRoleField, []).call() - end - raise ArgumentError, "Invalid arguments when calling get_role_field()" - end - # Get the name of the field to be used for the permissions. Defaults to DEFAULT_PERMISSION_FIELD. - # Permissions are expected to be saved as JsonArray - # @return [String] the permissionField - def get_permission_field - if !block_given? - return @j_del.java_method(:getPermissionField, []).call() - end - raise ArgumentError, "Invalid arguments when calling get_permission_field()" - end - # Get the name of the field to be used as property for the username in the method - # {::VertxAuthCommon::AuthProvider#authenticate}. Defaults to DEFAULT_CREDENTIAL_USERNAME_FIELD - # @return [String] the usernameCredentialField - def get_username_credential_field - if !block_given? - return @j_del.java_method(:getUsernameCredentialField, []).call() - end - raise ArgumentError, "Invalid arguments when calling get_username_credential_field()" - end - # Get the name of the field to be used as property for the password of credentials in the method - # {::VertxAuthCommon::AuthProvider#authenticate}. Defaults to DEFAULT_CREDENTIAL_PASSWORD_FIELD - # @return [String] the passwordCredentialField - def get_password_credential_field - if !block_given? - return @j_del.java_method(:getPasswordCredentialField, []).call() - end - raise ArgumentError, "Invalid arguments when calling get_password_credential_field()" - end - # Get the name of the field to be used for the salt. Only used when {::VertxAuthMongo::HashStrategy#set_salt_style} is - # set to - # @return [String] the saltField - def get_salt_field - if !block_given? - return @j_del.java_method(:getSaltField, []).call() - end - raise ArgumentError, "Invalid arguments when calling get_salt_field()" - end - # The HashStrategy which is used by the current instance - # @param [::VertxAuthMongo::HashStrategy] hashStrategy the {::VertxAuthMongo::HashStrategy} to be set - # @return [self] - def set_hash_strategy(hashStrategy=nil) - if hashStrategy.class.method_defined?(:j_del) && !block_given? - @j_del.java_method(:setHashStrategy, [Java::IoVertxExtAuthMongo::HashStrategy.java_class]).call(hashStrategy.j_del) - return self - end - raise ArgumentError, "Invalid arguments when calling set_hash_strategy(#{hashStrategy})" - end - # The HashStrategy which is used by the current instance - # @return [::VertxAuthMongo::HashStrategy] the defined instance of {::VertxAuthMongo::HashStrategy} - def get_hash_strategy - if !block_given? - return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:getHashStrategy, []).call(),::VertxAuthMongo::HashStrategy) - end - raise ArgumentError, "Invalid arguments when calling get_hash_strategy()" - end - # Insert a new user into mongo in the convenient way - # @param [String] username the username to be set - # @param [String] password the passsword in clear text, will be adapted following the definitions of the defined {::VertxAuthMongo::HashStrategy} - # @param [Array] roles a list of roles to be set - # @param [Array] permissions a list of permissions to be set - # @yield the ResultHandler will be provided with the id of the generated record - # @return [void] - def insert_user(username=nil,password=nil,roles=nil,permissions=nil) - if username.class == String && password.class == String && roles.class == Array && permissions.class == Array && block_given? - return @j_del.java_method(:insertUser, [Java::java.lang.String.java_class,Java::java.lang.String.java_class,Java::JavaUtil::List.java_class,Java::JavaUtil::List.java_class,Java::IoVertxCore::Handler.java_class]).call(username,password,roles.map { |element| element },permissions.map { |element| element },(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) })) - end - raise ArgumentError, "Invalid arguments when calling insert_user(#{username},#{password},#{roles},#{permissions})" - end - end -end diff --git a/vertx-auth-oauth2/src/main/asciidoc/dataobjects.adoc b/vertx-auth-oauth2/src/main/asciidoc/dataobjects.adoc index 57f880819..18611ee0f 100644 --- a/vertx-auth-oauth2/src/main/asciidoc/dataobjects.adoc +++ b/vertx-auth-oauth2/src/main/asciidoc/dataobjects.adoc @@ -44,6 +44,7 @@ |[[maxHeaderSize]]`maxHeaderSize`|`Number (int)`|- |[[maxInitialLineLength]]`maxInitialLineLength`|`Number (int)`|- |[[maxPoolSize]]`maxPoolSize`|`Number (int)`|- +|[[maxRedirects]]`maxRedirects`|`Number (int)`|- |[[maxWaitQueueSize]]`maxWaitQueueSize`|`Number (int)`|- |[[maxWebsocketFrameSize]]`maxWebsocketFrameSize`|`Number (int)`|- |[[metricsName]]`metricsName`|`String`|- diff --git a/vertx-auth-oauth2/src/main/asciidoc/groovy/index.adoc b/vertx-auth-oauth2/src/main/asciidoc/groovy/index.adoc index 4b7ee1b28..3e299488a 100644 --- a/vertx-auth-oauth2/src/main/asciidoc/groovy/index.adoc +++ b/vertx-auth-oauth2/src/main/asciidoc/groovy/index.adoc @@ -12,7 +12,7 @@ dependency to the _dependencies_ section of your build descriptor: io.vertx vertx-auth-oauth2 - 3.4.0.Beta1 + 3.4.0-SNAPSHOT ---- @@ -20,7 +20,7 @@ dependency to the _dependencies_ section of your build descriptor: [source,groovy,subs="+attributes"] ---- -compile 'io.vertx:vertx-auth-oauth2:3.4.0.Beta1' +compile 'io.vertx:vertx-auth-oauth2:3.4.0-SNAPSHOT' ---- OAuth2 lets users grant the access to the desired resources to third party applications, giving them the possibility @@ -75,8 +75,6 @@ An example on how to use this provider and authenticate with GitHub can be imple [source,groovy] ---- -import io.vertx.ext.auth.oauth2.OAuth2FlowType -import io.vertx.ext.auth.oauth2.OAuth2Auth def oauth2 = OAuth2Auth.create(vertx, OAuth2FlowType.AUTH_CODE, [ clientID:"YOUR_CLIENT_ID", @@ -124,8 +122,6 @@ access token. [source,groovy] ---- -import io.vertx.ext.auth.oauth2.OAuth2FlowType -import io.vertx.ext.auth.oauth2.OAuth2Auth // Set the client credentials and the OAuth2 server def credentials = [ @@ -174,9 +170,6 @@ need a fast way to test your application. [source,groovy] ---- -import io.vertx.ext.auth.oauth2.OAuth2FlowType -import io.vertx.ext.auth.oauth2.OAuth2Auth -import io.vertx.core.http.HttpMethod // Initialize the OAuth2 Library def oauth2 = OAuth2Auth.create(vertx, OAuth2FlowType.PASSWORD) @@ -211,8 +204,6 @@ This flow is suitable when client is requesting access to the protected resource [source,groovy] ---- -import io.vertx.ext.auth.oauth2.OAuth2FlowType -import io.vertx.ext.auth.oauth2.OAuth2Auth // Set the client credentials and the OAuth2 server def credentials = [ @@ -305,8 +296,6 @@ This information is quite valuable since it allows to do authorization at the AP [source,groovy] ---- -import io.vertx.ext.auth.oauth2.OAuth2FlowType -import io.vertx.ext.auth.oauth2.providers.KeycloakAuth // you would get this config from the keycloak admin console def keycloakJson = [ realm:"master", @@ -348,7 +337,6 @@ data (e.g. `preferred_username`) from the Keycloak principal. For example: [source,groovy] ---- -import io.vertx.ext.auth.oauth2.KeycloakHelper // you can get the decoded `id_token` from the Keycloak principal def idToken = KeycloakHelper.idToken(principal) diff --git a/vertx-auth-oauth2/src/main/asciidoc/java/index.adoc b/vertx-auth-oauth2/src/main/asciidoc/java/index.adoc index 9421616bd..0a6cd3c77 100644 --- a/vertx-auth-oauth2/src/main/asciidoc/java/index.adoc +++ b/vertx-auth-oauth2/src/main/asciidoc/java/index.adoc @@ -12,7 +12,7 @@ dependency to the _dependencies_ section of your build descriptor: io.vertx vertx-auth-oauth2 - 3.4.0.Beta1 + 3.4.0-SNAPSHOT ---- @@ -20,7 +20,7 @@ dependency to the _dependencies_ section of your build descriptor: [source,groovy,subs="+attributes"] ---- -compile 'io.vertx:vertx-auth-oauth2:3.4.0.Beta1' +compile 'io.vertx:vertx-auth-oauth2:3.4.0-SNAPSHOT' ---- OAuth2 lets users grant the access to the desired resources to third party applications, giving them the possibility diff --git a/vertx-auth-oauth2/src/main/asciidoc/js/index.adoc b/vertx-auth-oauth2/src/main/asciidoc/js/index.adoc index 8cd691a43..8d5fa4e96 100644 --- a/vertx-auth-oauth2/src/main/asciidoc/js/index.adoc +++ b/vertx-auth-oauth2/src/main/asciidoc/js/index.adoc @@ -12,7 +12,7 @@ dependency to the _dependencies_ section of your build descriptor: io.vertx vertx-auth-oauth2 - 3.4.0.Beta1 + 3.4.0-SNAPSHOT ---- @@ -20,7 +20,7 @@ dependency to the _dependencies_ section of your build descriptor: [source,groovy,subs="+attributes"] ---- -compile 'io.vertx:vertx-auth-oauth2:3.4.0.Beta1' +compile 'io.vertx:vertx-auth-oauth2:3.4.0-SNAPSHOT' ---- OAuth2 lets users grant the access to the desired resources to third party applications, giving them the possibility diff --git a/vertx-auth-oauth2/src/main/asciidoc/kotlin/index.adoc b/vertx-auth-oauth2/src/main/asciidoc/kotlin/index.adoc new file mode 100644 index 000000000..996a667dd --- /dev/null +++ b/vertx-auth-oauth2/src/main/asciidoc/kotlin/index.adoc @@ -0,0 +1,412 @@ +== The OAuth2 auth provider + +This component contains an out of the box OAuth2 implementation. + +To use this project, add the following +dependency to the _dependencies_ section of your build descriptor: + +* Maven (in your `pom.xml`): + +[source,xml,subs="+attributes"] +---- + + io.vertx + vertx-auth-oauth2 + 3.4.0-SNAPSHOT + +---- + +* Gradle (in your `build.gradle` file): + +[source,groovy,subs="+attributes"] +---- +compile 'io.vertx:vertx-auth-oauth2:3.4.0-SNAPSHOT' +---- + +OAuth2 lets users grant the access to the desired resources to third party applications, giving them the possibility +to enable and disable those accesses whenever they want. + +Vert.x OAuth2 supports the following flows. + +* Authorization Code Flow (for apps with servers that can store persistent information). +* Password Credentials Flow (when previous flow can't be used or during development). +* Client Credentials Flow (the client can request an access token using only its client credentials) + +=== Authorization Code Flow + +The authorization code grant type is used to obtain both access tokens and refresh tokens and is optimized for +confidential clients. As a redirection-based flow, the client must be capable of interacting with the resource +owner's user-agent (typically a web browser) and capable of receiving incoming requests (via redirection) from the +authorization server. + +For more details see http://tools.ietf.org/html/draft-ietf-oauth-v2-31#section-4.1[Oauth2 specification, section 4.1]. + +=== Password Credentials Flow + +The resource owner password credentials grant type is suitable in cases where the resource owner has a trust +relationship with the client, such as the device operating system or a highly privileged application. The +authorization server should take special care when enabling this grant type, and only allow it when other flows are +not viable. + +The grant type is suitable for clients capable of obtaining the resource owner's credentials (username and password, +typically using an interactive form). It is also used to migrate existing clients using direct authentication +schemes such as HTTP Basic or Digest authentication to OAuth by converting the stored credentials to an access token. + +For more details see http://tools.ietf.org/html/draft-ietf-oauth-v2-31#section-4.3[Oauth2 specification, section 4.3]. + +=== Client Credentials Flow + +The client can request an access token using only its client credentials (or other supported means of authentication) +when the client is requesting access to the protected resources under its control, or those of another resource owner +that have been previously arranged with the authorization server (the method of which is beyond the scope of this +specification). + +The client credentials grant type MUST only be used by confidential clients. + +For more details see http://tools.ietf.org/html/draft-ietf-oauth-v2-31#section-4.4[Oauth2 specification, section 4.4]. + +=== Extensions + +The provider supports RFC7523 an extension to allow server to server authorization based on JWT. + +=== Getting Started + +An example on how to use this provider and authenticate with GitHub can be implemented as: + +[source,kotlin] +---- + +var oauth2 = OAuth2Auth.create(vertx, OAuth2FlowType.AUTH_CODE, OAuth2ClientOptions( + clientID = "YOUR_CLIENT_ID", + clientSecret = "YOUR_CLIENT_SECRET", + site = "https://github.com/login", + tokenPath = "/oauth/access_token", + authorizationPath = "/oauth/authorize")) + +// when there is a need to access a protected resource or call a protected method, +// call the authZ url for a challenge + +var authorization_uri = oauth2.authorizeURL(json { + obj( + "redirect_uri" to "http://localhost:8080/callback", + "scope" to "notifications", + "state" to "3(#0/!~" + ) +}) + +// when working with web application use the above string as a redirect url + +// in this case GitHub will call you back in the callback uri one should now complete the handshake as: + + +var code = "xxxxxxxxxxxxxxxxxxxxxxxx" + +oauth2.getToken(json { + obj( + "code" to code, + "redirect_uri" to "http://localhost:8080/callback" + ) +}, { res -> + if (res.failed()) { + // error, the code provided is not valid + } else { + // save the token and continue... + } +}) + +---- + +==== Authorization Code flow + +The Authorization Code flow is made up from two parts. At first your application asks to the user the permission to +access their data. If the user approves the OAuth2 server sends to the client an authorization code. In the second +part, the client POST the authorization code along with its client secret to the authority server in order to get the +access token. + +[source,kotlin] +---- + +// Set the client credentials and the OAuth2 server +var credentials = OAuth2ClientOptions( + clientID = "", + clientSecret = "", + site = "https://api.oauth.com") + + +// Initialize the OAuth2 Library +var oauth2 = OAuth2Auth.create(vertx, OAuth2FlowType.AUTH_CODE, credentials) + +// Authorization oauth2 URI +var authorization_uri = oauth2.authorizeURL(json { + obj( + "redirect_uri" to "http://localhost:8080/callback", + "scope" to "", + "state" to "" + ) +}) + +// Redirect example using Vert.x +response.putHeader("Location", authorization_uri).setStatusCode(302).end() + +var tokenConfig = json { + obj( + "code" to "", + "redirect_uri" to "http://localhost:3000/callback" + ) +} + +// Callbacks +// Save the access token +oauth2.getToken(tokenConfig, { res -> + if (res.failed()) { + System.err.println("Access Token Error: ${res.cause().getMessage()}") + } else { + // Get the access token object (the authorization code is given from the previous step). + var token = res.result() + } +}) + +---- + +==== Password Credentials Flow + +This flow is suitable when the resource owner has a trust relationship with the client, such as its computer +operating system or a highly privileged application. Use this flow only when other flows are not viable or when you +need a fast way to test your application. + +[source,kotlin] +---- + +// Initialize the OAuth2 Library +var oauth2 = OAuth2Auth.create(vertx, OAuth2FlowType.PASSWORD) + +var tokenConfig = json { + obj( + "username" to "username", + "password" to "password" + ) +} + +// Callbacks +// Save the access token +oauth2.getToken(tokenConfig, { res -> + if (res.failed()) { + System.err.println("Access Token Error: ${res.cause().getMessage()}") + } else { + // Get the access token object (the authorization code is given from the previous step). + var token = res.result() + + oauth2.api(HttpMethod.GET, "/users", json { + obj("access_token" to token.principal().getString("access_token")) + }, { res2 -> + // the user object should be returned here... + }) + } +}) + +---- + +==== Client Credentials Flow + +This flow is suitable when client is requesting access to the protected resources under its control. + +[source,kotlin] +---- + +// Set the client credentials and the OAuth2 server +var credentials = OAuth2ClientOptions( + clientID = "", + clientSecret = "", + site = "https://api.oauth.com") + + +// Initialize the OAuth2 Library +var oauth2 = OAuth2Auth.create(vertx, OAuth2FlowType.CLIENT, credentials) + +var tokenConfig = json { + obj() +} + +// Callbacks +// Save the access token +oauth2.getToken(tokenConfig, { res -> + if (res.failed()) { + System.err.println("Access Token Error: ${res.cause().getMessage()}") + } else { + // Get the access token object (the authorization code is given from the previous step). + var token = res.result() + } +}) + +---- + +=== AccessToken object + +When a token expires we need to refresh it. OAuth2 offers the AccessToken class that add a couple of useful methods +to refresh the access token when it is expired. + +[source,kotlin] +---- +// Check if the token is expired. If expired it is refreshed. +if (token.expired()) { + // Callbacks + token.refresh({ res -> + if (res.succeeded()) { + // success + } else { + // error handling... + } + }) +} + +---- + +When you've done with the token or you want to log out, you can revoke the access token and refresh token. + +[source,kotlin] +---- +// Revoke only the access token +token.revoke("access_token", { res -> + // Session ended. But the refresh_token is still valid. + + // Revoke the refresh_token + token.revoke("refresh_token", { res1 -> + println("token revoked.") + }) +}) + +---- + +=== Example configuration for common OAuth2 providers + +For convenience there are several helpers to assist your with your configuration. Currently we provide: + +* Azure Active Directory `link:../../apidocs/io/vertx/ext/auth/oauth2/providers/AzureADAuth.html[AzureADAuth]` +* Box.com `link:../../apidocs/io/vertx/ext/auth/oauth2/providers/BoxAuth.html[BoxAuth]` +* Dropbox `link:../../apidocs/io/vertx/ext/auth/oauth2/providers/DropboxAuth.html[DropboxAuth]` +* Facebook `link:../../apidocs/io/vertx/ext/auth/oauth2/providers/FacebookAuth.html[FacebookAuth]` +* Foursquare `link:../../apidocs/io/vertx/ext/auth/oauth2/providers/FoursquareAuth.html[FoursquareAuth]` +* Github `link:../../apidocs/io/vertx/ext/auth/oauth2/providers/GithubAuth.html[GithubAuth]` +* Google `link:../../apidocs/io/vertx/ext/auth/oauth2/providers/GoogleAuth.html[GoogleAuth]` +* Instagram `link:../../apidocs/io/vertx/ext/auth/oauth2/providers/InstagramAuth.html[InstagramAuth]` +* Keycloak `link:../../apidocs/io/vertx/ext/auth/oauth2/providers/KeycloakAuth.html[KeycloakAuth]` +* LinkedIn `link:../../apidocs/io/vertx/ext/auth/oauth2/providers/LinkedInAuth.html[LinkedInAuth]` +* Mailchimp `link:../../apidocs/io/vertx/ext/auth/oauth2/providers/MailchimpAuth.html[MailchimpAuth]` +* Salesforce `link:../../apidocs/io/vertx/ext/auth/oauth2/providers/SalesforceAuth.html[SalesforceAuth]` +* Shopify `link:../../apidocs/io/vertx/ext/auth/oauth2/providers/ShopifyAuth.html[ShopifyAuth]` +* Soundcloud `link:../../apidocs/io/vertx/ext/auth/oauth2/providers/SoundcloudAuth.html[SoundcloudAuth]` +* Stripe `link:../../apidocs/io/vertx/ext/auth/oauth2/providers/StripeAuth.html[StripeAuth]` +* Twitter `link:../../apidocs/io/vertx/ext/auth/oauth2/providers/TwitterAuth.html[TwitterAuth]` + +==== JBoss Keycloak + +When using this Keycloak the provider has knowledge on how to parse access tokens and extract grants from inside. +This information is quite valuable since it allows to do authorization at the API level, for example: + +[source,kotlin] +---- +// you would get this config from the keycloak admin console +var keycloakJson = json { + obj( + "realm" to "master", + "realm-public-key" to "MIIBIjANBgkqhk...wIDAQAB", + "auth-server-url" to "http://localhost:9000/auth", + "ssl-required" to "external", + "resource" to "frontend", + "credentials" to obj("secret" to "2fbf5e18-b923-4a83-9657-b4ebd5317f60") + ) +} + +// Initialize the OAuth2 Library +var oauth2 = KeycloakAuth.create(vertx, OAuth2FlowType.PASSWORD, keycloakJson) + +// first get a token (authenticate) +oauth2.getToken(json { + obj( + "username" to "user", + "password" to "secret" + ) +}, { res -> + if (res.failed()) { + // error handling... + } else { + var token = res.result() + + // now check for permissions + token.isAuthorised("account:manage-account", { r -> + if (r.result()) { + // this user is authorized to manage its account + } + }) + } +}) + +---- + +We also provide a helper class for Keycloak so that we can we can easily retrieve decoded token and some necessary +data (e.g. `preferred_username`) from the Keycloak principal. For example: + +[source,kotlin] +---- +// you can get the decoded `id_token` from the Keycloak principal +var idToken = KeycloakHelper.idToken(principal) + +// you can also retrieve some properties directly from the Keycloak principal +// e.g. `preferred_username` +var username = KeycloakHelper.preferredUsername(principal) + +---- + +==== Google Server to Server + +The provider also supports Server to Server or the RFC7523 extension. This is a feature present on Google with their +service account. + +=== Token Introspection + +Tokens can be introspected in order to assert that they are still valid. Although there is RFC7660 for this purpose +not many providers implement it. Instead there are variations also known as `TokenInfo` end points. The OAuth2 +provider will accept both end points as a configuration. Currently we are known to work with `Google` and `Keycloak`. + +Token introspection assumes that tokens are opaque, so they need to be validated on the provider server. Every time a +token is validated it requires a round trip to the provider. Introspection can be performed at the OAuth2 level or at +the User level: + +[source,kotlin] +---- +// OAuth2Auth level +oauth2.introspectToken("opaque string", { res -> + if (res.succeeded()) { + // token is valid! + var accessToken = res.result() + } +}) + +// User level +token.introspect({ res -> + if (res.succeeded()) { + // Token is valid! + } +}) + +---- + +=== Verifying JWT tokens + +We've just covered how to introspect a token however when dealing with JWT tokens one can reduce the amount of trips +to the provider server thus enhancing your overall response times. In this case tokens will be verified using the +JWT protocol at your application side only. Verifying JWT tokens is cheaper and offers better performance, however +due to the stateless nature of JWTs it is not possible to know if a user is logged out and a token is invalid. For +this specific case one needs to use the token introspection if the provider supports it. + +[source,kotlin] +---- +// OAuth2Auth level +oauth2.decodeToken("jwt-token", { res -> + if (res.succeeded()) { + // token is valid! + var accessToken = res.result() + } +}) + +---- \ No newline at end of file diff --git a/vertx-auth-oauth2/src/main/asciidoc/ruby/index.adoc b/vertx-auth-oauth2/src/main/asciidoc/ruby/index.adoc index ebd7b3898..c2052ff10 100644 --- a/vertx-auth-oauth2/src/main/asciidoc/ruby/index.adoc +++ b/vertx-auth-oauth2/src/main/asciidoc/ruby/index.adoc @@ -12,7 +12,7 @@ dependency to the _dependencies_ section of your build descriptor: io.vertx vertx-auth-oauth2 - 3.4.0.Beta1 + 3.4.0-SNAPSHOT ---- @@ -20,7 +20,7 @@ dependency to the _dependencies_ section of your build descriptor: [source,groovy,subs="+attributes"] ---- -compile 'io.vertx:vertx-auth-oauth2:3.4.0.Beta1' +compile 'io.vertx:vertx-auth-oauth2:3.4.0-SNAPSHOT' ---- OAuth2 lets users grant the access to the desired resources to third party applications, giving them the possibility diff --git a/vertx-auth-oauth2/src/main/kotlin/io/vertx/kotlin/ext/auth/oauth2/OAuth2ClientOptions.kt b/vertx-auth-oauth2/src/main/kotlin/io/vertx/kotlin/ext/auth/oauth2/OAuth2ClientOptions.kt index fa9726c03..c153bfdb4 100644 --- a/vertx-auth-oauth2/src/main/kotlin/io/vertx/kotlin/ext/auth/oauth2/OAuth2ClientOptions.kt +++ b/vertx-auth-oauth2/src/main/kotlin/io/vertx/kotlin/ext/auth/oauth2/OAuth2ClientOptions.kt @@ -48,6 +48,7 @@ import io.vertx.core.net.ProxyOptions * @param maxHeaderSize * @param maxInitialLineLength * @param maxPoolSize + * @param maxRedirects * @param maxWaitQueueSize * @param maxWebsocketFrameSize * @param metricsName @@ -121,6 +122,7 @@ fun OAuth2ClientOptions( maxHeaderSize: Int? = null, maxInitialLineLength: Int? = null, maxPoolSize: Int? = null, + maxRedirects: Int? = null, maxWaitQueueSize: Int? = null, maxWebsocketFrameSize: Int? = null, metricsName: String? = null, @@ -262,6 +264,9 @@ fun OAuth2ClientOptions( if (maxPoolSize != null) { this.setMaxPoolSize(maxPoolSize) } + if (maxRedirects != null) { + this.setMaxRedirects(maxRedirects) + } if (maxWaitQueueSize != null) { this.setMaxWaitQueueSize(maxWaitQueueSize) } diff --git a/vertx-auth-oauth2/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule b/vertx-auth-oauth2/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule deleted file mode 100644 index e3d769142..000000000 --- a/vertx-auth-oauth2/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule +++ /dev/null @@ -1,4 +0,0 @@ -moduleName = io.vertx.ext.auth.oauth2.providers.TwitterAuth-module -moduleVersion = 1.0 -extensionClasses = io.vertx.groovy.ext.auth.oauth2.OAuth2Auth_GroovyExtension -staticExtensionClasses = io.vertx.groovy.ext.auth.oauth2.providers.AzureADAuth_GroovyStaticExtension, io.vertx.groovy.ext.auth.oauth2.providers.BoxAuth_GroovyStaticExtension, io.vertx.groovy.ext.auth.oauth2.providers.CloudFoundryAuth_GroovyStaticExtension, io.vertx.groovy.ext.auth.oauth2.providers.DropboxAuth_GroovyStaticExtension, io.vertx.groovy.ext.auth.oauth2.providers.FacebookAuth_GroovyStaticExtension, io.vertx.groovy.ext.auth.oauth2.providers.FoursquareAuth_GroovyStaticExtension, io.vertx.groovy.ext.auth.oauth2.providers.GithubAuth_GroovyStaticExtension, io.vertx.groovy.ext.auth.oauth2.providers.GoogleAuth_GroovyStaticExtension, io.vertx.groovy.ext.auth.oauth2.providers.HerokuAuth_GroovyStaticExtension, io.vertx.groovy.ext.auth.oauth2.providers.InstagramAuth_GroovyStaticExtension, io.vertx.groovy.ext.auth.oauth2.providers.KeycloakAuth_GroovyStaticExtension, io.vertx.groovy.ext.auth.oauth2.KeycloakHelper_GroovyStaticExtension, io.vertx.groovy.ext.auth.oauth2.providers.LinkedInAuth_GroovyStaticExtension, io.vertx.groovy.ext.auth.oauth2.providers.LiveAuth_GroovyStaticExtension, io.vertx.groovy.ext.auth.oauth2.providers.MailchimpAuth_GroovyStaticExtension, io.vertx.groovy.ext.auth.oauth2.OAuth2Auth_GroovyStaticExtension, io.vertx.groovy.ext.auth.oauth2.providers.SalesforceAuth_GroovyStaticExtension, io.vertx.groovy.ext.auth.oauth2.providers.ShopifyAuth_GroovyStaticExtension, io.vertx.groovy.ext.auth.oauth2.providers.SoundcloudAuth_GroovyStaticExtension, io.vertx.groovy.ext.auth.oauth2.providers.StripeAuth_GroovyStaticExtension, io.vertx.groovy.ext.auth.oauth2.providers.TwitterAuth_GroovyStaticExtension diff --git a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/access_token.js b/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/access_token.js deleted file mode 100644 index ae36bdc3e..000000000 --- a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/access_token.js +++ /dev/null @@ -1,222 +0,0 @@ -/* - * Copyright 2014 Red Hat, Inc. - * - * Red Hat 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. - */ - -/** @module vertx-auth-oauth2-js/access_token */ -var utils = require('vertx-js/util/utils'); -var User = require('vertx-auth-common-js/user'); -var AuthProvider = require('vertx-auth-common-js/auth_provider'); - -var io = Packages.io; -var JsonObject = io.vertx.core.json.JsonObject; -var JAccessToken = Java.type('io.vertx.ext.auth.oauth2.AccessToken'); - -/** - AccessToken extension to the User interface - - @class -*/ -var AccessToken = function(j_val) { - - var j_accessToken = j_val; - var that = this; - User.call(this, j_val); - - /** - - @public - @param arg0 {string} - @param arg1 {function} - @return {User} - */ - this.isAuthorised = function(arg0, arg1) { - var __args = arguments; - if (__args.length === 2 && typeof __args[0] === 'string' && typeof __args[1] === 'function') { - j_accessToken["isAuthorised(java.lang.String,io.vertx.core.Handler)"](arg0, function(ar) { - if (ar.succeeded()) { - arg1(ar.result(), null); - } else { - arg1(null, ar.cause()); - } - }); - return that; - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - - @public - - @return {User} - */ - this.clearCache = function() { - var __args = arguments; - if (__args.length === 0) { - j_accessToken["clearCache()"](); - return that; - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - - @public - - @return {Object} - */ - this.principal = function() { - var __args = arguments; - if (__args.length === 0) { - return utils.convReturnJson(j_accessToken["principal()"]()); - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - - @public - @param arg0 {AuthProvider} - */ - this.setAuthProvider = function(arg0) { - var __args = arguments; - if (__args.length === 1 && typeof __args[0] === 'object' && __args[0]._jdel) { - j_accessToken["setAuthProvider(io.vertx.ext.auth.AuthProvider)"](arg0._jdel); - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - Check if the access token is expired or not. - - @public - - @return {boolean} - */ - this.expired = function() { - var __args = arguments; - if (__args.length === 0) { - return j_accessToken["expired()"](); - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - Refresh the access token - - @public - @param callback {function} - The callback function returning the results. - @return {AccessToken} - */ - this.refresh = function(callback) { - var __args = arguments; - if (__args.length === 1 && typeof __args[0] === 'function') { - j_accessToken["refresh(io.vertx.core.Handler)"](function(ar) { - if (ar.succeeded()) { - callback(null, null); - } else { - callback(null, ar.cause()); - } - }); - return that; - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - Revoke access or refresh token - - @public - @param token_type {string} - A String containing the type of token to revoke. Should be either "access_token" or "refresh_token". - @param callback {function} - The callback function returning the results. - @return {AccessToken} - */ - this.revoke = function(token_type, callback) { - var __args = arguments; - if (__args.length === 2 && typeof __args[0] === 'string' && typeof __args[1] === 'function') { - j_accessToken["revoke(java.lang.String,io.vertx.core.Handler)"](token_type, function(ar) { - if (ar.succeeded()) { - callback(null, null); - } else { - callback(null, ar.cause()); - } - }); - return that; - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - Revoke refresh token and calls the logout endpoint. This is a openid-connect extension and might not be - available on all providers. - - @public - @param callback {function} - The callback function returning the results. - @return {AccessToken} - */ - this.logout = function(callback) { - var __args = arguments; - if (__args.length === 1 && typeof __args[0] === 'function') { - j_accessToken["logout(io.vertx.core.Handler)"](function(ar) { - if (ar.succeeded()) { - callback(null, null); - } else { - callback(null, ar.cause()); - } - }); - return that; - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - Introspect access token. This is an OAuth2 extension that allow to verify if an access token is still valid. - - @public - @param callback {function} - The callback function returning the results. - @return {AccessToken} - */ - this.introspect = function(callback) { - var __args = arguments; - if (__args.length === 1 && typeof __args[0] === 'function') { - j_accessToken["introspect(io.vertx.core.Handler)"](function(ar) { - if (ar.succeeded()) { - callback(null, null); - } else { - callback(null, ar.cause()); - } - }); - return that; - } else throw new TypeError('function invoked with invalid arguments'); - }; - - // A reference to the underlying Java delegate - // NOTE! This is an internal API and must not be used in user code. - // If you rely on this property your code is likely to break if we change it / remove it without warning. - this._jdel = j_accessToken; -}; - -AccessToken._jclass = utils.getJavaClass("io.vertx.ext.auth.oauth2.AccessToken"); -AccessToken._jtype = { - accept: function(obj) { - return AccessToken._jclass.isInstance(obj._jdel); - }, - wrap: function(jdel) { - var obj = Object.create(AccessToken.prototype, {}); - AccessToken.apply(obj, arguments); - return obj; - }, - unwrap: function(obj) { - return obj._jdel; - } -}; -AccessToken._create = function(jdel) { - var obj = Object.create(AccessToken.prototype, {}); - AccessToken.apply(obj, arguments); - return obj; -} -module.exports = AccessToken; \ No newline at end of file diff --git a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/azure_ad_auth.js b/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/azure_ad_auth.js deleted file mode 100644 index b29a96d21..000000000 --- a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/azure_ad_auth.js +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2014 Red Hat, Inc. - * - * Red Hat 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. - */ - -/** @module vertx-auth-oauth2-js/azure_ad_auth */ -var utils = require('vertx-js/util/utils'); -var Vertx = require('vertx-js/vertx'); -var OAuth2Auth = require('vertx-auth-oauth2-js/o_auth2_auth'); - -var io = Packages.io; -var JsonObject = io.vertx.core.json.JsonObject; -var JAzureADAuth = Java.type('io.vertx.ext.auth.oauth2.providers.AzureADAuth'); -var HttpClientOptions = Java.type('io.vertx.core.http.HttpClientOptions'); - -/** - - @class -*/ -var AzureADAuth = function(j_val) { - - var j_azureADAuth = j_val; - var that = this; - - // A reference to the underlying Java delegate - // NOTE! This is an internal API and must not be used in user code. - // If you rely on this property your code is likely to break if we change it / remove it without warning. - this._jdel = j_azureADAuth; -}; - -AzureADAuth._jclass = utils.getJavaClass("io.vertx.ext.auth.oauth2.providers.AzureADAuth"); -AzureADAuth._jtype = { - accept: function(obj) { - return AzureADAuth._jclass.isInstance(obj._jdel); - }, - wrap: function(jdel) { - var obj = Object.create(AzureADAuth.prototype, {}); - AzureADAuth.apply(obj, arguments); - return obj; - }, - unwrap: function(obj) { - return obj._jdel; - } -}; -AzureADAuth._create = function(jdel) { - var obj = Object.create(AzureADAuth.prototype, {}); - AzureADAuth.apply(obj, arguments); - return obj; -} -/** - Create a OAuth2Auth provider for Microsoft Azure Active Directory - - @memberof module:vertx-auth-oauth2-js/azure_ad_auth - @param vertx {Vertx} - @param clientId {string} the client id given to you by Azure - @param clientSecret {string} the client secret given to you by Azure - @param guid {string} the guid of your application given to you by Azure - @param httpClientOptions {Object} custom http client options - @return {OAuth2Auth} - */ -AzureADAuth.create = function() { - var __args = arguments; - if (__args.length === 4 && typeof __args[0] === 'object' && __args[0]._jdel && typeof __args[1] === 'string' && typeof __args[2] === 'string' && typeof __args[3] === 'string') { - return utils.convReturnVertxGen(OAuth2Auth, JAzureADAuth["create(io.vertx.core.Vertx,java.lang.String,java.lang.String,java.lang.String)"](__args[0]._jdel, __args[1], __args[2], __args[3])); - }else if (__args.length === 5 && typeof __args[0] === 'object' && __args[0]._jdel && typeof __args[1] === 'string' && typeof __args[2] === 'string' && typeof __args[3] === 'string' && (typeof __args[4] === 'object' && __args[4] != null)) { - return utils.convReturnVertxGen(OAuth2Auth, JAzureADAuth["create(io.vertx.core.Vertx,java.lang.String,java.lang.String,java.lang.String,io.vertx.core.http.HttpClientOptions)"](__args[0]._jdel, __args[1], __args[2], __args[3], __args[4] != null ? new HttpClientOptions(new JsonObject(Java.asJSONCompatible(__args[4]))) : null)); - } else throw new TypeError('function invoked with invalid arguments'); -}; - -module.exports = AzureADAuth; \ No newline at end of file diff --git a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/box_auth.js b/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/box_auth.js deleted file mode 100644 index be4fd98a7..000000000 --- a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/box_auth.js +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2014 Red Hat, Inc. - * - * Red Hat 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. - */ - -/** @module vertx-auth-oauth2-js/box_auth */ -var utils = require('vertx-js/util/utils'); -var Vertx = require('vertx-js/vertx'); -var OAuth2Auth = require('vertx-auth-oauth2-js/o_auth2_auth'); - -var io = Packages.io; -var JsonObject = io.vertx.core.json.JsonObject; -var JBoxAuth = Java.type('io.vertx.ext.auth.oauth2.providers.BoxAuth'); -var HttpClientOptions = Java.type('io.vertx.core.http.HttpClientOptions'); - -/** - - @class -*/ -var BoxAuth = function(j_val) { - - var j_boxAuth = j_val; - var that = this; - - // A reference to the underlying Java delegate - // NOTE! This is an internal API and must not be used in user code. - // If you rely on this property your code is likely to break if we change it / remove it without warning. - this._jdel = j_boxAuth; -}; - -BoxAuth._jclass = utils.getJavaClass("io.vertx.ext.auth.oauth2.providers.BoxAuth"); -BoxAuth._jtype = { - accept: function(obj) { - return BoxAuth._jclass.isInstance(obj._jdel); - }, - wrap: function(jdel) { - var obj = Object.create(BoxAuth.prototype, {}); - BoxAuth.apply(obj, arguments); - return obj; - }, - unwrap: function(obj) { - return obj._jdel; - } -}; -BoxAuth._create = function(jdel) { - var obj = Object.create(BoxAuth.prototype, {}); - BoxAuth.apply(obj, arguments); - return obj; -} -/** - Create a OAuth2Auth provider for App.net - - @memberof module:vertx-auth-oauth2-js/box_auth - @param vertx {Vertx} - @param clientId {string} the client id given to you by box.com - @param clientSecret {string} the client secret given to you by box.com - @param httpClientOptions {Object} custom http client options - @return {OAuth2Auth} - */ -BoxAuth.create = function() { - var __args = arguments; - if (__args.length === 3 && typeof __args[0] === 'object' && __args[0]._jdel && typeof __args[1] === 'string' && typeof __args[2] === 'string') { - return utils.convReturnVertxGen(OAuth2Auth, JBoxAuth["create(io.vertx.core.Vertx,java.lang.String,java.lang.String)"](__args[0]._jdel, __args[1], __args[2])); - }else if (__args.length === 4 && typeof __args[0] === 'object' && __args[0]._jdel && typeof __args[1] === 'string' && typeof __args[2] === 'string' && (typeof __args[3] === 'object' && __args[3] != null)) { - return utils.convReturnVertxGen(OAuth2Auth, JBoxAuth["create(io.vertx.core.Vertx,java.lang.String,java.lang.String,io.vertx.core.http.HttpClientOptions)"](__args[0]._jdel, __args[1], __args[2], __args[3] != null ? new HttpClientOptions(new JsonObject(Java.asJSONCompatible(__args[3]))) : null)); - } else throw new TypeError('function invoked with invalid arguments'); -}; - -module.exports = BoxAuth; \ No newline at end of file diff --git a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/cloud_foundry_auth.js b/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/cloud_foundry_auth.js deleted file mode 100644 index 6b04fa0aa..000000000 --- a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/cloud_foundry_auth.js +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2014 Red Hat, Inc. - * - * Red Hat 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. - */ - -/** @module vertx-auth-oauth2-js/cloud_foundry_auth */ -var utils = require('vertx-js/util/utils'); -var Vertx = require('vertx-js/vertx'); -var OAuth2Auth = require('vertx-auth-oauth2-js/o_auth2_auth'); - -var io = Packages.io; -var JsonObject = io.vertx.core.json.JsonObject; -var JCloudFoundryAuth = Java.type('io.vertx.ext.auth.oauth2.providers.CloudFoundryAuth'); -var HttpClientOptions = Java.type('io.vertx.core.http.HttpClientOptions'); - -/** - - @class -*/ -var CloudFoundryAuth = function(j_val) { - - var j_cloudFoundryAuth = j_val; - var that = this; - - // A reference to the underlying Java delegate - // NOTE! This is an internal API and must not be used in user code. - // If you rely on this property your code is likely to break if we change it / remove it without warning. - this._jdel = j_cloudFoundryAuth; -}; - -CloudFoundryAuth._jclass = utils.getJavaClass("io.vertx.ext.auth.oauth2.providers.CloudFoundryAuth"); -CloudFoundryAuth._jtype = { - accept: function(obj) { - return CloudFoundryAuth._jclass.isInstance(obj._jdel); - }, - wrap: function(jdel) { - var obj = Object.create(CloudFoundryAuth.prototype, {}); - CloudFoundryAuth.apply(obj, arguments); - return obj; - }, - unwrap: function(obj) { - return obj._jdel; - } -}; -CloudFoundryAuth._create = function(jdel) { - var obj = Object.create(CloudFoundryAuth.prototype, {}); - CloudFoundryAuth.apply(obj, arguments); - return obj; -} -/** - Create a OAuth2Auth provider for CloudFoundry UAA - - @memberof module:vertx-auth-oauth2-js/cloud_foundry_auth - @param vertx {Vertx} - @param clientId {string} the client id given to you by CloudFoundry UAA - @param clientSecret {string} the client secret given to you by CloudFoundry UAA - @param uuaURL {string} the url to your UUA server instance - @param httpClientOptions {Object} custom http client options - @return {OAuth2Auth} - */ -CloudFoundryAuth.create = function() { - var __args = arguments; - if (__args.length === 4 && typeof __args[0] === 'object' && __args[0]._jdel && typeof __args[1] === 'string' && typeof __args[2] === 'string' && typeof __args[3] === 'string') { - return utils.convReturnVertxGen(OAuth2Auth, JCloudFoundryAuth["create(io.vertx.core.Vertx,java.lang.String,java.lang.String,java.lang.String)"](__args[0]._jdel, __args[1], __args[2], __args[3])); - }else if (__args.length === 5 && typeof __args[0] === 'object' && __args[0]._jdel && typeof __args[1] === 'string' && typeof __args[2] === 'string' && typeof __args[3] === 'string' && (typeof __args[4] === 'object' && __args[4] != null)) { - return utils.convReturnVertxGen(OAuth2Auth, JCloudFoundryAuth["create(io.vertx.core.Vertx,java.lang.String,java.lang.String,java.lang.String,io.vertx.core.http.HttpClientOptions)"](__args[0]._jdel, __args[1], __args[2], __args[3], __args[4] != null ? new HttpClientOptions(new JsonObject(Java.asJSONCompatible(__args[4]))) : null)); - } else throw new TypeError('function invoked with invalid arguments'); -}; - -module.exports = CloudFoundryAuth; \ No newline at end of file diff --git a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/cloud_foundry_uaa.js b/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/cloud_foundry_uaa.js deleted file mode 100644 index 5c776f928..000000000 --- a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/cloud_foundry_uaa.js +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2014 Red Hat, Inc. - * - * Red Hat 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. - */ - -/** @module vertx-auth-oauth2-js/cloud_foundry_uaa */ -var utils = require('vertx-js/util/utils'); -var Vertx = require('vertx-js/vertx'); -var OAuth2Auth = require('vertx-auth-oauth2-js/o_auth2_auth'); - -var io = Packages.io; -var JsonObject = io.vertx.core.json.JsonObject; -var JCloudFoundryUAA = Java.type('io.vertx.ext.auth.oauth2.providers.CloudFoundryUAA'); -var HttpClientOptions = Java.type('io.vertx.core.http.HttpClientOptions'); - -/** - - @class -*/ -var CloudFoundryUAA = function(j_val) { - - var j_cloudFoundryUAA = j_val; - var that = this; - - // A reference to the underlying Java delegate - // NOTE! This is an internal API and must not be used in user code. - // If you rely on this property your code is likely to break if we change it / remove it without warning. - this._jdel = j_cloudFoundryUAA; -}; - -CloudFoundryUAA._jclass = utils.getJavaClass("io.vertx.ext.auth.oauth2.providers.CloudFoundryUAA"); -CloudFoundryUAA._jtype = { - accept: function(obj) { - return CloudFoundryUAA._jclass.isInstance(obj._jdel); - }, - wrap: function(jdel) { - var obj = Object.create(CloudFoundryUAA.prototype, {}); - CloudFoundryUAA.apply(obj, arguments); - return obj; - }, - unwrap: function(obj) { - return obj._jdel; - } -}; -CloudFoundryUAA._create = function(jdel) { - var obj = Object.create(CloudFoundryUAA.prototype, {}); - CloudFoundryUAA.apply(obj, arguments); - return obj; -} -/** - Create a OAuth2Auth provider for CloudFoundry UAA - - @memberof module:vertx-auth-oauth2-js/cloud_foundry_uaa - @param vertx {Vertx} - @param clientId {string} the client id given to you by CloudFoundry UAA - @param clientSecret {string} the client secret given to you by CloudFoundry UAA - @param uuaURL {string} the url to your UUA server instance - @param httpClientOptions {Object} custom http client options - @return {OAuth2Auth} - */ -CloudFoundryUAA.create = function() { - var __args = arguments; - if (__args.length === 4 && typeof __args[0] === 'object' && __args[0]._jdel && typeof __args[1] === 'string' && typeof __args[2] === 'string' && typeof __args[3] === 'string') { - return utils.convReturnVertxGen(OAuth2Auth, JCloudFoundryUAA["create(io.vertx.core.Vertx,java.lang.String,java.lang.String,java.lang.String)"](__args[0]._jdel, __args[1], __args[2], __args[3])); - }else if (__args.length === 5 && typeof __args[0] === 'object' && __args[0]._jdel && typeof __args[1] === 'string' && typeof __args[2] === 'string' && typeof __args[3] === 'string' && (typeof __args[4] === 'object' && __args[4] != null)) { - return utils.convReturnVertxGen(OAuth2Auth, JCloudFoundryUAA["create(io.vertx.core.Vertx,java.lang.String,java.lang.String,java.lang.String,io.vertx.core.http.HttpClientOptions)"](__args[0]._jdel, __args[1], __args[2], __args[3], __args[4] != null ? new HttpClientOptions(new JsonObject(Java.asJSONCompatible(__args[4]))) : null)); - } else throw new TypeError('function invoked with invalid arguments'); -}; - -module.exports = CloudFoundryUAA; \ No newline at end of file diff --git a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/dropbox_auth.js b/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/dropbox_auth.js deleted file mode 100644 index 867ad66b0..000000000 --- a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/dropbox_auth.js +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2014 Red Hat, Inc. - * - * Red Hat 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. - */ - -/** @module vertx-auth-oauth2-js/dropbox_auth */ -var utils = require('vertx-js/util/utils'); -var Vertx = require('vertx-js/vertx'); -var OAuth2Auth = require('vertx-auth-oauth2-js/o_auth2_auth'); - -var io = Packages.io; -var JsonObject = io.vertx.core.json.JsonObject; -var JDropboxAuth = Java.type('io.vertx.ext.auth.oauth2.providers.DropboxAuth'); -var HttpClientOptions = Java.type('io.vertx.core.http.HttpClientOptions'); - -/** - - @class -*/ -var DropboxAuth = function(j_val) { - - var j_dropboxAuth = j_val; - var that = this; - - // A reference to the underlying Java delegate - // NOTE! This is an internal API and must not be used in user code. - // If you rely on this property your code is likely to break if we change it / remove it without warning. - this._jdel = j_dropboxAuth; -}; - -DropboxAuth._jclass = utils.getJavaClass("io.vertx.ext.auth.oauth2.providers.DropboxAuth"); -DropboxAuth._jtype = { - accept: function(obj) { - return DropboxAuth._jclass.isInstance(obj._jdel); - }, - wrap: function(jdel) { - var obj = Object.create(DropboxAuth.prototype, {}); - DropboxAuth.apply(obj, arguments); - return obj; - }, - unwrap: function(obj) { - return obj._jdel; - } -}; -DropboxAuth._create = function(jdel) { - var obj = Object.create(DropboxAuth.prototype, {}); - DropboxAuth.apply(obj, arguments); - return obj; -} -/** - Create a OAuth2Auth provider for Dropbox - - @memberof module:vertx-auth-oauth2-js/dropbox_auth - @param vertx {Vertx} - @param clientId {string} the client id given to you by Dropbox - @param clientSecret {string} the client secret given to you by Dropbox - @param httpClientOptions {Object} custom http client options - @return {OAuth2Auth} - */ -DropboxAuth.create = function() { - var __args = arguments; - if (__args.length === 3 && typeof __args[0] === 'object' && __args[0]._jdel && typeof __args[1] === 'string' && typeof __args[2] === 'string') { - return utils.convReturnVertxGen(OAuth2Auth, JDropboxAuth["create(io.vertx.core.Vertx,java.lang.String,java.lang.String)"](__args[0]._jdel, __args[1], __args[2])); - }else if (__args.length === 4 && typeof __args[0] === 'object' && __args[0]._jdel && typeof __args[1] === 'string' && typeof __args[2] === 'string' && (typeof __args[3] === 'object' && __args[3] != null)) { - return utils.convReturnVertxGen(OAuth2Auth, JDropboxAuth["create(io.vertx.core.Vertx,java.lang.String,java.lang.String,io.vertx.core.http.HttpClientOptions)"](__args[0]._jdel, __args[1], __args[2], __args[3] != null ? new HttpClientOptions(new JsonObject(Java.asJSONCompatible(__args[3]))) : null)); - } else throw new TypeError('function invoked with invalid arguments'); -}; - -module.exports = DropboxAuth; \ No newline at end of file diff --git a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/facebook_auth.js b/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/facebook_auth.js deleted file mode 100644 index ad6ef0229..000000000 --- a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/facebook_auth.js +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2014 Red Hat, Inc. - * - * Red Hat 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. - */ - -/** @module vertx-auth-oauth2-js/facebook_auth */ -var utils = require('vertx-js/util/utils'); -var Vertx = require('vertx-js/vertx'); -var OAuth2Auth = require('vertx-auth-oauth2-js/o_auth2_auth'); - -var io = Packages.io; -var JsonObject = io.vertx.core.json.JsonObject; -var JFacebookAuth = Java.type('io.vertx.ext.auth.oauth2.providers.FacebookAuth'); -var HttpClientOptions = Java.type('io.vertx.core.http.HttpClientOptions'); - -/** - - @class -*/ -var FacebookAuth = function(j_val) { - - var j_facebookAuth = j_val; - var that = this; - - // A reference to the underlying Java delegate - // NOTE! This is an internal API and must not be used in user code. - // If you rely on this property your code is likely to break if we change it / remove it without warning. - this._jdel = j_facebookAuth; -}; - -FacebookAuth._jclass = utils.getJavaClass("io.vertx.ext.auth.oauth2.providers.FacebookAuth"); -FacebookAuth._jtype = { - accept: function(obj) { - return FacebookAuth._jclass.isInstance(obj._jdel); - }, - wrap: function(jdel) { - var obj = Object.create(FacebookAuth.prototype, {}); - FacebookAuth.apply(obj, arguments); - return obj; - }, - unwrap: function(obj) { - return obj._jdel; - } -}; -FacebookAuth._create = function(jdel) { - var obj = Object.create(FacebookAuth.prototype, {}); - FacebookAuth.apply(obj, arguments); - return obj; -} -/** - Create a OAuth2Auth provider for Facebook - - @memberof module:vertx-auth-oauth2-js/facebook_auth - @param vertx {Vertx} - @param clientId {string} the client id given to you by Facebook - @param clientSecret {string} the client secret given to you by Facebook - @param httpClientOptions {Object} custom http client options - @return {OAuth2Auth} - */ -FacebookAuth.create = function() { - var __args = arguments; - if (__args.length === 3 && typeof __args[0] === 'object' && __args[0]._jdel && typeof __args[1] === 'string' && typeof __args[2] === 'string') { - return utils.convReturnVertxGen(OAuth2Auth, JFacebookAuth["create(io.vertx.core.Vertx,java.lang.String,java.lang.String)"](__args[0]._jdel, __args[1], __args[2])); - }else if (__args.length === 4 && typeof __args[0] === 'object' && __args[0]._jdel && typeof __args[1] === 'string' && typeof __args[2] === 'string' && (typeof __args[3] === 'object' && __args[3] != null)) { - return utils.convReturnVertxGen(OAuth2Auth, JFacebookAuth["create(io.vertx.core.Vertx,java.lang.String,java.lang.String,io.vertx.core.http.HttpClientOptions)"](__args[0]._jdel, __args[1], __args[2], __args[3] != null ? new HttpClientOptions(new JsonObject(Java.asJSONCompatible(__args[3]))) : null)); - } else throw new TypeError('function invoked with invalid arguments'); -}; - -module.exports = FacebookAuth; \ No newline at end of file diff --git a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/foursquare_auth.js b/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/foursquare_auth.js deleted file mode 100644 index b3142cf37..000000000 --- a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/foursquare_auth.js +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2014 Red Hat, Inc. - * - * Red Hat 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. - */ - -/** @module vertx-auth-oauth2-js/foursquare_auth */ -var utils = require('vertx-js/util/utils'); -var Vertx = require('vertx-js/vertx'); -var OAuth2Auth = require('vertx-auth-oauth2-js/o_auth2_auth'); - -var io = Packages.io; -var JsonObject = io.vertx.core.json.JsonObject; -var JFoursquareAuth = Java.type('io.vertx.ext.auth.oauth2.providers.FoursquareAuth'); -var HttpClientOptions = Java.type('io.vertx.core.http.HttpClientOptions'); - -/** - - @class -*/ -var FoursquareAuth = function(j_val) { - - var j_foursquareAuth = j_val; - var that = this; - - // A reference to the underlying Java delegate - // NOTE! This is an internal API and must not be used in user code. - // If you rely on this property your code is likely to break if we change it / remove it without warning. - this._jdel = j_foursquareAuth; -}; - -FoursquareAuth._jclass = utils.getJavaClass("io.vertx.ext.auth.oauth2.providers.FoursquareAuth"); -FoursquareAuth._jtype = { - accept: function(obj) { - return FoursquareAuth._jclass.isInstance(obj._jdel); - }, - wrap: function(jdel) { - var obj = Object.create(FoursquareAuth.prototype, {}); - FoursquareAuth.apply(obj, arguments); - return obj; - }, - unwrap: function(obj) { - return obj._jdel; - } -}; -FoursquareAuth._create = function(jdel) { - var obj = Object.create(FoursquareAuth.prototype, {}); - FoursquareAuth.apply(obj, arguments); - return obj; -} -/** - Create a OAuth2Auth provider for Dropbox - - @memberof module:vertx-auth-oauth2-js/foursquare_auth - @param vertx {Vertx} - @param clientId {string} the client id given to you by Dropbox - @param clientSecret {string} the client secret given to you by Dropbox - @param httpClientOptions {Object} custom http client options - @return {OAuth2Auth} - */ -FoursquareAuth.create = function() { - var __args = arguments; - if (__args.length === 3 && typeof __args[0] === 'object' && __args[0]._jdel && typeof __args[1] === 'string' && typeof __args[2] === 'string') { - return utils.convReturnVertxGen(OAuth2Auth, JFoursquareAuth["create(io.vertx.core.Vertx,java.lang.String,java.lang.String)"](__args[0]._jdel, __args[1], __args[2])); - }else if (__args.length === 4 && typeof __args[0] === 'object' && __args[0]._jdel && typeof __args[1] === 'string' && typeof __args[2] === 'string' && (typeof __args[3] === 'object' && __args[3] != null)) { - return utils.convReturnVertxGen(OAuth2Auth, JFoursquareAuth["create(io.vertx.core.Vertx,java.lang.String,java.lang.String,io.vertx.core.http.HttpClientOptions)"](__args[0]._jdel, __args[1], __args[2], __args[3] != null ? new HttpClientOptions(new JsonObject(Java.asJSONCompatible(__args[3]))) : null)); - } else throw new TypeError('function invoked with invalid arguments'); -}; - -module.exports = FoursquareAuth; \ No newline at end of file diff --git a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/github_auth.js b/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/github_auth.js deleted file mode 100644 index b6640da4a..000000000 --- a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/github_auth.js +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2014 Red Hat, Inc. - * - * Red Hat 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. - */ - -/** @module vertx-auth-oauth2-js/github_auth */ -var utils = require('vertx-js/util/utils'); -var Vertx = require('vertx-js/vertx'); -var OAuth2Auth = require('vertx-auth-oauth2-js/o_auth2_auth'); - -var io = Packages.io; -var JsonObject = io.vertx.core.json.JsonObject; -var JGithubAuth = Java.type('io.vertx.ext.auth.oauth2.providers.GithubAuth'); -var HttpClientOptions = Java.type('io.vertx.core.http.HttpClientOptions'); - -/** - - @class -*/ -var GithubAuth = function(j_val) { - - var j_githubAuth = j_val; - var that = this; - - // A reference to the underlying Java delegate - // NOTE! This is an internal API and must not be used in user code. - // If you rely on this property your code is likely to break if we change it / remove it without warning. - this._jdel = j_githubAuth; -}; - -GithubAuth._jclass = utils.getJavaClass("io.vertx.ext.auth.oauth2.providers.GithubAuth"); -GithubAuth._jtype = { - accept: function(obj) { - return GithubAuth._jclass.isInstance(obj._jdel); - }, - wrap: function(jdel) { - var obj = Object.create(GithubAuth.prototype, {}); - GithubAuth.apply(obj, arguments); - return obj; - }, - unwrap: function(obj) { - return obj._jdel; - } -}; -GithubAuth._create = function(jdel) { - var obj = Object.create(GithubAuth.prototype, {}); - GithubAuth.apply(obj, arguments); - return obj; -} -/** - Create a OAuth2Auth provider for Gtihub - - @memberof module:vertx-auth-oauth2-js/github_auth - @param vertx {Vertx} - @param clientId {string} the client id given to you by Github - @param clientSecret {string} the client secret given to you by Github - @param httpClientOptions {Object} custom http client options - @return {OAuth2Auth} - */ -GithubAuth.create = function() { - var __args = arguments; - if (__args.length === 3 && typeof __args[0] === 'object' && __args[0]._jdel && typeof __args[1] === 'string' && typeof __args[2] === 'string') { - return utils.convReturnVertxGen(OAuth2Auth, JGithubAuth["create(io.vertx.core.Vertx,java.lang.String,java.lang.String)"](__args[0]._jdel, __args[1], __args[2])); - }else if (__args.length === 4 && typeof __args[0] === 'object' && __args[0]._jdel && typeof __args[1] === 'string' && typeof __args[2] === 'string' && (typeof __args[3] === 'object' && __args[3] != null)) { - return utils.convReturnVertxGen(OAuth2Auth, JGithubAuth["create(io.vertx.core.Vertx,java.lang.String,java.lang.String,io.vertx.core.http.HttpClientOptions)"](__args[0]._jdel, __args[1], __args[2], __args[3] != null ? new HttpClientOptions(new JsonObject(Java.asJSONCompatible(__args[3]))) : null)); - } else throw new TypeError('function invoked with invalid arguments'); -}; - -module.exports = GithubAuth; \ No newline at end of file diff --git a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/google_auth.js b/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/google_auth.js deleted file mode 100644 index 5c08d1c85..000000000 --- a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/google_auth.js +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2014 Red Hat, Inc. - * - * Red Hat 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. - */ - -/** @module vertx-auth-oauth2-js/google_auth */ -var utils = require('vertx-js/util/utils'); -var Vertx = require('vertx-js/vertx'); -var OAuth2Auth = require('vertx-auth-oauth2-js/o_auth2_auth'); - -var io = Packages.io; -var JsonObject = io.vertx.core.json.JsonObject; -var JGoogleAuth = Java.type('io.vertx.ext.auth.oauth2.providers.GoogleAuth'); -var HttpClientOptions = Java.type('io.vertx.core.http.HttpClientOptions'); - -/** - - @class -*/ -var GoogleAuth = function(j_val) { - - var j_googleAuth = j_val; - var that = this; - - // A reference to the underlying Java delegate - // NOTE! This is an internal API and must not be used in user code. - // If you rely on this property your code is likely to break if we change it / remove it without warning. - this._jdel = j_googleAuth; -}; - -GoogleAuth._jclass = utils.getJavaClass("io.vertx.ext.auth.oauth2.providers.GoogleAuth"); -GoogleAuth._jtype = { - accept: function(obj) { - return GoogleAuth._jclass.isInstance(obj._jdel); - }, - wrap: function(jdel) { - var obj = Object.create(GoogleAuth.prototype, {}); - GoogleAuth.apply(obj, arguments); - return obj; - }, - unwrap: function(obj) { - return obj._jdel; - } -}; -GoogleAuth._create = function(jdel) { - var obj = Object.create(GoogleAuth.prototype, {}); - GoogleAuth.apply(obj, arguments); - return obj; -} -/** - Create a OAuth2Auth provider for Google - - @memberof module:vertx-auth-oauth2-js/google_auth - @param vertx {Vertx} - @param clientId {string} the client id given to you by Google - @param clientSecret {string} the client secret given to you by Google - @param httpClientOptions {Object} custom http client options - @return {OAuth2Auth} - */ -GoogleAuth.create = function() { - var __args = arguments; - if (__args.length === 2 && typeof __args[0] === 'object' && __args[0]._jdel && (typeof __args[1] === 'object' && __args[1] != null)) { - return utils.convReturnVertxGen(OAuth2Auth, JGoogleAuth["create(io.vertx.core.Vertx,io.vertx.core.json.JsonObject)"](__args[0]._jdel, utils.convParamJsonObject(__args[1]))); - }else if (__args.length === 3 && typeof __args[0] === 'object' && __args[0]._jdel && typeof __args[1] === 'string' && typeof __args[2] === 'string') { - return utils.convReturnVertxGen(OAuth2Auth, JGoogleAuth["create(io.vertx.core.Vertx,java.lang.String,java.lang.String)"](__args[0]._jdel, __args[1], __args[2])); - }else if (__args.length === 3 && typeof __args[0] === 'object' && __args[0]._jdel && (typeof __args[1] === 'object' && __args[1] != null) && (typeof __args[2] === 'object' && __args[2] != null)) { - return utils.convReturnVertxGen(OAuth2Auth, JGoogleAuth["create(io.vertx.core.Vertx,io.vertx.core.json.JsonObject,io.vertx.core.http.HttpClientOptions)"](__args[0]._jdel, utils.convParamJsonObject(__args[1]), __args[2] != null ? new HttpClientOptions(new JsonObject(Java.asJSONCompatible(__args[2]))) : null)); - }else if (__args.length === 4 && typeof __args[0] === 'object' && __args[0]._jdel && typeof __args[1] === 'string' && typeof __args[2] === 'string' && (typeof __args[3] === 'object' && __args[3] != null)) { - return utils.convReturnVertxGen(OAuth2Auth, JGoogleAuth["create(io.vertx.core.Vertx,java.lang.String,java.lang.String,io.vertx.core.http.HttpClientOptions)"](__args[0]._jdel, __args[1], __args[2], __args[3] != null ? new HttpClientOptions(new JsonObject(Java.asJSONCompatible(__args[3]))) : null)); - } else throw new TypeError('function invoked with invalid arguments'); -}; - -module.exports = GoogleAuth; \ No newline at end of file diff --git a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/heroku_auth.js b/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/heroku_auth.js deleted file mode 100644 index 1fdde3616..000000000 --- a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/heroku_auth.js +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2014 Red Hat, Inc. - * - * Red Hat 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. - */ - -/** @module vertx-auth-oauth2-js/heroku_auth */ -var utils = require('vertx-js/util/utils'); -var Vertx = require('vertx-js/vertx'); -var OAuth2Auth = require('vertx-auth-oauth2-js/o_auth2_auth'); - -var io = Packages.io; -var JsonObject = io.vertx.core.json.JsonObject; -var JHerokuAuth = Java.type('io.vertx.ext.auth.oauth2.providers.HerokuAuth'); -var HttpClientOptions = Java.type('io.vertx.core.http.HttpClientOptions'); - -/** - - @class -*/ -var HerokuAuth = function(j_val) { - - var j_herokuAuth = j_val; - var that = this; - - // A reference to the underlying Java delegate - // NOTE! This is an internal API and must not be used in user code. - // If you rely on this property your code is likely to break if we change it / remove it without warning. - this._jdel = j_herokuAuth; -}; - -HerokuAuth._jclass = utils.getJavaClass("io.vertx.ext.auth.oauth2.providers.HerokuAuth"); -HerokuAuth._jtype = { - accept: function(obj) { - return HerokuAuth._jclass.isInstance(obj._jdel); - }, - wrap: function(jdel) { - var obj = Object.create(HerokuAuth.prototype, {}); - HerokuAuth.apply(obj, arguments); - return obj; - }, - unwrap: function(obj) { - return obj._jdel; - } -}; -HerokuAuth._create = function(jdel) { - var obj = Object.create(HerokuAuth.prototype, {}); - HerokuAuth.apply(obj, arguments); - return obj; -} -/** - Create a OAuth2Auth provider for live.com - - @memberof module:vertx-auth-oauth2-js/heroku_auth - @param vertx {Vertx} - @param clientId {string} the client id given to you by Heroku - @param clientSecret {string} the client secret given to you by Heroku - @param httpClientOptions {Object} custom http client options - @return {OAuth2Auth} - */ -HerokuAuth.create = function() { - var __args = arguments; - if (__args.length === 3 && typeof __args[0] === 'object' && __args[0]._jdel && typeof __args[1] === 'string' && typeof __args[2] === 'string') { - return utils.convReturnVertxGen(OAuth2Auth, JHerokuAuth["create(io.vertx.core.Vertx,java.lang.String,java.lang.String)"](__args[0]._jdel, __args[1], __args[2])); - }else if (__args.length === 4 && typeof __args[0] === 'object' && __args[0]._jdel && typeof __args[1] === 'string' && typeof __args[2] === 'string' && (typeof __args[3] === 'object' && __args[3] != null)) { - return utils.convReturnVertxGen(OAuth2Auth, JHerokuAuth["create(io.vertx.core.Vertx,java.lang.String,java.lang.String,io.vertx.core.http.HttpClientOptions)"](__args[0]._jdel, __args[1], __args[2], __args[3] != null ? new HttpClientOptions(new JsonObject(Java.asJSONCompatible(__args[3]))) : null)); - } else throw new TypeError('function invoked with invalid arguments'); -}; - -module.exports = HerokuAuth; \ No newline at end of file diff --git a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/instagram_auth.js b/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/instagram_auth.js deleted file mode 100644 index b02d88390..000000000 --- a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/instagram_auth.js +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2014 Red Hat, Inc. - * - * Red Hat 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. - */ - -/** @module vertx-auth-oauth2-js/instagram_auth */ -var utils = require('vertx-js/util/utils'); -var Vertx = require('vertx-js/vertx'); -var OAuth2Auth = require('vertx-auth-oauth2-js/o_auth2_auth'); - -var io = Packages.io; -var JsonObject = io.vertx.core.json.JsonObject; -var JInstagramAuth = Java.type('io.vertx.ext.auth.oauth2.providers.InstagramAuth'); -var HttpClientOptions = Java.type('io.vertx.core.http.HttpClientOptions'); - -/** - - @class -*/ -var InstagramAuth = function(j_val) { - - var j_instagramAuth = j_val; - var that = this; - - // A reference to the underlying Java delegate - // NOTE! This is an internal API and must not be used in user code. - // If you rely on this property your code is likely to break if we change it / remove it without warning. - this._jdel = j_instagramAuth; -}; - -InstagramAuth._jclass = utils.getJavaClass("io.vertx.ext.auth.oauth2.providers.InstagramAuth"); -InstagramAuth._jtype = { - accept: function(obj) { - return InstagramAuth._jclass.isInstance(obj._jdel); - }, - wrap: function(jdel) { - var obj = Object.create(InstagramAuth.prototype, {}); - InstagramAuth.apply(obj, arguments); - return obj; - }, - unwrap: function(obj) { - return obj._jdel; - } -}; -InstagramAuth._create = function(jdel) { - var obj = Object.create(InstagramAuth.prototype, {}); - InstagramAuth.apply(obj, arguments); - return obj; -} -/** - Create a OAuth2Auth provider for Instagram - - @memberof module:vertx-auth-oauth2-js/instagram_auth - @param vertx {Vertx} - @param clientId {string} the client id given to you by Instagram - @param clientSecret {string} the client secret given to you by Instagram - @param httpClientOptions {Object} custom http client options - @return {OAuth2Auth} - */ -InstagramAuth.create = function() { - var __args = arguments; - if (__args.length === 3 && typeof __args[0] === 'object' && __args[0]._jdel && typeof __args[1] === 'string' && typeof __args[2] === 'string') { - return utils.convReturnVertxGen(OAuth2Auth, JInstagramAuth["create(io.vertx.core.Vertx,java.lang.String,java.lang.String)"](__args[0]._jdel, __args[1], __args[2])); - }else if (__args.length === 4 && typeof __args[0] === 'object' && __args[0]._jdel && typeof __args[1] === 'string' && typeof __args[2] === 'string' && (typeof __args[3] === 'object' && __args[3] != null)) { - return utils.convReturnVertxGen(OAuth2Auth, JInstagramAuth["create(io.vertx.core.Vertx,java.lang.String,java.lang.String,io.vertx.core.http.HttpClientOptions)"](__args[0]._jdel, __args[1], __args[2], __args[3] != null ? new HttpClientOptions(new JsonObject(Java.asJSONCompatible(__args[3]))) : null)); - } else throw new TypeError('function invoked with invalid arguments'); -}; - -module.exports = InstagramAuth; \ No newline at end of file diff --git a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/keycloak_auth.js b/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/keycloak_auth.js deleted file mode 100644 index 31143f783..000000000 --- a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/keycloak_auth.js +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2014 Red Hat, Inc. - * - * Red Hat 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. - */ - -/** @module vertx-auth-oauth2-js/keycloak_auth */ -var utils = require('vertx-js/util/utils'); -var Vertx = require('vertx-js/vertx'); -var OAuth2Auth = require('vertx-auth-oauth2-js/o_auth2_auth'); - -var io = Packages.io; -var JsonObject = io.vertx.core.json.JsonObject; -var JKeycloakAuth = Java.type('io.vertx.ext.auth.oauth2.providers.KeycloakAuth'); -var HttpClientOptions = Java.type('io.vertx.core.http.HttpClientOptions'); - -/** - - @class -*/ -var KeycloakAuth = function(j_val) { - - var j_keycloakAuth = j_val; - var that = this; - - // A reference to the underlying Java delegate - // NOTE! This is an internal API and must not be used in user code. - // If you rely on this property your code is likely to break if we change it / remove it without warning. - this._jdel = j_keycloakAuth; -}; - -KeycloakAuth._jclass = utils.getJavaClass("io.vertx.ext.auth.oauth2.providers.KeycloakAuth"); -KeycloakAuth._jtype = { - accept: function(obj) { - return KeycloakAuth._jclass.isInstance(obj._jdel); - }, - wrap: function(jdel) { - var obj = Object.create(KeycloakAuth.prototype, {}); - KeycloakAuth.apply(obj, arguments); - return obj; - }, - unwrap: function(obj) { - return obj._jdel; - } -}; -KeycloakAuth._create = function(jdel) { - var obj = Object.create(KeycloakAuth.prototype, {}); - KeycloakAuth.apply(obj, arguments); - return obj; -} -/** - Create a OAuth2Auth provider for Keycloak - - @memberof module:vertx-auth-oauth2-js/keycloak_auth - @param vertx {Vertx} - @param flow {Object} the oauth2 flow to use - @param config {Object} the json config file exported from Keycloak admin console - @param httpClientOptions {Object} custom http client options - @return {OAuth2Auth} - */ -KeycloakAuth.create = function() { - var __args = arguments; - if (__args.length === 2 && typeof __args[0] === 'object' && __args[0]._jdel && (typeof __args[1] === 'object' && __args[1] != null)) { - return utils.convReturnVertxGen(OAuth2Auth, JKeycloakAuth["create(io.vertx.core.Vertx,io.vertx.core.json.JsonObject)"](__args[0]._jdel, utils.convParamJsonObject(__args[1]))); - }else if (__args.length === 3 && typeof __args[0] === 'object' && __args[0]._jdel && typeof __args[1] === 'string' && (typeof __args[2] === 'object' && __args[2] != null)) { - return utils.convReturnVertxGen(OAuth2Auth, JKeycloakAuth["create(io.vertx.core.Vertx,io.vertx.ext.auth.oauth2.OAuth2FlowType,io.vertx.core.json.JsonObject)"](__args[0]._jdel, io.vertx.ext.auth.oauth2.OAuth2FlowType.valueOf(__args[1]), utils.convParamJsonObject(__args[2]))); - }else if (__args.length === 3 && typeof __args[0] === 'object' && __args[0]._jdel && (typeof __args[1] === 'object' && __args[1] != null) && (typeof __args[2] === 'object' && __args[2] != null)) { - return utils.convReturnVertxGen(OAuth2Auth, JKeycloakAuth["create(io.vertx.core.Vertx,io.vertx.core.json.JsonObject,io.vertx.core.http.HttpClientOptions)"](__args[0]._jdel, utils.convParamJsonObject(__args[1]), __args[2] != null ? new HttpClientOptions(new JsonObject(Java.asJSONCompatible(__args[2]))) : null)); - }else if (__args.length === 4 && typeof __args[0] === 'object' && __args[0]._jdel && typeof __args[1] === 'string' && (typeof __args[2] === 'object' && __args[2] != null) && (typeof __args[3] === 'object' && __args[3] != null)) { - return utils.convReturnVertxGen(OAuth2Auth, JKeycloakAuth["create(io.vertx.core.Vertx,io.vertx.ext.auth.oauth2.OAuth2FlowType,io.vertx.core.json.JsonObject,io.vertx.core.http.HttpClientOptions)"](__args[0]._jdel, io.vertx.ext.auth.oauth2.OAuth2FlowType.valueOf(__args[1]), utils.convParamJsonObject(__args[2]), __args[3] != null ? new HttpClientOptions(new JsonObject(Java.asJSONCompatible(__args[3]))) : null)); - } else throw new TypeError('function invoked with invalid arguments'); -}; - -module.exports = KeycloakAuth; \ No newline at end of file diff --git a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/keycloak_helper.js b/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/keycloak_helper.js deleted file mode 100644 index bbc1ea445..000000000 --- a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/keycloak_helper.js +++ /dev/null @@ -1,234 +0,0 @@ -/* - * Copyright 2014 Red Hat, Inc. - * - * Red Hat 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. - */ - -/** @module vertx-auth-oauth2-js/keycloak_helper */ -var utils = require('vertx-js/util/utils'); - -var io = Packages.io; -var JsonObject = io.vertx.core.json.JsonObject; -var JKeycloakHelper = Java.type('io.vertx.ext.auth.oauth2.KeycloakHelper'); - -/** - Helper class for processing Keycloak principal. - - @class -*/ -var KeycloakHelper = function(j_val) { - - var j_keycloakHelper = j_val; - var that = this; - - // A reference to the underlying Java delegate - // NOTE! This is an internal API and must not be used in user code. - // If you rely on this property your code is likely to break if we change it / remove it without warning. - this._jdel = j_keycloakHelper; -}; - -KeycloakHelper._jclass = utils.getJavaClass("io.vertx.ext.auth.oauth2.KeycloakHelper"); -KeycloakHelper._jtype = { - accept: function(obj) { - return KeycloakHelper._jclass.isInstance(obj._jdel); - }, - wrap: function(jdel) { - var obj = Object.create(KeycloakHelper.prototype, {}); - KeycloakHelper.apply(obj, arguments); - return obj; - }, - unwrap: function(obj) { - return obj._jdel; - } -}; -KeycloakHelper._create = function(jdel) { - var obj = Object.create(KeycloakHelper.prototype, {}); - KeycloakHelper.apply(obj, arguments); - return obj; -} -/** - Get raw `id_token` string from the principal. - - @memberof module:vertx-auth-oauth2-js/keycloak_helper - @param principal {Object} user principal - @return {string} the raw id token string - */ -KeycloakHelper.rawIdToken = function(principal) { - var __args = arguments; - if (__args.length === 1 && (typeof __args[0] === 'object' && __args[0] != null)) { - return JKeycloakHelper["rawIdToken(io.vertx.core.json.JsonObject)"](utils.convParamJsonObject(principal)); - } else throw new TypeError('function invoked with invalid arguments'); -}; - -/** - Get decoded `id_token` from the principal. - - @memberof module:vertx-auth-oauth2-js/keycloak_helper - @param principal {Object} user principal - @return {Object} the id token - */ -KeycloakHelper.idToken = function(principal) { - var __args = arguments; - if (__args.length === 1 && (typeof __args[0] === 'object' && __args[0] != null)) { - return utils.convReturnJson(JKeycloakHelper["idToken(io.vertx.core.json.JsonObject)"](utils.convParamJsonObject(principal))); - } else throw new TypeError('function invoked with invalid arguments'); -}; - -/** - Get raw `access_token` string from the principal. - - @memberof module:vertx-auth-oauth2-js/keycloak_helper - @param principal {Object} user principal - @return {string} the raw access token string - */ -KeycloakHelper.rawAccessToken = function(principal) { - var __args = arguments; - if (__args.length === 1 && (typeof __args[0] === 'object' && __args[0] != null)) { - return JKeycloakHelper["rawAccessToken(io.vertx.core.json.JsonObject)"](utils.convParamJsonObject(principal)); - } else throw new TypeError('function invoked with invalid arguments'); -}; - -/** - Get decoded `access_token` from the principal. - - @memberof module:vertx-auth-oauth2-js/keycloak_helper - @param principal {Object} user principal - @return {Object} the access token - */ -KeycloakHelper.accessToken = function(principal) { - var __args = arguments; - if (__args.length === 1 && (typeof __args[0] === 'object' && __args[0] != null)) { - return utils.convReturnJson(JKeycloakHelper["accessToken(io.vertx.core.json.JsonObject)"](utils.convParamJsonObject(principal))); - } else throw new TypeError('function invoked with invalid arguments'); -}; - -/** - - @memberof module:vertx-auth-oauth2-js/keycloak_helper - @param principal {Object} - @return {number} - */ -KeycloakHelper.authTime = function(principal) { - var __args = arguments; - if (__args.length === 1 && (typeof __args[0] === 'object' && __args[0] != null)) { - return JKeycloakHelper["authTime(io.vertx.core.json.JsonObject)"](utils.convParamJsonObject(principal)); - } else throw new TypeError('function invoked with invalid arguments'); -}; - -/** - - @memberof module:vertx-auth-oauth2-js/keycloak_helper - @param principal {Object} - @return {string} - */ -KeycloakHelper.sessionState = function(principal) { - var __args = arguments; - if (__args.length === 1 && (typeof __args[0] === 'object' && __args[0] != null)) { - return JKeycloakHelper["sessionState(io.vertx.core.json.JsonObject)"](utils.convParamJsonObject(principal)); - } else throw new TypeError('function invoked with invalid arguments'); -}; - -/** - - @memberof module:vertx-auth-oauth2-js/keycloak_helper - @param principal {Object} - @return {string} - */ -KeycloakHelper.acr = function(principal) { - var __args = arguments; - if (__args.length === 1 && (typeof __args[0] === 'object' && __args[0] != null)) { - return JKeycloakHelper["acr(io.vertx.core.json.JsonObject)"](utils.convParamJsonObject(principal)); - } else throw new TypeError('function invoked with invalid arguments'); -}; - -/** - - @memberof module:vertx-auth-oauth2-js/keycloak_helper - @param principal {Object} - @return {string} - */ -KeycloakHelper.name = function(principal) { - var __args = arguments; - if (__args.length === 1 && (typeof __args[0] === 'object' && __args[0] != null)) { - return JKeycloakHelper["name(io.vertx.core.json.JsonObject)"](utils.convParamJsonObject(principal)); - } else throw new TypeError('function invoked with invalid arguments'); -}; - -/** - - @memberof module:vertx-auth-oauth2-js/keycloak_helper - @param principal {Object} - @return {string} - */ -KeycloakHelper.email = function(principal) { - var __args = arguments; - if (__args.length === 1 && (typeof __args[0] === 'object' && __args[0] != null)) { - return JKeycloakHelper["email(io.vertx.core.json.JsonObject)"](utils.convParamJsonObject(principal)); - } else throw new TypeError('function invoked with invalid arguments'); -}; - -/** - - @memberof module:vertx-auth-oauth2-js/keycloak_helper - @param principal {Object} - @return {string} - */ -KeycloakHelper.preferredUsername = function(principal) { - var __args = arguments; - if (__args.length === 1 && (typeof __args[0] === 'object' && __args[0] != null)) { - return JKeycloakHelper["preferredUsername(io.vertx.core.json.JsonObject)"](utils.convParamJsonObject(principal)); - } else throw new TypeError('function invoked with invalid arguments'); -}; - -/** - - @memberof module:vertx-auth-oauth2-js/keycloak_helper - @param principal {Object} - @return {string} - */ -KeycloakHelper.nickName = function(principal) { - var __args = arguments; - if (__args.length === 1 && (typeof __args[0] === 'object' && __args[0] != null)) { - return JKeycloakHelper["nickName(io.vertx.core.json.JsonObject)"](utils.convParamJsonObject(principal)); - } else throw new TypeError('function invoked with invalid arguments'); -}; - -/** - - @memberof module:vertx-auth-oauth2-js/keycloak_helper - @param principal {Object} - @return {Array.} - */ -KeycloakHelper.allowedOrigins = function(principal) { - var __args = arguments; - if (__args.length === 1 && (typeof __args[0] === 'object' && __args[0] != null)) { - return utils.convReturnSet(JKeycloakHelper["allowedOrigins(io.vertx.core.json.JsonObject)"](utils.convParamJsonObject(principal))); - } else throw new TypeError('function invoked with invalid arguments'); -}; - -/** - Parse the token string with base64 decoder. - This will only obtain the "payload" part of the token. - - @memberof module:vertx-auth-oauth2-js/keycloak_helper - @param token {string} token string - @return {Object} token payload json object - */ -KeycloakHelper.parseToken = function(token) { - var __args = arguments; - if (__args.length === 1 && typeof __args[0] === 'string') { - return utils.convReturnJson(JKeycloakHelper["parseToken(java.lang.String)"](token)); - } else throw new TypeError('function invoked with invalid arguments'); -}; - -module.exports = KeycloakHelper; \ No newline at end of file diff --git a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/linked_in_auth.js b/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/linked_in_auth.js deleted file mode 100644 index 9356c4c1d..000000000 --- a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/linked_in_auth.js +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2014 Red Hat, Inc. - * - * Red Hat 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. - */ - -/** @module vertx-auth-oauth2-js/linked_in_auth */ -var utils = require('vertx-js/util/utils'); -var Vertx = require('vertx-js/vertx'); -var OAuth2Auth = require('vertx-auth-oauth2-js/o_auth2_auth'); - -var io = Packages.io; -var JsonObject = io.vertx.core.json.JsonObject; -var JLinkedInAuth = Java.type('io.vertx.ext.auth.oauth2.providers.LinkedInAuth'); -var HttpClientOptions = Java.type('io.vertx.core.http.HttpClientOptions'); - -/** - - @class -*/ -var LinkedInAuth = function(j_val) { - - var j_linkedInAuth = j_val; - var that = this; - - // A reference to the underlying Java delegate - // NOTE! This is an internal API and must not be used in user code. - // If you rely on this property your code is likely to break if we change it / remove it without warning. - this._jdel = j_linkedInAuth; -}; - -LinkedInAuth._jclass = utils.getJavaClass("io.vertx.ext.auth.oauth2.providers.LinkedInAuth"); -LinkedInAuth._jtype = { - accept: function(obj) { - return LinkedInAuth._jclass.isInstance(obj._jdel); - }, - wrap: function(jdel) { - var obj = Object.create(LinkedInAuth.prototype, {}); - LinkedInAuth.apply(obj, arguments); - return obj; - }, - unwrap: function(obj) { - return obj._jdel; - } -}; -LinkedInAuth._create = function(jdel) { - var obj = Object.create(LinkedInAuth.prototype, {}); - LinkedInAuth.apply(obj, arguments); - return obj; -} -/** - Create a OAuth2Auth provider for LinkedIn - - @memberof module:vertx-auth-oauth2-js/linked_in_auth - @param vertx {Vertx} - @param clientId {string} the client id given to you by LinkedIn - @param clientSecret {string} the client secret given to you by LinkedIn - @param httpClientOptions {Object} custom http client options - @return {OAuth2Auth} - */ -LinkedInAuth.create = function() { - var __args = arguments; - if (__args.length === 3 && typeof __args[0] === 'object' && __args[0]._jdel && typeof __args[1] === 'string' && typeof __args[2] === 'string') { - return utils.convReturnVertxGen(OAuth2Auth, JLinkedInAuth["create(io.vertx.core.Vertx,java.lang.String,java.lang.String)"](__args[0]._jdel, __args[1], __args[2])); - }else if (__args.length === 4 && typeof __args[0] === 'object' && __args[0]._jdel && typeof __args[1] === 'string' && typeof __args[2] === 'string' && (typeof __args[3] === 'object' && __args[3] != null)) { - return utils.convReturnVertxGen(OAuth2Auth, JLinkedInAuth["create(io.vertx.core.Vertx,java.lang.String,java.lang.String,io.vertx.core.http.HttpClientOptions)"](__args[0]._jdel, __args[1], __args[2], __args[3] != null ? new HttpClientOptions(new JsonObject(Java.asJSONCompatible(__args[3]))) : null)); - } else throw new TypeError('function invoked with invalid arguments'); -}; - -module.exports = LinkedInAuth; \ No newline at end of file diff --git a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/live_auth.js b/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/live_auth.js deleted file mode 100644 index e55bc6992..000000000 --- a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/live_auth.js +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2014 Red Hat, Inc. - * - * Red Hat 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. - */ - -/** @module vertx-auth-oauth2-js/live_auth */ -var utils = require('vertx-js/util/utils'); -var Vertx = require('vertx-js/vertx'); -var OAuth2Auth = require('vertx-auth-oauth2-js/o_auth2_auth'); - -var io = Packages.io; -var JsonObject = io.vertx.core.json.JsonObject; -var JLiveAuth = Java.type('io.vertx.ext.auth.oauth2.providers.LiveAuth'); -var HttpClientOptions = Java.type('io.vertx.core.http.HttpClientOptions'); - -/** - - @class -*/ -var LiveAuth = function(j_val) { - - var j_liveAuth = j_val; - var that = this; - - // A reference to the underlying Java delegate - // NOTE! This is an internal API and must not be used in user code. - // If you rely on this property your code is likely to break if we change it / remove it without warning. - this._jdel = j_liveAuth; -}; - -LiveAuth._jclass = utils.getJavaClass("io.vertx.ext.auth.oauth2.providers.LiveAuth"); -LiveAuth._jtype = { - accept: function(obj) { - return LiveAuth._jclass.isInstance(obj._jdel); - }, - wrap: function(jdel) { - var obj = Object.create(LiveAuth.prototype, {}); - LiveAuth.apply(obj, arguments); - return obj; - }, - unwrap: function(obj) { - return obj._jdel; - } -}; -LiveAuth._create = function(jdel) { - var obj = Object.create(LiveAuth.prototype, {}); - LiveAuth.apply(obj, arguments); - return obj; -} -/** - Create a OAuth2Auth provider for live.com - - @memberof module:vertx-auth-oauth2-js/live_auth - @param vertx {Vertx} - @param clientId {string} the client id given to you by live.com - @param clientSecret {string} the client secret given to you by live.com - @param httpClientOptions {Object} custom http client options - @return {OAuth2Auth} - */ -LiveAuth.create = function() { - var __args = arguments; - if (__args.length === 3 && typeof __args[0] === 'object' && __args[0]._jdel && typeof __args[1] === 'string' && typeof __args[2] === 'string') { - return utils.convReturnVertxGen(OAuth2Auth, JLiveAuth["create(io.vertx.core.Vertx,java.lang.String,java.lang.String)"](__args[0]._jdel, __args[1], __args[2])); - }else if (__args.length === 4 && typeof __args[0] === 'object' && __args[0]._jdel && typeof __args[1] === 'string' && typeof __args[2] === 'string' && (typeof __args[3] === 'object' && __args[3] != null)) { - return utils.convReturnVertxGen(OAuth2Auth, JLiveAuth["create(io.vertx.core.Vertx,java.lang.String,java.lang.String,io.vertx.core.http.HttpClientOptions)"](__args[0]._jdel, __args[1], __args[2], __args[3] != null ? new HttpClientOptions(new JsonObject(Java.asJSONCompatible(__args[3]))) : null)); - } else throw new TypeError('function invoked with invalid arguments'); -}; - -module.exports = LiveAuth; \ No newline at end of file diff --git a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/mailchimp_auth.js b/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/mailchimp_auth.js deleted file mode 100644 index 3ed546536..000000000 --- a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/mailchimp_auth.js +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2014 Red Hat, Inc. - * - * Red Hat 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. - */ - -/** @module vertx-auth-oauth2-js/mailchimp_auth */ -var utils = require('vertx-js/util/utils'); -var Vertx = require('vertx-js/vertx'); -var OAuth2Auth = require('vertx-auth-oauth2-js/o_auth2_auth'); - -var io = Packages.io; -var JsonObject = io.vertx.core.json.JsonObject; -var JMailchimpAuth = Java.type('io.vertx.ext.auth.oauth2.providers.MailchimpAuth'); -var HttpClientOptions = Java.type('io.vertx.core.http.HttpClientOptions'); - -/** - - @class -*/ -var MailchimpAuth = function(j_val) { - - var j_mailchimpAuth = j_val; - var that = this; - - // A reference to the underlying Java delegate - // NOTE! This is an internal API and must not be used in user code. - // If you rely on this property your code is likely to break if we change it / remove it without warning. - this._jdel = j_mailchimpAuth; -}; - -MailchimpAuth._jclass = utils.getJavaClass("io.vertx.ext.auth.oauth2.providers.MailchimpAuth"); -MailchimpAuth._jtype = { - accept: function(obj) { - return MailchimpAuth._jclass.isInstance(obj._jdel); - }, - wrap: function(jdel) { - var obj = Object.create(MailchimpAuth.prototype, {}); - MailchimpAuth.apply(obj, arguments); - return obj; - }, - unwrap: function(obj) { - return obj._jdel; - } -}; -MailchimpAuth._create = function(jdel) { - var obj = Object.create(MailchimpAuth.prototype, {}); - MailchimpAuth.apply(obj, arguments); - return obj; -} -/** - Create a OAuth2Auth provider for Dropbox - - @memberof module:vertx-auth-oauth2-js/mailchimp_auth - @param vertx {Vertx} - @param clientId {string} the client id given to you by Mailchimp - @param clientSecret {string} the client secret given to you by Mailchimp - @param httpClientOptions {Object} custom http client options - @return {OAuth2Auth} - */ -MailchimpAuth.create = function() { - var __args = arguments; - if (__args.length === 3 && typeof __args[0] === 'object' && __args[0]._jdel && typeof __args[1] === 'string' && typeof __args[2] === 'string') { - return utils.convReturnVertxGen(OAuth2Auth, JMailchimpAuth["create(io.vertx.core.Vertx,java.lang.String,java.lang.String)"](__args[0]._jdel, __args[1], __args[2])); - }else if (__args.length === 4 && typeof __args[0] === 'object' && __args[0]._jdel && typeof __args[1] === 'string' && typeof __args[2] === 'string' && (typeof __args[3] === 'object' && __args[3] != null)) { - return utils.convReturnVertxGen(OAuth2Auth, JMailchimpAuth["create(io.vertx.core.Vertx,java.lang.String,java.lang.String,io.vertx.core.http.HttpClientOptions)"](__args[0]._jdel, __args[1], __args[2], __args[3] != null ? new HttpClientOptions(new JsonObject(Java.asJSONCompatible(__args[3]))) : null)); - } else throw new TypeError('function invoked with invalid arguments'); -}; - -module.exports = MailchimpAuth; \ No newline at end of file diff --git a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/o_auth2_auth.js b/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/o_auth2_auth.js deleted file mode 100644 index cab253801..000000000 --- a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/o_auth2_auth.js +++ /dev/null @@ -1,267 +0,0 @@ -/* - * Copyright 2014 Red Hat, Inc. - * - * Red Hat 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. - */ - -/** @module vertx-auth-oauth2-js/o_auth2_auth */ -var utils = require('vertx-js/util/utils'); -var User = require('vertx-auth-common-js/user'); -var Vertx = require('vertx-js/vertx'); -var AccessToken = require('vertx-auth-oauth2-js/access_token'); -var AuthProvider = require('vertx-auth-common-js/auth_provider'); - -var io = Packages.io; -var JsonObject = io.vertx.core.json.JsonObject; -var JOAuth2Auth = Java.type('io.vertx.ext.auth.oauth2.OAuth2Auth'); -var OAuth2ClientOptions = Java.type('io.vertx.ext.auth.oauth2.OAuth2ClientOptions'); - -/** - - @class -*/ -var OAuth2Auth = function(j_val) { - - var j_oAuth2Auth = j_val; - var that = this; - AuthProvider.call(this, j_val); - - /** - - @public - @param arg0 {Object} - @param arg1 {function} - */ - this.authenticate = function(arg0, arg1) { - var __args = arguments; - if (__args.length === 2 && (typeof __args[0] === 'object' && __args[0] != null) && typeof __args[1] === 'function') { - j_oAuth2Auth["authenticate(io.vertx.core.json.JsonObject,io.vertx.core.Handler)"](utils.convParamJsonObject(arg0), function(ar) { - if (ar.succeeded()) { - arg1(utils.convReturnVertxGen(User, ar.result()), null); - } else { - arg1(null, ar.cause()); - } - }); - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - Generate a redirect URL to the authN/Z backend. It only applies to auth_code flow. - - @public - @param params {Object} - @return {string} - */ - this.authorizeURL = function(params) { - var __args = arguments; - if (__args.length === 1 && (typeof __args[0] === 'object' && __args[0] != null)) { - return j_oAuth2Auth["authorizeURL(io.vertx.core.json.JsonObject)"](utils.convParamJsonObject(params)); - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - Returns the Access Token object. - - @public - @param params {Object} - JSON with the options, each flow requires different options. - @param handler {function} - The handler returning the results. - */ - this.getToken = function(params, handler) { - var __args = arguments; - if (__args.length === 2 && (typeof __args[0] === 'object' && __args[0] != null) && typeof __args[1] === 'function') { - j_oAuth2Auth["getToken(io.vertx.core.json.JsonObject,io.vertx.core.Handler)"](utils.convParamJsonObject(params), function(ar) { - if (ar.succeeded()) { - handler(utils.convReturnVertxGen(AccessToken, ar.result()), null); - } else { - handler(null, ar.cause()); - } - }); - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - Call OAuth2 APIs. - - @public - @param method {Object} HttpMethod - @param path {string} target path - @param params {Object} parameters - @param handler {function} handler - @return {OAuth2Auth} self - */ - this.api = function(method, path, params, handler) { - var __args = arguments; - if (__args.length === 4 && typeof __args[0] === 'string' && typeof __args[1] === 'string' && (typeof __args[2] === 'object' && __args[2] != null) && typeof __args[3] === 'function') { - j_oAuth2Auth["api(io.vertx.core.http.HttpMethod,java.lang.String,io.vertx.core.json.JsonObject,io.vertx.core.Handler)"](io.vertx.core.http.HttpMethod.valueOf(method), path, utils.convParamJsonObject(params), function(ar) { - if (ar.succeeded()) { - handler(utils.convReturnJson(ar.result()), null); - } else { - handler(null, ar.cause()); - } - }); - return that; - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - Returns true if this provider supports JWT tokens as the access_token. This is typically true if the provider - implements the `openid-connect` protocol. This is a plain return from the config option jwtToken, which is false - by default. - - This information is important to validate grants. Since pure OAuth2 should be used for authorization and when a - token is requested all grants should be declared, in case of openid-connect this is not true. OpenId will issue - a token and all grants will be encoded on the token itself so the requester does not need to list the required - grants. - - @public - - @return {boolean} true if openid-connect is used. - */ - this.hasJWTToken = function() { - var __args = arguments; - if (__args.length === 0) { - return j_oAuth2Auth["hasJWTToken()"](); - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - Decode a token to a {@link AccessToken} object. This is useful to handle bearer JWT tokens. - - @public - @param token {string} the access token (base64 string) - @param handler {function} A handler to receive the event - @return {OAuth2Auth} self - */ - this.decodeToken = function(token, handler) { - var __args = arguments; - if (__args.length === 2 && typeof __args[0] === 'string' && typeof __args[1] === 'function') { - j_oAuth2Auth["decodeToken(java.lang.String,io.vertx.core.Handler)"](token, function(ar) { - if (ar.succeeded()) { - handler(utils.convReturnVertxGen(AccessToken, ar.result()), null); - } else { - handler(null, ar.cause()); - } - }); - return that; - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - Query an OAuth 2.0 authorization server to determine the active state of an OAuth 2.0 token and to determine - meta-information about this token. - - @public - @param token {string} the access token (base64 string) - @param tokenType {string} hint to the token type e.g.: `access_token` - @param handler {function} A handler to receive the event - @return {OAuth2Auth} self - */ - this.introspectToken = function() { - var __args = arguments; - if (__args.length === 2 && typeof __args[0] === 'string' && typeof __args[1] === 'function') { - j_oAuth2Auth["introspectToken(java.lang.String,io.vertx.core.Handler)"](__args[0], function(ar) { - if (ar.succeeded()) { - __args[1](utils.convReturnVertxGen(AccessToken, ar.result()), null); - } else { - __args[1](null, ar.cause()); - } - }); - return that; - } else if (__args.length === 3 && typeof __args[0] === 'string' && typeof __args[1] === 'string' && typeof __args[2] === 'function') { - j_oAuth2Auth["introspectToken(java.lang.String,java.lang.String,io.vertx.core.Handler)"](__args[0], __args[1], function(ar) { - if (ar.succeeded()) { - __args[2](utils.convReturnJson(ar.result()), null); - } else { - __args[2](null, ar.cause()); - } - }); - return that; - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - Returns the scope separator. - - The RFC 6749 states that a scope is expressed as a set of case-sensitive and space-delimited strings, however - vendors tend not to agree on this and we see the following cases being used: space, plus sign, comma. - - @public - - @return {string} what value was used in the configuration of the object, falling back to the default value which is a space. - */ - this.getScopeSeparator = function() { - var __args = arguments; - if (__args.length === 0) { - return j_oAuth2Auth["getScopeSeparator()"](); - } else throw new TypeError('function invoked with invalid arguments'); - }; - - // A reference to the underlying Java delegate - // NOTE! This is an internal API and must not be used in user code. - // If you rely on this property your code is likely to break if we change it / remove it without warning. - this._jdel = j_oAuth2Auth; -}; - -OAuth2Auth._jclass = utils.getJavaClass("io.vertx.ext.auth.oauth2.OAuth2Auth"); -OAuth2Auth._jtype = { - accept: function(obj) { - return OAuth2Auth._jclass.isInstance(obj._jdel); - }, - wrap: function(jdel) { - var obj = Object.create(OAuth2Auth.prototype, {}); - OAuth2Auth.apply(obj, arguments); - return obj; - }, - unwrap: function(obj) { - return obj._jdel; - } -}; -OAuth2Auth._create = function(jdel) { - var obj = Object.create(OAuth2Auth.prototype, {}); - OAuth2Auth.apply(obj, arguments); - return obj; -} -/** - - @memberof module:vertx-auth-oauth2-js/o_auth2_auth - @param vertx {Vertx} the Vertx instance - @param flow {Object} - @param config {Object} the config as exported from the admin console - @return {OAuth2Auth} the auth provider - */ -OAuth2Auth.createKeycloak = function(vertx, flow, config) { - var __args = arguments; - if (__args.length === 3 && typeof __args[0] === 'object' && __args[0]._jdel && typeof __args[1] === 'string' && (typeof __args[2] === 'object' && __args[2] != null)) { - return utils.convReturnVertxGen(OAuth2Auth, JOAuth2Auth["createKeycloak(io.vertx.core.Vertx,io.vertx.ext.auth.oauth2.OAuth2FlowType,io.vertx.core.json.JsonObject)"](vertx._jdel, io.vertx.ext.auth.oauth2.OAuth2FlowType.valueOf(flow), utils.convParamJsonObject(config))); - } else throw new TypeError('function invoked with invalid arguments'); -}; - -/** - Create a OAuth2 auth provider - - @memberof module:vertx-auth-oauth2-js/o_auth2_auth - @param vertx {Vertx} the Vertx instance - @param flow {Object} - @param config {Object} the config - @return {OAuth2Auth} the auth provider - */ -OAuth2Auth.create = function() { - var __args = arguments; - if (__args.length === 2 && typeof __args[0] === 'object' && __args[0]._jdel && typeof __args[1] === 'string') { - return utils.convReturnVertxGen(OAuth2Auth, JOAuth2Auth["create(io.vertx.core.Vertx,io.vertx.ext.auth.oauth2.OAuth2FlowType)"](__args[0]._jdel, io.vertx.ext.auth.oauth2.OAuth2FlowType.valueOf(__args[1]))); - }else if (__args.length === 3 && typeof __args[0] === 'object' && __args[0]._jdel && typeof __args[1] === 'string' && (typeof __args[2] === 'object' && __args[2] != null)) { - return utils.convReturnVertxGen(OAuth2Auth, JOAuth2Auth["create(io.vertx.core.Vertx,io.vertx.ext.auth.oauth2.OAuth2FlowType,io.vertx.ext.auth.oauth2.OAuth2ClientOptions)"](__args[0]._jdel, io.vertx.ext.auth.oauth2.OAuth2FlowType.valueOf(__args[1]), __args[2] != null ? new OAuth2ClientOptions(new JsonObject(Java.asJSONCompatible(__args[2]))) : null)); - } else throw new TypeError('function invoked with invalid arguments'); -}; - -module.exports = OAuth2Auth; \ No newline at end of file diff --git a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/salesforce_auth.js b/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/salesforce_auth.js deleted file mode 100644 index 56fd4fc2c..000000000 --- a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/salesforce_auth.js +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2014 Red Hat, Inc. - * - * Red Hat 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. - */ - -/** @module vertx-auth-oauth2-js/salesforce_auth */ -var utils = require('vertx-js/util/utils'); -var Vertx = require('vertx-js/vertx'); -var OAuth2Auth = require('vertx-auth-oauth2-js/o_auth2_auth'); - -var io = Packages.io; -var JsonObject = io.vertx.core.json.JsonObject; -var JSalesforceAuth = Java.type('io.vertx.ext.auth.oauth2.providers.SalesforceAuth'); -var HttpClientOptions = Java.type('io.vertx.core.http.HttpClientOptions'); - -/** - - @class -*/ -var SalesforceAuth = function(j_val) { - - var j_salesforceAuth = j_val; - var that = this; - - // A reference to the underlying Java delegate - // NOTE! This is an internal API and must not be used in user code. - // If you rely on this property your code is likely to break if we change it / remove it without warning. - this._jdel = j_salesforceAuth; -}; - -SalesforceAuth._jclass = utils.getJavaClass("io.vertx.ext.auth.oauth2.providers.SalesforceAuth"); -SalesforceAuth._jtype = { - accept: function(obj) { - return SalesforceAuth._jclass.isInstance(obj._jdel); - }, - wrap: function(jdel) { - var obj = Object.create(SalesforceAuth.prototype, {}); - SalesforceAuth.apply(obj, arguments); - return obj; - }, - unwrap: function(obj) { - return obj._jdel; - } -}; -SalesforceAuth._create = function(jdel) { - var obj = Object.create(SalesforceAuth.prototype, {}); - SalesforceAuth.apply(obj, arguments); - return obj; -} -/** - Create a OAuth2Auth provider for Salesforce - - @memberof module:vertx-auth-oauth2-js/salesforce_auth - @param vertx {Vertx} - @param clientId {string} the client id given to you by Salesforce - @param clientSecret {string} the client secret given to you by Salesforce - @param httpClientOptions {Object} custom http client options - @return {OAuth2Auth} - */ -SalesforceAuth.create = function() { - var __args = arguments; - if (__args.length === 3 && typeof __args[0] === 'object' && __args[0]._jdel && typeof __args[1] === 'string' && typeof __args[2] === 'string') { - return utils.convReturnVertxGen(OAuth2Auth, JSalesforceAuth["create(io.vertx.core.Vertx,java.lang.String,java.lang.String)"](__args[0]._jdel, __args[1], __args[2])); - }else if (__args.length === 4 && typeof __args[0] === 'object' && __args[0]._jdel && typeof __args[1] === 'string' && typeof __args[2] === 'string' && (typeof __args[3] === 'object' && __args[3] != null)) { - return utils.convReturnVertxGen(OAuth2Auth, JSalesforceAuth["create(io.vertx.core.Vertx,java.lang.String,java.lang.String,io.vertx.core.http.HttpClientOptions)"](__args[0]._jdel, __args[1], __args[2], __args[3] != null ? new HttpClientOptions(new JsonObject(Java.asJSONCompatible(__args[3]))) : null)); - } else throw new TypeError('function invoked with invalid arguments'); -}; - -module.exports = SalesforceAuth; \ No newline at end of file diff --git a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/shopify_auth.js b/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/shopify_auth.js deleted file mode 100644 index 527b4dde2..000000000 --- a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/shopify_auth.js +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2014 Red Hat, Inc. - * - * Red Hat 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. - */ - -/** @module vertx-auth-oauth2-js/shopify_auth */ -var utils = require('vertx-js/util/utils'); -var Vertx = require('vertx-js/vertx'); -var OAuth2Auth = require('vertx-auth-oauth2-js/o_auth2_auth'); - -var io = Packages.io; -var JsonObject = io.vertx.core.json.JsonObject; -var JShopifyAuth = Java.type('io.vertx.ext.auth.oauth2.providers.ShopifyAuth'); -var HttpClientOptions = Java.type('io.vertx.core.http.HttpClientOptions'); - -/** - - @class -*/ -var ShopifyAuth = function(j_val) { - - var j_shopifyAuth = j_val; - var that = this; - - // A reference to the underlying Java delegate - // NOTE! This is an internal API and must not be used in user code. - // If you rely on this property your code is likely to break if we change it / remove it without warning. - this._jdel = j_shopifyAuth; -}; - -ShopifyAuth._jclass = utils.getJavaClass("io.vertx.ext.auth.oauth2.providers.ShopifyAuth"); -ShopifyAuth._jtype = { - accept: function(obj) { - return ShopifyAuth._jclass.isInstance(obj._jdel); - }, - wrap: function(jdel) { - var obj = Object.create(ShopifyAuth.prototype, {}); - ShopifyAuth.apply(obj, arguments); - return obj; - }, - unwrap: function(obj) { - return obj._jdel; - } -}; -ShopifyAuth._create = function(jdel) { - var obj = Object.create(ShopifyAuth.prototype, {}); - ShopifyAuth.apply(obj, arguments); - return obj; -} -/** - Create a OAuth2Auth provider for Shopify - - @memberof module:vertx-auth-oauth2-js/shopify_auth - @param vertx {Vertx} - @param clientId {string} the client id given to you by Shopify - @param clientSecret {string} the client secret given to you by Shopify - @param shop {string} your shop name - @param httpClientOptions {Object} custom http client options - @return {OAuth2Auth} - */ -ShopifyAuth.create = function() { - var __args = arguments; - if (__args.length === 4 && typeof __args[0] === 'object' && __args[0]._jdel && typeof __args[1] === 'string' && typeof __args[2] === 'string' && typeof __args[3] === 'string') { - return utils.convReturnVertxGen(OAuth2Auth, JShopifyAuth["create(io.vertx.core.Vertx,java.lang.String,java.lang.String,java.lang.String)"](__args[0]._jdel, __args[1], __args[2], __args[3])); - }else if (__args.length === 5 && typeof __args[0] === 'object' && __args[0]._jdel && typeof __args[1] === 'string' && typeof __args[2] === 'string' && typeof __args[3] === 'string' && (typeof __args[4] === 'object' && __args[4] != null)) { - return utils.convReturnVertxGen(OAuth2Auth, JShopifyAuth["create(io.vertx.core.Vertx,java.lang.String,java.lang.String,java.lang.String,io.vertx.core.http.HttpClientOptions)"](__args[0]._jdel, __args[1], __args[2], __args[3], __args[4] != null ? new HttpClientOptions(new JsonObject(Java.asJSONCompatible(__args[4]))) : null)); - } else throw new TypeError('function invoked with invalid arguments'); -}; - -module.exports = ShopifyAuth; \ No newline at end of file diff --git a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/soundcloud_auth.js b/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/soundcloud_auth.js deleted file mode 100644 index 23c33f0df..000000000 --- a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/soundcloud_auth.js +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2014 Red Hat, Inc. - * - * Red Hat 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. - */ - -/** @module vertx-auth-oauth2-js/soundcloud_auth */ -var utils = require('vertx-js/util/utils'); -var Vertx = require('vertx-js/vertx'); -var OAuth2Auth = require('vertx-auth-oauth2-js/o_auth2_auth'); - -var io = Packages.io; -var JsonObject = io.vertx.core.json.JsonObject; -var JSoundcloudAuth = Java.type('io.vertx.ext.auth.oauth2.providers.SoundcloudAuth'); -var HttpClientOptions = Java.type('io.vertx.core.http.HttpClientOptions'); - -/** - - @class -*/ -var SoundcloudAuth = function(j_val) { - - var j_soundcloudAuth = j_val; - var that = this; - - // A reference to the underlying Java delegate - // NOTE! This is an internal API and must not be used in user code. - // If you rely on this property your code is likely to break if we change it / remove it without warning. - this._jdel = j_soundcloudAuth; -}; - -SoundcloudAuth._jclass = utils.getJavaClass("io.vertx.ext.auth.oauth2.providers.SoundcloudAuth"); -SoundcloudAuth._jtype = { - accept: function(obj) { - return SoundcloudAuth._jclass.isInstance(obj._jdel); - }, - wrap: function(jdel) { - var obj = Object.create(SoundcloudAuth.prototype, {}); - SoundcloudAuth.apply(obj, arguments); - return obj; - }, - unwrap: function(obj) { - return obj._jdel; - } -}; -SoundcloudAuth._create = function(jdel) { - var obj = Object.create(SoundcloudAuth.prototype, {}); - SoundcloudAuth.apply(obj, arguments); - return obj; -} -/** - Create a OAuth2Auth provider for Dropbox - - @memberof module:vertx-auth-oauth2-js/soundcloud_auth - @param vertx {Vertx} - @param clientId {string} the client id given to you by SoundCloud - @param clientSecret {string} the client secret given to you by SoundCloud - @param httpClientOptions {Object} custom http client options - @return {OAuth2Auth} - */ -SoundcloudAuth.create = function() { - var __args = arguments; - if (__args.length === 3 && typeof __args[0] === 'object' && __args[0]._jdel && typeof __args[1] === 'string' && typeof __args[2] === 'string') { - return utils.convReturnVertxGen(OAuth2Auth, JSoundcloudAuth["create(io.vertx.core.Vertx,java.lang.String,java.lang.String)"](__args[0]._jdel, __args[1], __args[2])); - }else if (__args.length === 4 && typeof __args[0] === 'object' && __args[0]._jdel && typeof __args[1] === 'string' && typeof __args[2] === 'string' && (typeof __args[3] === 'object' && __args[3] != null)) { - return utils.convReturnVertxGen(OAuth2Auth, JSoundcloudAuth["create(io.vertx.core.Vertx,java.lang.String,java.lang.String,io.vertx.core.http.HttpClientOptions)"](__args[0]._jdel, __args[1], __args[2], __args[3] != null ? new HttpClientOptions(new JsonObject(Java.asJSONCompatible(__args[3]))) : null)); - } else throw new TypeError('function invoked with invalid arguments'); -}; - -module.exports = SoundcloudAuth; \ No newline at end of file diff --git a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/stripe_auth.js b/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/stripe_auth.js deleted file mode 100644 index f9e62043d..000000000 --- a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/stripe_auth.js +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2014 Red Hat, Inc. - * - * Red Hat 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. - */ - -/** @module vertx-auth-oauth2-js/stripe_auth */ -var utils = require('vertx-js/util/utils'); -var Vertx = require('vertx-js/vertx'); -var OAuth2Auth = require('vertx-auth-oauth2-js/o_auth2_auth'); - -var io = Packages.io; -var JsonObject = io.vertx.core.json.JsonObject; -var JStripeAuth = Java.type('io.vertx.ext.auth.oauth2.providers.StripeAuth'); -var HttpClientOptions = Java.type('io.vertx.core.http.HttpClientOptions'); - -/** - - @class -*/ -var StripeAuth = function(j_val) { - - var j_stripeAuth = j_val; - var that = this; - - // A reference to the underlying Java delegate - // NOTE! This is an internal API and must not be used in user code. - // If you rely on this property your code is likely to break if we change it / remove it without warning. - this._jdel = j_stripeAuth; -}; - -StripeAuth._jclass = utils.getJavaClass("io.vertx.ext.auth.oauth2.providers.StripeAuth"); -StripeAuth._jtype = { - accept: function(obj) { - return StripeAuth._jclass.isInstance(obj._jdel); - }, - wrap: function(jdel) { - var obj = Object.create(StripeAuth.prototype, {}); - StripeAuth.apply(obj, arguments); - return obj; - }, - unwrap: function(obj) { - return obj._jdel; - } -}; -StripeAuth._create = function(jdel) { - var obj = Object.create(StripeAuth.prototype, {}); - StripeAuth.apply(obj, arguments); - return obj; -} -/** - Create a OAuth2Auth provider for Dropbox - - @memberof module:vertx-auth-oauth2-js/stripe_auth - @param vertx {Vertx} - @param clientId {string} the client id given to you by Stripe - @param clientSecret {string} the client secret given to you by Stripe - @param httpClientOptions {Object} custom http client options - @return {OAuth2Auth} - */ -StripeAuth.create = function() { - var __args = arguments; - if (__args.length === 3 && typeof __args[0] === 'object' && __args[0]._jdel && typeof __args[1] === 'string' && typeof __args[2] === 'string') { - return utils.convReturnVertxGen(OAuth2Auth, JStripeAuth["create(io.vertx.core.Vertx,java.lang.String,java.lang.String)"](__args[0]._jdel, __args[1], __args[2])); - }else if (__args.length === 4 && typeof __args[0] === 'object' && __args[0]._jdel && typeof __args[1] === 'string' && typeof __args[2] === 'string' && (typeof __args[3] === 'object' && __args[3] != null)) { - return utils.convReturnVertxGen(OAuth2Auth, JStripeAuth["create(io.vertx.core.Vertx,java.lang.String,java.lang.String,io.vertx.core.http.HttpClientOptions)"](__args[0]._jdel, __args[1], __args[2], __args[3] != null ? new HttpClientOptions(new JsonObject(Java.asJSONCompatible(__args[3]))) : null)); - } else throw new TypeError('function invoked with invalid arguments'); -}; - -module.exports = StripeAuth; \ No newline at end of file diff --git a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/twitter_auth.js b/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/twitter_auth.js deleted file mode 100644 index 2283f6a8c..000000000 --- a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2-js/twitter_auth.js +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2014 Red Hat, Inc. - * - * Red Hat 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. - */ - -/** @module vertx-auth-oauth2-js/twitter_auth */ -var utils = require('vertx-js/util/utils'); -var Vertx = require('vertx-js/vertx'); -var OAuth2Auth = require('vertx-auth-oauth2-js/o_auth2_auth'); - -var io = Packages.io; -var JsonObject = io.vertx.core.json.JsonObject; -var JTwitterAuth = Java.type('io.vertx.ext.auth.oauth2.providers.TwitterAuth'); -var HttpClientOptions = Java.type('io.vertx.core.http.HttpClientOptions'); - -/** - - @class -*/ -var TwitterAuth = function(j_val) { - - var j_twitterAuth = j_val; - var that = this; - - // A reference to the underlying Java delegate - // NOTE! This is an internal API and must not be used in user code. - // If you rely on this property your code is likely to break if we change it / remove it without warning. - this._jdel = j_twitterAuth; -}; - -TwitterAuth._jclass = utils.getJavaClass("io.vertx.ext.auth.oauth2.providers.TwitterAuth"); -TwitterAuth._jtype = { - accept: function(obj) { - return TwitterAuth._jclass.isInstance(obj._jdel); - }, - wrap: function(jdel) { - var obj = Object.create(TwitterAuth.prototype, {}); - TwitterAuth.apply(obj, arguments); - return obj; - }, - unwrap: function(obj) { - return obj._jdel; - } -}; -TwitterAuth._create = function(jdel) { - var obj = Object.create(TwitterAuth.prototype, {}); - TwitterAuth.apply(obj, arguments); - return obj; -} -/** - Create a OAuth2Auth provider for Twitter - - @memberof module:vertx-auth-oauth2-js/twitter_auth - @param vertx {Vertx} - @param clientId {string} the client id given to you by Twitter - @param clientSecret {string} the client secret given to you by Twitter - @param httpClientOptions {Object} custom http client options - @return {OAuth2Auth} - */ -TwitterAuth.create = function() { - var __args = arguments; - if (__args.length === 3 && typeof __args[0] === 'object' && __args[0]._jdel && typeof __args[1] === 'string' && typeof __args[2] === 'string') { - return utils.convReturnVertxGen(OAuth2Auth, JTwitterAuth["create(io.vertx.core.Vertx,java.lang.String,java.lang.String)"](__args[0]._jdel, __args[1], __args[2])); - }else if (__args.length === 4 && typeof __args[0] === 'object' && __args[0]._jdel && typeof __args[1] === 'string' && typeof __args[2] === 'string' && (typeof __args[3] === 'object' && __args[3] != null)) { - return utils.convReturnVertxGen(OAuth2Auth, JTwitterAuth["create(io.vertx.core.Vertx,java.lang.String,java.lang.String,io.vertx.core.http.HttpClientOptions)"](__args[0]._jdel, __args[1], __args[2], __args[3] != null ? new HttpClientOptions(new JsonObject(Java.asJSONCompatible(__args[3]))) : null)); - } else throw new TypeError('function invoked with invalid arguments'); -}; - -module.exports = TwitterAuth; \ No newline at end of file diff --git a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/access_token.rb b/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/access_token.rb deleted file mode 100644 index a6750e130..000000000 --- a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/access_token.rb +++ /dev/null @@ -1,119 +0,0 @@ -require 'vertx-auth-common/user' -require 'vertx-auth-common/auth_provider' -require 'vertx/util/utils.rb' -# Generated from io.vertx.ext.auth.oauth2.AccessToken -module VertxAuthOauth2 - # AccessToken extension to the User interface - class AccessToken < ::VertxAuthCommon::User - # @private - # @param j_del [::VertxAuthOauth2::AccessToken] the java delegate - def initialize(j_del) - super(j_del) - @j_del = j_del - end - # @private - # @return [::VertxAuthOauth2::AccessToken] the underlying java delegate - def j_del - @j_del - end - @@j_api_type = Object.new - def @@j_api_type.accept?(obj) - obj.class == AccessToken - end - def @@j_api_type.wrap(obj) - AccessToken.new(obj) - end - def @@j_api_type.unwrap(obj) - obj.j_del - end - def self.j_api_type - @@j_api_type - end - def self.j_class - Java::IoVertxExtAuthOauth2::AccessToken.java_class - end - # @param [String] arg0 - # @yield - # @return [self] - def is_authorised(arg0=nil) - if arg0.class == String && block_given? - @j_del.java_method(:isAuthorised, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(arg0,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) })) - return self - end - raise ArgumentError, "Invalid arguments when calling is_authorised(#{arg0})" - end - # @return [self] - def clear_cache - if !block_given? - @j_del.java_method(:clearCache, []).call() - return self - end - raise ArgumentError, "Invalid arguments when calling clear_cache()" - end - # @return [Hash{String => Object}] - def principal - if !block_given? - return @j_del.java_method(:principal, []).call() != nil ? JSON.parse(@j_del.java_method(:principal, []).call().encode) : nil - end - raise ArgumentError, "Invalid arguments when calling principal()" - end - # @param [::VertxAuthCommon::AuthProvider] arg0 - # @return [void] - def set_auth_provider(arg0=nil) - if arg0.class.method_defined?(:j_del) && !block_given? - return @j_del.java_method(:setAuthProvider, [Java::IoVertxExtAuth::AuthProvider.java_class]).call(arg0.j_del) - end - raise ArgumentError, "Invalid arguments when calling set_auth_provider(#{arg0})" - end - # Check if the access token is expired or not. - # @return [true,false] - def expired? - if !block_given? - return @j_del.java_method(:expired, []).call() - end - raise ArgumentError, "Invalid arguments when calling expired?()" - end - # Refresh the access token - # @yield - The callback function returning the results. - # @return [self] - def refresh - if block_given? - @j_del.java_method(:refresh, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil) })) - return self - end - raise ArgumentError, "Invalid arguments when calling refresh()" - end - # Revoke access or refresh token - # @param [String] token_type - A String containing the type of token to revoke. Should be either "access_token" or "refresh_token". - # @yield - The callback function returning the results. - # @return [self] - def revoke(token_type=nil) - if token_type.class == String && block_given? - @j_del.java_method(:revoke, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(token_type,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) })) - return self - end - raise ArgumentError, "Invalid arguments when calling revoke(#{token_type})" - end - # Revoke refresh token and calls the logout endpoint. This is a openid-connect extension and might not be - # available on all providers. - # @yield - The callback function returning the results. - # @return [self] - def logout - if block_given? - @j_del.java_method(:logout, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil) })) - return self - end - raise ArgumentError, "Invalid arguments when calling logout()" - end - # Introspect access token. This is an OAuth2 extension that allow to verify if an access token is still valid. - # @yield - The callback function returning the results. - # @return [self] - def introspect - if block_given? - @j_del.java_method(:introspect, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil) })) - return self - end - raise ArgumentError, "Invalid arguments when calling introspect()" - end - end -end diff --git a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/azure_ad_auth.rb b/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/azure_ad_auth.rb deleted file mode 100644 index a4bfd41dc..000000000 --- a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/azure_ad_auth.rb +++ /dev/null @@ -1,50 +0,0 @@ -require 'vertx/vertx' -require 'vertx-auth-oauth2/o_auth2_auth' -require 'vertx/util/utils.rb' -# Generated from io.vertx.ext.auth.oauth2.providers.AzureADAuth -module VertxAuthOauth2 - # Simplified factory to create an for Azure AD. - class AzureADAuth - # @private - # @param j_del [::VertxAuthOauth2::AzureADAuth] the java delegate - def initialize(j_del) - @j_del = j_del - end - # @private - # @return [::VertxAuthOauth2::AzureADAuth] the underlying java delegate - def j_del - @j_del - end - @@j_api_type = Object.new - def @@j_api_type.accept?(obj) - obj.class == AzureADAuth - end - def @@j_api_type.wrap(obj) - AzureADAuth.new(obj) - end - def @@j_api_type.unwrap(obj) - obj.j_del - end - def self.j_api_type - @@j_api_type - end - def self.j_class - Java::IoVertxExtAuthOauth2Providers::AzureADAuth.java_class - end - # Create a OAuth2Auth provider for Microsoft Azure Active Directory - # @param [::Vertx::Vertx] vertx - # @param [String] clientId the client id given to you by Azure - # @param [String] clientSecret the client secret given to you by Azure - # @param [String] guid the guid of your application given to you by Azure - # @param [Hash] httpClientOptions custom http client options - # @return [::VertxAuthOauth2::OAuth2Auth] - def self.create(vertx=nil,clientId=nil,clientSecret=nil,guid=nil,httpClientOptions=nil) - if vertx.class.method_defined?(:j_del) && clientId.class == String && clientSecret.class == String && guid.class == String && !block_given? && httpClientOptions == nil - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2Providers::AzureADAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class]).call(vertx.j_del,clientId,clientSecret,guid),::VertxAuthOauth2::OAuth2Auth) - elsif vertx.class.method_defined?(:j_del) && clientId.class == String && clientSecret.class == String && guid.class == String && httpClientOptions.class == Hash && !block_given? - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2Providers::AzureADAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class,Java::IoVertxCoreHttp::HttpClientOptions.java_class]).call(vertx.j_del,clientId,clientSecret,guid,Java::IoVertxCoreHttp::HttpClientOptions.new(::Vertx::Util::Utils.to_json_object(httpClientOptions))),::VertxAuthOauth2::OAuth2Auth) - end - raise ArgumentError, "Invalid arguments when calling create(#{vertx},#{clientId},#{clientSecret},#{guid},#{httpClientOptions})" - end - end -end diff --git a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/box_auth.rb b/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/box_auth.rb deleted file mode 100644 index a7f930e99..000000000 --- a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/box_auth.rb +++ /dev/null @@ -1,49 +0,0 @@ -require 'vertx/vertx' -require 'vertx-auth-oauth2/o_auth2_auth' -require 'vertx/util/utils.rb' -# Generated from io.vertx.ext.auth.oauth2.providers.BoxAuth -module VertxAuthOauth2 - # Simplified factory to create an for box.com. - class BoxAuth - # @private - # @param j_del [::VertxAuthOauth2::BoxAuth] the java delegate - def initialize(j_del) - @j_del = j_del - end - # @private - # @return [::VertxAuthOauth2::BoxAuth] the underlying java delegate - def j_del - @j_del - end - @@j_api_type = Object.new - def @@j_api_type.accept?(obj) - obj.class == BoxAuth - end - def @@j_api_type.wrap(obj) - BoxAuth.new(obj) - end - def @@j_api_type.unwrap(obj) - obj.j_del - end - def self.j_api_type - @@j_api_type - end - def self.j_class - Java::IoVertxExtAuthOauth2Providers::BoxAuth.java_class - end - # Create a OAuth2Auth provider for App.net - # @param [::Vertx::Vertx] vertx - # @param [String] clientId the client id given to you by box.com - # @param [String] clientSecret the client secret given to you by box.com - # @param [Hash] httpClientOptions custom http client options - # @return [::VertxAuthOauth2::OAuth2Auth] - def self.create(vertx=nil,clientId=nil,clientSecret=nil,httpClientOptions=nil) - if vertx.class.method_defined?(:j_del) && clientId.class == String && clientSecret.class == String && !block_given? && httpClientOptions == nil - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2Providers::BoxAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class]).call(vertx.j_del,clientId,clientSecret),::VertxAuthOauth2::OAuth2Auth) - elsif vertx.class.method_defined?(:j_del) && clientId.class == String && clientSecret.class == String && httpClientOptions.class == Hash && !block_given? - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2Providers::BoxAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class,Java::IoVertxCoreHttp::HttpClientOptions.java_class]).call(vertx.j_del,clientId,clientSecret,Java::IoVertxCoreHttp::HttpClientOptions.new(::Vertx::Util::Utils.to_json_object(httpClientOptions))),::VertxAuthOauth2::OAuth2Auth) - end - raise ArgumentError, "Invalid arguments when calling create(#{vertx},#{clientId},#{clientSecret},#{httpClientOptions})" - end - end -end diff --git a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/cloud_foundry_auth.rb b/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/cloud_foundry_auth.rb deleted file mode 100644 index 50187f364..000000000 --- a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/cloud_foundry_auth.rb +++ /dev/null @@ -1,50 +0,0 @@ -require 'vertx/vertx' -require 'vertx-auth-oauth2/o_auth2_auth' -require 'vertx/util/utils.rb' -# Generated from io.vertx.ext.auth.oauth2.providers.CloudFoundryAuth -module VertxAuthOauth2 - # Simplified factory to create an for CloudFoundry UAA. - class CloudFoundryAuth - # @private - # @param j_del [::VertxAuthOauth2::CloudFoundryAuth] the java delegate - def initialize(j_del) - @j_del = j_del - end - # @private - # @return [::VertxAuthOauth2::CloudFoundryAuth] the underlying java delegate - def j_del - @j_del - end - @@j_api_type = Object.new - def @@j_api_type.accept?(obj) - obj.class == CloudFoundryAuth - end - def @@j_api_type.wrap(obj) - CloudFoundryAuth.new(obj) - end - def @@j_api_type.unwrap(obj) - obj.j_del - end - def self.j_api_type - @@j_api_type - end - def self.j_class - Java::IoVertxExtAuthOauth2Providers::CloudFoundryAuth.java_class - end - # Create a OAuth2Auth provider for CloudFoundry UAA - # @param [::Vertx::Vertx] vertx - # @param [String] clientId the client id given to you by CloudFoundry UAA - # @param [String] clientSecret the client secret given to you by CloudFoundry UAA - # @param [String] uuaURL the url to your UUA server instance - # @param [Hash] httpClientOptions custom http client options - # @return [::VertxAuthOauth2::OAuth2Auth] - def self.create(vertx=nil,clientId=nil,clientSecret=nil,uuaURL=nil,httpClientOptions=nil) - if vertx.class.method_defined?(:j_del) && clientId.class == String && clientSecret.class == String && uuaURL.class == String && !block_given? && httpClientOptions == nil - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2Providers::CloudFoundryAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class]).call(vertx.j_del,clientId,clientSecret,uuaURL),::VertxAuthOauth2::OAuth2Auth) - elsif vertx.class.method_defined?(:j_del) && clientId.class == String && clientSecret.class == String && uuaURL.class == String && httpClientOptions.class == Hash && !block_given? - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2Providers::CloudFoundryAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class,Java::IoVertxCoreHttp::HttpClientOptions.java_class]).call(vertx.j_del,clientId,clientSecret,uuaURL,Java::IoVertxCoreHttp::HttpClientOptions.new(::Vertx::Util::Utils.to_json_object(httpClientOptions))),::VertxAuthOauth2::OAuth2Auth) - end - raise ArgumentError, "Invalid arguments when calling create(#{vertx},#{clientId},#{clientSecret},#{uuaURL},#{httpClientOptions})" - end - end -end diff --git a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/cloud_foundry_uaa.rb b/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/cloud_foundry_uaa.rb deleted file mode 100644 index 58bb69c37..000000000 --- a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/cloud_foundry_uaa.rb +++ /dev/null @@ -1,50 +0,0 @@ -require 'vertx/vertx' -require 'vertx-auth-oauth2/o_auth2_auth' -require 'vertx/util/utils.rb' -# Generated from io.vertx.ext.auth.oauth2.providers.CloudFoundryAuth -module VertxAuthOauth2 - # Simplified factory to create an for CloudFoundry UAA. - class CloudFoundryUAA - # @private - # @param j_del [::VertxAuthOauth2::CloudFoundryUAA] the java delegate - def initialize(j_del) - @j_del = j_del - end - # @private - # @return [::VertxAuthOauth2::CloudFoundryUAA] the underlying java delegate - def j_del - @j_del - end - @@j_api_type = Object.new - def @@j_api_type.accept?(obj) - obj.class == CloudFoundryUAA - end - def @@j_api_type.wrap(obj) - CloudFoundryUAA.new(obj) - end - def @@j_api_type.unwrap(obj) - obj.j_del - end - def self.j_api_type - @@j_api_type - end - def self.j_class - Java::IoVertxExtAuthOauth2Providers::CloudFoundryUAA.java_class - end - # Create a OAuth2Auth provider for CloudFoundry UAA - # @param [::Vertx::Vertx] vertx - # @param [String] clientId the client id given to you by CloudFoundry UAA - # @param [String] clientSecret the client secret given to you by CloudFoundry UAA - # @param [String] uuaURL the url to your UUA server instance - # @param [Hash] httpClientOptions custom http client options - # @return [::VertxAuthOauth2::OAuth2Auth] - def self.create(vertx=nil,clientId=nil,clientSecret=nil,uuaURL=nil,httpClientOptions=nil) - if vertx.class.method_defined?(:j_del) && clientId.class == String && clientSecret.class == String && uuaURL.class == String && !block_given? && httpClientOptions == nil - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2Providers::CloudFoundryUAA.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class]).call(vertx.j_del,clientId,clientSecret,uuaURL),::VertxAuthOauth2::OAuth2Auth) - elsif vertx.class.method_defined?(:j_del) && clientId.class == String && clientSecret.class == String && uuaURL.class == String && httpClientOptions.class == Hash && !block_given? - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2Providers::CloudFoundryUAA.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class,Java::IoVertxCoreHttp::HttpClientOptions.java_class]).call(vertx.j_del,clientId,clientSecret,uuaURL,Java::IoVertxCoreHttp::HttpClientOptions.new(::Vertx::Util::Utils.to_json_object(httpClientOptions))),::VertxAuthOauth2::OAuth2Auth) - end - raise ArgumentError, "Invalid arguments when calling create(#{vertx},#{clientId},#{clientSecret},#{uuaURL},#{httpClientOptions})" - end - end -end diff --git a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/dropbox_auth.rb b/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/dropbox_auth.rb deleted file mode 100644 index 55f5db436..000000000 --- a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/dropbox_auth.rb +++ /dev/null @@ -1,49 +0,0 @@ -require 'vertx/vertx' -require 'vertx-auth-oauth2/o_auth2_auth' -require 'vertx/util/utils.rb' -# Generated from io.vertx.ext.auth.oauth2.providers.DropboxAuth -module VertxAuthOauth2 - # Simplified factory to create an for Dropbox. - class DropboxAuth - # @private - # @param j_del [::VertxAuthOauth2::DropboxAuth] the java delegate - def initialize(j_del) - @j_del = j_del - end - # @private - # @return [::VertxAuthOauth2::DropboxAuth] the underlying java delegate - def j_del - @j_del - end - @@j_api_type = Object.new - def @@j_api_type.accept?(obj) - obj.class == DropboxAuth - end - def @@j_api_type.wrap(obj) - DropboxAuth.new(obj) - end - def @@j_api_type.unwrap(obj) - obj.j_del - end - def self.j_api_type - @@j_api_type - end - def self.j_class - Java::IoVertxExtAuthOauth2Providers::DropboxAuth.java_class - end - # Create a OAuth2Auth provider for Dropbox - # @param [::Vertx::Vertx] vertx - # @param [String] clientId the client id given to you by Dropbox - # @param [String] clientSecret the client secret given to you by Dropbox - # @param [Hash] httpClientOptions custom http client options - # @return [::VertxAuthOauth2::OAuth2Auth] - def self.create(vertx=nil,clientId=nil,clientSecret=nil,httpClientOptions=nil) - if vertx.class.method_defined?(:j_del) && clientId.class == String && clientSecret.class == String && !block_given? && httpClientOptions == nil - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2Providers::DropboxAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class]).call(vertx.j_del,clientId,clientSecret),::VertxAuthOauth2::OAuth2Auth) - elsif vertx.class.method_defined?(:j_del) && clientId.class == String && clientSecret.class == String && httpClientOptions.class == Hash && !block_given? - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2Providers::DropboxAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class,Java::IoVertxCoreHttp::HttpClientOptions.java_class]).call(vertx.j_del,clientId,clientSecret,Java::IoVertxCoreHttp::HttpClientOptions.new(::Vertx::Util::Utils.to_json_object(httpClientOptions))),::VertxAuthOauth2::OAuth2Auth) - end - raise ArgumentError, "Invalid arguments when calling create(#{vertx},#{clientId},#{clientSecret},#{httpClientOptions})" - end - end -end diff --git a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/facebook_auth.rb b/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/facebook_auth.rb deleted file mode 100644 index ccec771c3..000000000 --- a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/facebook_auth.rb +++ /dev/null @@ -1,49 +0,0 @@ -require 'vertx/vertx' -require 'vertx-auth-oauth2/o_auth2_auth' -require 'vertx/util/utils.rb' -# Generated from io.vertx.ext.auth.oauth2.providers.FacebookAuth -module VertxAuthOauth2 - # Simplified factory to create an for Facebook. - class FacebookAuth - # @private - # @param j_del [::VertxAuthOauth2::FacebookAuth] the java delegate - def initialize(j_del) - @j_del = j_del - end - # @private - # @return [::VertxAuthOauth2::FacebookAuth] the underlying java delegate - def j_del - @j_del - end - @@j_api_type = Object.new - def @@j_api_type.accept?(obj) - obj.class == FacebookAuth - end - def @@j_api_type.wrap(obj) - FacebookAuth.new(obj) - end - def @@j_api_type.unwrap(obj) - obj.j_del - end - def self.j_api_type - @@j_api_type - end - def self.j_class - Java::IoVertxExtAuthOauth2Providers::FacebookAuth.java_class - end - # Create a OAuth2Auth provider for Facebook - # @param [::Vertx::Vertx] vertx - # @param [String] clientId the client id given to you by Facebook - # @param [String] clientSecret the client secret given to you by Facebook - # @param [Hash] httpClientOptions custom http client options - # @return [::VertxAuthOauth2::OAuth2Auth] - def self.create(vertx=nil,clientId=nil,clientSecret=nil,httpClientOptions=nil) - if vertx.class.method_defined?(:j_del) && clientId.class == String && clientSecret.class == String && !block_given? && httpClientOptions == nil - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2Providers::FacebookAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class]).call(vertx.j_del,clientId,clientSecret),::VertxAuthOauth2::OAuth2Auth) - elsif vertx.class.method_defined?(:j_del) && clientId.class == String && clientSecret.class == String && httpClientOptions.class == Hash && !block_given? - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2Providers::FacebookAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class,Java::IoVertxCoreHttp::HttpClientOptions.java_class]).call(vertx.j_del,clientId,clientSecret,Java::IoVertxCoreHttp::HttpClientOptions.new(::Vertx::Util::Utils.to_json_object(httpClientOptions))),::VertxAuthOauth2::OAuth2Auth) - end - raise ArgumentError, "Invalid arguments when calling create(#{vertx},#{clientId},#{clientSecret},#{httpClientOptions})" - end - end -end diff --git a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/foursquare_auth.rb b/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/foursquare_auth.rb deleted file mode 100644 index d8ccc4257..000000000 --- a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/foursquare_auth.rb +++ /dev/null @@ -1,49 +0,0 @@ -require 'vertx/vertx' -require 'vertx-auth-oauth2/o_auth2_auth' -require 'vertx/util/utils.rb' -# Generated from io.vertx.ext.auth.oauth2.providers.FoursquareAuth -module VertxAuthOauth2 - # Simplified factory to create an for Dropbox. - class FoursquareAuth - # @private - # @param j_del [::VertxAuthOauth2::FoursquareAuth] the java delegate - def initialize(j_del) - @j_del = j_del - end - # @private - # @return [::VertxAuthOauth2::FoursquareAuth] the underlying java delegate - def j_del - @j_del - end - @@j_api_type = Object.new - def @@j_api_type.accept?(obj) - obj.class == FoursquareAuth - end - def @@j_api_type.wrap(obj) - FoursquareAuth.new(obj) - end - def @@j_api_type.unwrap(obj) - obj.j_del - end - def self.j_api_type - @@j_api_type - end - def self.j_class - Java::IoVertxExtAuthOauth2Providers::FoursquareAuth.java_class - end - # Create a OAuth2Auth provider for Dropbox - # @param [::Vertx::Vertx] vertx - # @param [String] clientId the client id given to you by Dropbox - # @param [String] clientSecret the client secret given to you by Dropbox - # @param [Hash] httpClientOptions custom http client options - # @return [::VertxAuthOauth2::OAuth2Auth] - def self.create(vertx=nil,clientId=nil,clientSecret=nil,httpClientOptions=nil) - if vertx.class.method_defined?(:j_del) && clientId.class == String && clientSecret.class == String && !block_given? && httpClientOptions == nil - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2Providers::FoursquareAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class]).call(vertx.j_del,clientId,clientSecret),::VertxAuthOauth2::OAuth2Auth) - elsif vertx.class.method_defined?(:j_del) && clientId.class == String && clientSecret.class == String && httpClientOptions.class == Hash && !block_given? - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2Providers::FoursquareAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class,Java::IoVertxCoreHttp::HttpClientOptions.java_class]).call(vertx.j_del,clientId,clientSecret,Java::IoVertxCoreHttp::HttpClientOptions.new(::Vertx::Util::Utils.to_json_object(httpClientOptions))),::VertxAuthOauth2::OAuth2Auth) - end - raise ArgumentError, "Invalid arguments when calling create(#{vertx},#{clientId},#{clientSecret},#{httpClientOptions})" - end - end -end diff --git a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/github_auth.rb b/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/github_auth.rb deleted file mode 100644 index 47ee087aa..000000000 --- a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/github_auth.rb +++ /dev/null @@ -1,49 +0,0 @@ -require 'vertx/vertx' -require 'vertx-auth-oauth2/o_auth2_auth' -require 'vertx/util/utils.rb' -# Generated from io.vertx.ext.auth.oauth2.providers.GithubAuth -module VertxAuthOauth2 - # Simplified factory to create an for Github. - class GithubAuth - # @private - # @param j_del [::VertxAuthOauth2::GithubAuth] the java delegate - def initialize(j_del) - @j_del = j_del - end - # @private - # @return [::VertxAuthOauth2::GithubAuth] the underlying java delegate - def j_del - @j_del - end - @@j_api_type = Object.new - def @@j_api_type.accept?(obj) - obj.class == GithubAuth - end - def @@j_api_type.wrap(obj) - GithubAuth.new(obj) - end - def @@j_api_type.unwrap(obj) - obj.j_del - end - def self.j_api_type - @@j_api_type - end - def self.j_class - Java::IoVertxExtAuthOauth2Providers::GithubAuth.java_class - end - # Create a OAuth2Auth provider for Gtihub - # @param [::Vertx::Vertx] vertx - # @param [String] clientId the client id given to you by Github - # @param [String] clientSecret the client secret given to you by Github - # @param [Hash] httpClientOptions custom http client options - # @return [::VertxAuthOauth2::OAuth2Auth] - def self.create(vertx=nil,clientId=nil,clientSecret=nil,httpClientOptions=nil) - if vertx.class.method_defined?(:j_del) && clientId.class == String && clientSecret.class == String && !block_given? && httpClientOptions == nil - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2Providers::GithubAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class]).call(vertx.j_del,clientId,clientSecret),::VertxAuthOauth2::OAuth2Auth) - elsif vertx.class.method_defined?(:j_del) && clientId.class == String && clientSecret.class == String && httpClientOptions.class == Hash && !block_given? - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2Providers::GithubAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class,Java::IoVertxCoreHttp::HttpClientOptions.java_class]).call(vertx.j_del,clientId,clientSecret,Java::IoVertxCoreHttp::HttpClientOptions.new(::Vertx::Util::Utils.to_json_object(httpClientOptions))),::VertxAuthOauth2::OAuth2Auth) - end - raise ArgumentError, "Invalid arguments when calling create(#{vertx},#{clientId},#{clientSecret},#{httpClientOptions})" - end - end -end diff --git a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/google_auth.rb b/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/google_auth.rb deleted file mode 100644 index 4f8747a51..000000000 --- a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/google_auth.rb +++ /dev/null @@ -1,65 +0,0 @@ -require 'vertx/vertx' -require 'vertx-auth-oauth2/o_auth2_auth' -require 'vertx/util/utils.rb' -# Generated from io.vertx.ext.auth.oauth2.providers.GoogleAuth -module VertxAuthOauth2 - # Simplified factory to create an {::VertxAuthOauth2::OAuth2Auth} for Google. - class GoogleAuth - # @private - # @param j_del [::VertxAuthOauth2::GoogleAuth] the java delegate - def initialize(j_del) - @j_del = j_del - end - # @private - # @return [::VertxAuthOauth2::GoogleAuth] the underlying java delegate - def j_del - @j_del - end - @@j_api_type = Object.new - def @@j_api_type.accept?(obj) - obj.class == GoogleAuth - end - def @@j_api_type.wrap(obj) - GoogleAuth.new(obj) - end - def @@j_api_type.unwrap(obj) - obj.j_del - end - def self.j_api_type - @@j_api_type - end - def self.j_class - Java::IoVertxExtAuthOauth2Providers::GoogleAuth.java_class - end - # Create a OAuth2Auth provider for Google - # @overload create(vertx,serviceAccountJson) - # @param [::Vertx::Vertx] vertx - # @param [Hash{String => Object}] serviceAccountJson the configuration json file from your Google API page - # @overload create(vertx,clientId,clientSecret) - # @param [::Vertx::Vertx] vertx - # @param [String] clientId the client id given to you by Google - # @param [String] clientSecret the client secret given to you by Google - # @overload create(vertx,serviceAccountJson,httpClientOptions) - # @param [::Vertx::Vertx] vertx - # @param [Hash{String => Object}] serviceAccountJson the configuration json file from your Google API page - # @param [Hash] httpClientOptions custom http client options - # @overload create(vertx,clientId,clientSecret,httpClientOptions) - # @param [::Vertx::Vertx] vertx - # @param [String] clientId the client id given to you by Google - # @param [String] clientSecret the client secret given to you by Google - # @param [Hash] httpClientOptions custom http client options - # @return [::VertxAuthOauth2::OAuth2Auth] - def self.create(param_1=nil,param_2=nil,param_3=nil,param_4=nil) - if param_1.class.method_defined?(:j_del) && param_2.class == Hash && !block_given? && param_3 == nil && param_4 == nil - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2Providers::GoogleAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxCoreJson::JsonObject.java_class]).call(param_1.j_del,::Vertx::Util::Utils.to_json_object(param_2)),::VertxAuthOauth2::OAuth2Auth) - elsif param_1.class.method_defined?(:j_del) && param_2.class == String && param_3.class == String && !block_given? && param_4 == nil - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2Providers::GoogleAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class]).call(param_1.j_del,param_2,param_3),::VertxAuthOauth2::OAuth2Auth) - elsif param_1.class.method_defined?(:j_del) && param_2.class == Hash && param_3.class == Hash && !block_given? && param_4 == nil - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2Providers::GoogleAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxCoreJson::JsonObject.java_class,Java::IoVertxCoreHttp::HttpClientOptions.java_class]).call(param_1.j_del,::Vertx::Util::Utils.to_json_object(param_2),Java::IoVertxCoreHttp::HttpClientOptions.new(::Vertx::Util::Utils.to_json_object(param_3))),::VertxAuthOauth2::OAuth2Auth) - elsif param_1.class.method_defined?(:j_del) && param_2.class == String && param_3.class == String && param_4.class == Hash && !block_given? - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2Providers::GoogleAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class,Java::IoVertxCoreHttp::HttpClientOptions.java_class]).call(param_1.j_del,param_2,param_3,Java::IoVertxCoreHttp::HttpClientOptions.new(::Vertx::Util::Utils.to_json_object(param_4))),::VertxAuthOauth2::OAuth2Auth) - end - raise ArgumentError, "Invalid arguments when calling create(#{param_1},#{param_2},#{param_3},#{param_4})" - end - end -end diff --git a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/heroku_auth.rb b/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/heroku_auth.rb deleted file mode 100644 index d92baa680..000000000 --- a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/heroku_auth.rb +++ /dev/null @@ -1,49 +0,0 @@ -require 'vertx/vertx' -require 'vertx-auth-oauth2/o_auth2_auth' -require 'vertx/util/utils.rb' -# Generated from io.vertx.ext.auth.oauth2.providers.HerokuAuth -module VertxAuthOauth2 - # Simplified factory to create an for Heroku. - class HerokuAuth - # @private - # @param j_del [::VertxAuthOauth2::HerokuAuth] the java delegate - def initialize(j_del) - @j_del = j_del - end - # @private - # @return [::VertxAuthOauth2::HerokuAuth] the underlying java delegate - def j_del - @j_del - end - @@j_api_type = Object.new - def @@j_api_type.accept?(obj) - obj.class == HerokuAuth - end - def @@j_api_type.wrap(obj) - HerokuAuth.new(obj) - end - def @@j_api_type.unwrap(obj) - obj.j_del - end - def self.j_api_type - @@j_api_type - end - def self.j_class - Java::IoVertxExtAuthOauth2Providers::HerokuAuth.java_class - end - # Create a OAuth2Auth provider for live.com - # @param [::Vertx::Vertx] vertx - # @param [String] clientId the client id given to you by Heroku - # @param [String] clientSecret the client secret given to you by Heroku - # @param [Hash] httpClientOptions custom http client options - # @return [::VertxAuthOauth2::OAuth2Auth] - def self.create(vertx=nil,clientId=nil,clientSecret=nil,httpClientOptions=nil) - if vertx.class.method_defined?(:j_del) && clientId.class == String && clientSecret.class == String && !block_given? && httpClientOptions == nil - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2Providers::HerokuAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class]).call(vertx.j_del,clientId,clientSecret),::VertxAuthOauth2::OAuth2Auth) - elsif vertx.class.method_defined?(:j_del) && clientId.class == String && clientSecret.class == String && httpClientOptions.class == Hash && !block_given? - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2Providers::HerokuAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class,Java::IoVertxCoreHttp::HttpClientOptions.java_class]).call(vertx.j_del,clientId,clientSecret,Java::IoVertxCoreHttp::HttpClientOptions.new(::Vertx::Util::Utils.to_json_object(httpClientOptions))),::VertxAuthOauth2::OAuth2Auth) - end - raise ArgumentError, "Invalid arguments when calling create(#{vertx},#{clientId},#{clientSecret},#{httpClientOptions})" - end - end -end diff --git a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/instagram_auth.rb b/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/instagram_auth.rb deleted file mode 100644 index d2d197de3..000000000 --- a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/instagram_auth.rb +++ /dev/null @@ -1,49 +0,0 @@ -require 'vertx/vertx' -require 'vertx-auth-oauth2/o_auth2_auth' -require 'vertx/util/utils.rb' -# Generated from io.vertx.ext.auth.oauth2.providers.InstagramAuth -module VertxAuthOauth2 - # Simplified factory to create an for Instagram. - class InstagramAuth - # @private - # @param j_del [::VertxAuthOauth2::InstagramAuth] the java delegate - def initialize(j_del) - @j_del = j_del - end - # @private - # @return [::VertxAuthOauth2::InstagramAuth] the underlying java delegate - def j_del - @j_del - end - @@j_api_type = Object.new - def @@j_api_type.accept?(obj) - obj.class == InstagramAuth - end - def @@j_api_type.wrap(obj) - InstagramAuth.new(obj) - end - def @@j_api_type.unwrap(obj) - obj.j_del - end - def self.j_api_type - @@j_api_type - end - def self.j_class - Java::IoVertxExtAuthOauth2Providers::InstagramAuth.java_class - end - # Create a OAuth2Auth provider for Instagram - # @param [::Vertx::Vertx] vertx - # @param [String] clientId the client id given to you by Instagram - # @param [String] clientSecret the client secret given to you by Instagram - # @param [Hash] httpClientOptions custom http client options - # @return [::VertxAuthOauth2::OAuth2Auth] - def self.create(vertx=nil,clientId=nil,clientSecret=nil,httpClientOptions=nil) - if vertx.class.method_defined?(:j_del) && clientId.class == String && clientSecret.class == String && !block_given? && httpClientOptions == nil - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2Providers::InstagramAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class]).call(vertx.j_del,clientId,clientSecret),::VertxAuthOauth2::OAuth2Auth) - elsif vertx.class.method_defined?(:j_del) && clientId.class == String && clientSecret.class == String && httpClientOptions.class == Hash && !block_given? - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2Providers::InstagramAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class,Java::IoVertxCoreHttp::HttpClientOptions.java_class]).call(vertx.j_del,clientId,clientSecret,Java::IoVertxCoreHttp::HttpClientOptions.new(::Vertx::Util::Utils.to_json_object(httpClientOptions))),::VertxAuthOauth2::OAuth2Auth) - end - raise ArgumentError, "Invalid arguments when calling create(#{vertx},#{clientId},#{clientSecret},#{httpClientOptions})" - end - end -end diff --git a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/keycloak_auth.rb b/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/keycloak_auth.rb deleted file mode 100644 index 0a602a672..000000000 --- a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/keycloak_auth.rb +++ /dev/null @@ -1,65 +0,0 @@ -require 'vertx/vertx' -require 'vertx-auth-oauth2/o_auth2_auth' -require 'vertx/util/utils.rb' -# Generated from io.vertx.ext.auth.oauth2.providers.KeycloakAuth -module VertxAuthOauth2 - # Simplified factory to create an for Keycloak. - class KeycloakAuth - # @private - # @param j_del [::VertxAuthOauth2::KeycloakAuth] the java delegate - def initialize(j_del) - @j_del = j_del - end - # @private - # @return [::VertxAuthOauth2::KeycloakAuth] the underlying java delegate - def j_del - @j_del - end - @@j_api_type = Object.new - def @@j_api_type.accept?(obj) - obj.class == KeycloakAuth - end - def @@j_api_type.wrap(obj) - KeycloakAuth.new(obj) - end - def @@j_api_type.unwrap(obj) - obj.j_del - end - def self.j_api_type - @@j_api_type - end - def self.j_class - Java::IoVertxExtAuthOauth2Providers::KeycloakAuth.java_class - end - # Create a OAuth2Auth provider for Keycloak - # @overload create(vertx,config) - # @param [::Vertx::Vertx] vertx - # @param [Hash{String => Object}] config the json config file exported from Keycloak admin console - # @overload create(vertx,flow,config) - # @param [::Vertx::Vertx] vertx - # @param [:AUTH_CODE,:CLIENT,:PASSWORD,:AUTH_JWT] flow the oauth2 flow to use - # @param [Hash{String => Object}] config the json config file exported from Keycloak admin console - # @overload create(vertx,config,httpClientOptions) - # @param [::Vertx::Vertx] vertx - # @param [Hash{String => Object}] config the json config file exported from Keycloak admin console - # @param [Hash] httpClientOptions custom http client options - # @overload create(vertx,flow,config,httpClientOptions) - # @param [::Vertx::Vertx] vertx - # @param [:AUTH_CODE,:CLIENT,:PASSWORD,:AUTH_JWT] flow the oauth2 flow to use - # @param [Hash{String => Object}] config the json config file exported from Keycloak admin console - # @param [Hash] httpClientOptions custom http client options - # @return [::VertxAuthOauth2::OAuth2Auth] - def self.create(param_1=nil,param_2=nil,param_3=nil,param_4=nil) - if param_1.class.method_defined?(:j_del) && param_2.class == Hash && !block_given? && param_3 == nil && param_4 == nil - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2Providers::KeycloakAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxCoreJson::JsonObject.java_class]).call(param_1.j_del,::Vertx::Util::Utils.to_json_object(param_2)),::VertxAuthOauth2::OAuth2Auth) - elsif param_1.class.method_defined?(:j_del) && param_2.class == Symbol && param_3.class == Hash && !block_given? && param_4 == nil - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2Providers::KeycloakAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxExtAuthOauth2::OAuth2FlowType.java_class,Java::IoVertxCoreJson::JsonObject.java_class]).call(param_1.j_del,Java::IoVertxExtAuthOauth2::OAuth2FlowType.valueOf(param_2.to_s),::Vertx::Util::Utils.to_json_object(param_3)),::VertxAuthOauth2::OAuth2Auth) - elsif param_1.class.method_defined?(:j_del) && param_2.class == Hash && param_3.class == Hash && !block_given? && param_4 == nil - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2Providers::KeycloakAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxCoreJson::JsonObject.java_class,Java::IoVertxCoreHttp::HttpClientOptions.java_class]).call(param_1.j_del,::Vertx::Util::Utils.to_json_object(param_2),Java::IoVertxCoreHttp::HttpClientOptions.new(::Vertx::Util::Utils.to_json_object(param_3))),::VertxAuthOauth2::OAuth2Auth) - elsif param_1.class.method_defined?(:j_del) && param_2.class == Symbol && param_3.class == Hash && param_4.class == Hash && !block_given? - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2Providers::KeycloakAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxExtAuthOauth2::OAuth2FlowType.java_class,Java::IoVertxCoreJson::JsonObject.java_class,Java::IoVertxCoreHttp::HttpClientOptions.java_class]).call(param_1.j_del,Java::IoVertxExtAuthOauth2::OAuth2FlowType.valueOf(param_2.to_s),::Vertx::Util::Utils.to_json_object(param_3),Java::IoVertxCoreHttp::HttpClientOptions.new(::Vertx::Util::Utils.to_json_object(param_4))),::VertxAuthOauth2::OAuth2Auth) - end - raise ArgumentError, "Invalid arguments when calling create(#{param_1},#{param_2},#{param_3},#{param_4})" - end - end -end diff --git a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/keycloak_helper.rb b/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/keycloak_helper.rb deleted file mode 100644 index f851bcef2..000000000 --- a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/keycloak_helper.rb +++ /dev/null @@ -1,143 +0,0 @@ -require 'vertx/util/utils.rb' -# Generated from io.vertx.ext.auth.oauth2.KeycloakHelper -module VertxAuthOauth2 - # Helper class for processing Keycloak principal. - class KeycloakHelper - # @private - # @param j_del [::VertxAuthOauth2::KeycloakHelper] the java delegate - def initialize(j_del) - @j_del = j_del - end - # @private - # @return [::VertxAuthOauth2::KeycloakHelper] the underlying java delegate - def j_del - @j_del - end - @@j_api_type = Object.new - def @@j_api_type.accept?(obj) - obj.class == KeycloakHelper - end - def @@j_api_type.wrap(obj) - KeycloakHelper.new(obj) - end - def @@j_api_type.unwrap(obj) - obj.j_del - end - def self.j_api_type - @@j_api_type - end - def self.j_class - Java::IoVertxExtAuthOauth2::KeycloakHelper.java_class - end - # Get raw `id_token` string from the principal. - # @param [Hash{String => Object}] principal user principal - # @return [String] the raw id token string - def self.raw_id_token(principal=nil) - if principal.class == Hash && !block_given? - return Java::IoVertxExtAuthOauth2::KeycloakHelper.java_method(:rawIdToken, [Java::IoVertxCoreJson::JsonObject.java_class]).call(::Vertx::Util::Utils.to_json_object(principal)) - end - raise ArgumentError, "Invalid arguments when calling raw_id_token(#{principal})" - end - # Get decoded `id_token` from the principal. - # @param [Hash{String => Object}] principal user principal - # @return [Hash{String => Object}] the id token - def self.id_token(principal=nil) - if principal.class == Hash && !block_given? - return Java::IoVertxExtAuthOauth2::KeycloakHelper.java_method(:idToken, [Java::IoVertxCoreJson::JsonObject.java_class]).call(::Vertx::Util::Utils.to_json_object(principal)) != nil ? JSON.parse(Java::IoVertxExtAuthOauth2::KeycloakHelper.java_method(:idToken, [Java::IoVertxCoreJson::JsonObject.java_class]).call(::Vertx::Util::Utils.to_json_object(principal)).encode) : nil - end - raise ArgumentError, "Invalid arguments when calling id_token(#{principal})" - end - # Get raw `access_token` string from the principal. - # @param [Hash{String => Object}] principal user principal - # @return [String] the raw access token string - def self.raw_access_token(principal=nil) - if principal.class == Hash && !block_given? - return Java::IoVertxExtAuthOauth2::KeycloakHelper.java_method(:rawAccessToken, [Java::IoVertxCoreJson::JsonObject.java_class]).call(::Vertx::Util::Utils.to_json_object(principal)) - end - raise ArgumentError, "Invalid arguments when calling raw_access_token(#{principal})" - end - # Get decoded `access_token` from the principal. - # @param [Hash{String => Object}] principal user principal - # @return [Hash{String => Object}] the access token - def self.access_token(principal=nil) - if principal.class == Hash && !block_given? - return Java::IoVertxExtAuthOauth2::KeycloakHelper.java_method(:accessToken, [Java::IoVertxCoreJson::JsonObject.java_class]).call(::Vertx::Util::Utils.to_json_object(principal)) != nil ? JSON.parse(Java::IoVertxExtAuthOauth2::KeycloakHelper.java_method(:accessToken, [Java::IoVertxCoreJson::JsonObject.java_class]).call(::Vertx::Util::Utils.to_json_object(principal)).encode) : nil - end - raise ArgumentError, "Invalid arguments when calling access_token(#{principal})" - end - # @param [Hash{String => Object}] principal - # @return [Fixnum] - def self.auth_time(principal=nil) - if principal.class == Hash && !block_given? - return Java::IoVertxExtAuthOauth2::KeycloakHelper.java_method(:authTime, [Java::IoVertxCoreJson::JsonObject.java_class]).call(::Vertx::Util::Utils.to_json_object(principal)) - end - raise ArgumentError, "Invalid arguments when calling auth_time(#{principal})" - end - # @param [Hash{String => Object}] principal - # @return [String] - def self.session_state(principal=nil) - if principal.class == Hash && !block_given? - return Java::IoVertxExtAuthOauth2::KeycloakHelper.java_method(:sessionState, [Java::IoVertxCoreJson::JsonObject.java_class]).call(::Vertx::Util::Utils.to_json_object(principal)) - end - raise ArgumentError, "Invalid arguments when calling session_state(#{principal})" - end - # @param [Hash{String => Object}] principal - # @return [String] - def self.acr(principal=nil) - if principal.class == Hash && !block_given? - return Java::IoVertxExtAuthOauth2::KeycloakHelper.java_method(:acr, [Java::IoVertxCoreJson::JsonObject.java_class]).call(::Vertx::Util::Utils.to_json_object(principal)) - end - raise ArgumentError, "Invalid arguments when calling acr(#{principal})" - end - # @param [Hash{String => Object}] principal - # @return [String] - def self.name(principal=nil) - if principal.class == Hash && !block_given? - return Java::IoVertxExtAuthOauth2::KeycloakHelper.java_method(:name, [Java::IoVertxCoreJson::JsonObject.java_class]).call(::Vertx::Util::Utils.to_json_object(principal)) - end - raise ArgumentError, "Invalid arguments when calling name(#{principal})" - end - # @param [Hash{String => Object}] principal - # @return [String] - def self.email(principal=nil) - if principal.class == Hash && !block_given? - return Java::IoVertxExtAuthOauth2::KeycloakHelper.java_method(:email, [Java::IoVertxCoreJson::JsonObject.java_class]).call(::Vertx::Util::Utils.to_json_object(principal)) - end - raise ArgumentError, "Invalid arguments when calling email(#{principal})" - end - # @param [Hash{String => Object}] principal - # @return [String] - def self.preferred_username(principal=nil) - if principal.class == Hash && !block_given? - return Java::IoVertxExtAuthOauth2::KeycloakHelper.java_method(:preferredUsername, [Java::IoVertxCoreJson::JsonObject.java_class]).call(::Vertx::Util::Utils.to_json_object(principal)) - end - raise ArgumentError, "Invalid arguments when calling preferred_username(#{principal})" - end - # @param [Hash{String => Object}] principal - # @return [String] - def self.nick_name(principal=nil) - if principal.class == Hash && !block_given? - return Java::IoVertxExtAuthOauth2::KeycloakHelper.java_method(:nickName, [Java::IoVertxCoreJson::JsonObject.java_class]).call(::Vertx::Util::Utils.to_json_object(principal)) - end - raise ArgumentError, "Invalid arguments when calling nick_name(#{principal})" - end - # @param [Hash{String => Object}] principal - # @return [Set] - def self.allowed_origins(principal=nil) - if principal.class == Hash && !block_given? - return ::Vertx::Util::Utils.to_set(Java::IoVertxExtAuthOauth2::KeycloakHelper.java_method(:allowedOrigins, [Java::IoVertxCoreJson::JsonObject.java_class]).call(::Vertx::Util::Utils.to_json_object(principal))).map! { |elt| elt } - end - raise ArgumentError, "Invalid arguments when calling allowed_origins(#{principal})" - end - # Parse the token string with base64 decoder. - # This will only obtain the "payload" part of the token. - # @param [String] token token string - # @return [Hash{String => Object}] token payload json object - def self.parse_token(token=nil) - if token.class == String && !block_given? - return Java::IoVertxExtAuthOauth2::KeycloakHelper.java_method(:parseToken, [Java::java.lang.String.java_class]).call(token) != nil ? JSON.parse(Java::IoVertxExtAuthOauth2::KeycloakHelper.java_method(:parseToken, [Java::java.lang.String.java_class]).call(token).encode) : nil - end - raise ArgumentError, "Invalid arguments when calling parse_token(#{token})" - end - end -end diff --git a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/linked_in_auth.rb b/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/linked_in_auth.rb deleted file mode 100644 index f4d0ee67a..000000000 --- a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/linked_in_auth.rb +++ /dev/null @@ -1,49 +0,0 @@ -require 'vertx/vertx' -require 'vertx-auth-oauth2/o_auth2_auth' -require 'vertx/util/utils.rb' -# Generated from io.vertx.ext.auth.oauth2.providers.LinkedInAuth -module VertxAuthOauth2 - # Simplified factory to create an for LinkedIn. - class LinkedInAuth - # @private - # @param j_del [::VertxAuthOauth2::LinkedInAuth] the java delegate - def initialize(j_del) - @j_del = j_del - end - # @private - # @return [::VertxAuthOauth2::LinkedInAuth] the underlying java delegate - def j_del - @j_del - end - @@j_api_type = Object.new - def @@j_api_type.accept?(obj) - obj.class == LinkedInAuth - end - def @@j_api_type.wrap(obj) - LinkedInAuth.new(obj) - end - def @@j_api_type.unwrap(obj) - obj.j_del - end - def self.j_api_type - @@j_api_type - end - def self.j_class - Java::IoVertxExtAuthOauth2Providers::LinkedInAuth.java_class - end - # Create a OAuth2Auth provider for LinkedIn - # @param [::Vertx::Vertx] vertx - # @param [String] clientId the client id given to you by LinkedIn - # @param [String] clientSecret the client secret given to you by LinkedIn - # @param [Hash] httpClientOptions custom http client options - # @return [::VertxAuthOauth2::OAuth2Auth] - def self.create(vertx=nil,clientId=nil,clientSecret=nil,httpClientOptions=nil) - if vertx.class.method_defined?(:j_del) && clientId.class == String && clientSecret.class == String && !block_given? && httpClientOptions == nil - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2Providers::LinkedInAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class]).call(vertx.j_del,clientId,clientSecret),::VertxAuthOauth2::OAuth2Auth) - elsif vertx.class.method_defined?(:j_del) && clientId.class == String && clientSecret.class == String && httpClientOptions.class == Hash && !block_given? - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2Providers::LinkedInAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class,Java::IoVertxCoreHttp::HttpClientOptions.java_class]).call(vertx.j_del,clientId,clientSecret,Java::IoVertxCoreHttp::HttpClientOptions.new(::Vertx::Util::Utils.to_json_object(httpClientOptions))),::VertxAuthOauth2::OAuth2Auth) - end - raise ArgumentError, "Invalid arguments when calling create(#{vertx},#{clientId},#{clientSecret},#{httpClientOptions})" - end - end -end diff --git a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/live_auth.rb b/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/live_auth.rb deleted file mode 100644 index 73d80760f..000000000 --- a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/live_auth.rb +++ /dev/null @@ -1,49 +0,0 @@ -require 'vertx/vertx' -require 'vertx-auth-oauth2/o_auth2_auth' -require 'vertx/util/utils.rb' -# Generated from io.vertx.ext.auth.oauth2.providers.LiveAuth -module VertxAuthOauth2 - # Simplified factory to create an for live.com Services. - class LiveAuth - # @private - # @param j_del [::VertxAuthOauth2::LiveAuth] the java delegate - def initialize(j_del) - @j_del = j_del - end - # @private - # @return [::VertxAuthOauth2::LiveAuth] the underlying java delegate - def j_del - @j_del - end - @@j_api_type = Object.new - def @@j_api_type.accept?(obj) - obj.class == LiveAuth - end - def @@j_api_type.wrap(obj) - LiveAuth.new(obj) - end - def @@j_api_type.unwrap(obj) - obj.j_del - end - def self.j_api_type - @@j_api_type - end - def self.j_class - Java::IoVertxExtAuthOauth2Providers::LiveAuth.java_class - end - # Create a OAuth2Auth provider for live.com - # @param [::Vertx::Vertx] vertx - # @param [String] clientId the client id given to you by live.com - # @param [String] clientSecret the client secret given to you by live.com - # @param [Hash] httpClientOptions custom http client options - # @return [::VertxAuthOauth2::OAuth2Auth] - def self.create(vertx=nil,clientId=nil,clientSecret=nil,httpClientOptions=nil) - if vertx.class.method_defined?(:j_del) && clientId.class == String && clientSecret.class == String && !block_given? && httpClientOptions == nil - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2Providers::LiveAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class]).call(vertx.j_del,clientId,clientSecret),::VertxAuthOauth2::OAuth2Auth) - elsif vertx.class.method_defined?(:j_del) && clientId.class == String && clientSecret.class == String && httpClientOptions.class == Hash && !block_given? - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2Providers::LiveAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class,Java::IoVertxCoreHttp::HttpClientOptions.java_class]).call(vertx.j_del,clientId,clientSecret,Java::IoVertxCoreHttp::HttpClientOptions.new(::Vertx::Util::Utils.to_json_object(httpClientOptions))),::VertxAuthOauth2::OAuth2Auth) - end - raise ArgumentError, "Invalid arguments when calling create(#{vertx},#{clientId},#{clientSecret},#{httpClientOptions})" - end - end -end diff --git a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/mailchimp_auth.rb b/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/mailchimp_auth.rb deleted file mode 100644 index 8f869b87f..000000000 --- a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/mailchimp_auth.rb +++ /dev/null @@ -1,49 +0,0 @@ -require 'vertx/vertx' -require 'vertx-auth-oauth2/o_auth2_auth' -require 'vertx/util/utils.rb' -# Generated from io.vertx.ext.auth.oauth2.providers.MailchimpAuth -module VertxAuthOauth2 - # Simplified factory to create an for Mailchimp. - class MailchimpAuth - # @private - # @param j_del [::VertxAuthOauth2::MailchimpAuth] the java delegate - def initialize(j_del) - @j_del = j_del - end - # @private - # @return [::VertxAuthOauth2::MailchimpAuth] the underlying java delegate - def j_del - @j_del - end - @@j_api_type = Object.new - def @@j_api_type.accept?(obj) - obj.class == MailchimpAuth - end - def @@j_api_type.wrap(obj) - MailchimpAuth.new(obj) - end - def @@j_api_type.unwrap(obj) - obj.j_del - end - def self.j_api_type - @@j_api_type - end - def self.j_class - Java::IoVertxExtAuthOauth2Providers::MailchimpAuth.java_class - end - # Create a OAuth2Auth provider for Dropbox - # @param [::Vertx::Vertx] vertx - # @param [String] clientId the client id given to you by Mailchimp - # @param [String] clientSecret the client secret given to you by Mailchimp - # @param [Hash] httpClientOptions custom http client options - # @return [::VertxAuthOauth2::OAuth2Auth] - def self.create(vertx=nil,clientId=nil,clientSecret=nil,httpClientOptions=nil) - if vertx.class.method_defined?(:j_del) && clientId.class == String && clientSecret.class == String && !block_given? && httpClientOptions == nil - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2Providers::MailchimpAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class]).call(vertx.j_del,clientId,clientSecret),::VertxAuthOauth2::OAuth2Auth) - elsif vertx.class.method_defined?(:j_del) && clientId.class == String && clientSecret.class == String && httpClientOptions.class == Hash && !block_given? - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2Providers::MailchimpAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class,Java::IoVertxCoreHttp::HttpClientOptions.java_class]).call(vertx.j_del,clientId,clientSecret,Java::IoVertxCoreHttp::HttpClientOptions.new(::Vertx::Util::Utils.to_json_object(httpClientOptions))),::VertxAuthOauth2::OAuth2Auth) - end - raise ArgumentError, "Invalid arguments when calling create(#{vertx},#{clientId},#{clientSecret},#{httpClientOptions})" - end - end -end diff --git a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/o_auth2_auth.rb b/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/o_auth2_auth.rb deleted file mode 100644 index fda493f9c..000000000 --- a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/o_auth2_auth.rb +++ /dev/null @@ -1,155 +0,0 @@ -require 'vertx-auth-common/user' -require 'vertx/vertx' -require 'vertx-auth-oauth2/access_token' -require 'vertx-auth-common/auth_provider' -require 'vertx/util/utils.rb' -# Generated from io.vertx.ext.auth.oauth2.OAuth2Auth -module VertxAuthOauth2 - # Factory interface for creating OAuth2 based {::VertxAuthCommon::AuthProvider} instances. - class OAuth2Auth < ::VertxAuthCommon::AuthProvider - # @private - # @param j_del [::VertxAuthOauth2::OAuth2Auth] the java delegate - def initialize(j_del) - super(j_del) - @j_del = j_del - end - # @private - # @return [::VertxAuthOauth2::OAuth2Auth] the underlying java delegate - def j_del - @j_del - end - @@j_api_type = Object.new - def @@j_api_type.accept?(obj) - obj.class == OAuth2Auth - end - def @@j_api_type.wrap(obj) - OAuth2Auth.new(obj) - end - def @@j_api_type.unwrap(obj) - obj.j_del - end - def self.j_api_type - @@j_api_type - end - def self.j_class - Java::IoVertxExtAuthOauth2::OAuth2Auth.java_class - end - # @param [Hash{String => Object}] arg0 - # @yield - # @return [void] - def authenticate(arg0=nil) - if arg0.class == Hash && block_given? - return @j_del.java_method(:authenticate, [Java::IoVertxCoreJson::JsonObject.java_class,Java::IoVertxCore::Handler.java_class]).call(::Vertx::Util::Utils.to_json_object(arg0),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxAuthCommon::User) : nil) })) - end - raise ArgumentError, "Invalid arguments when calling authenticate(#{arg0})" - end - # @param [::Vertx::Vertx] vertx the Vertx instance - # @param [:AUTH_CODE,:CLIENT,:PASSWORD,:AUTH_JWT] flow - # @param [Hash{String => Object}] config the config as exported from the admin console - # @return [::VertxAuthOauth2::OAuth2Auth] the auth provider - def self.create_keycloak(vertx=nil,flow=nil,config=nil) - if vertx.class.method_defined?(:j_del) && flow.class == Symbol && config.class == Hash && !block_given? - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2::OAuth2Auth.java_method(:createKeycloak, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxExtAuthOauth2::OAuth2FlowType.java_class,Java::IoVertxCoreJson::JsonObject.java_class]).call(vertx.j_del,Java::IoVertxExtAuthOauth2::OAuth2FlowType.valueOf(flow.to_s),::Vertx::Util::Utils.to_json_object(config)),::VertxAuthOauth2::OAuth2Auth) - end - raise ArgumentError, "Invalid arguments when calling create_keycloak(#{vertx},#{flow},#{config})" - end - # Create a OAuth2 auth provider - # @param [::Vertx::Vertx] vertx the Vertx instance - # @param [:AUTH_CODE,:CLIENT,:PASSWORD,:AUTH_JWT] flow - # @param [Hash] config the config - # @return [::VertxAuthOauth2::OAuth2Auth] the auth provider - def self.create(vertx=nil,flow=nil,config=nil) - if vertx.class.method_defined?(:j_del) && flow.class == Symbol && !block_given? && config == nil - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2::OAuth2Auth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxExtAuthOauth2::OAuth2FlowType.java_class]).call(vertx.j_del,Java::IoVertxExtAuthOauth2::OAuth2FlowType.valueOf(flow.to_s)),::VertxAuthOauth2::OAuth2Auth) - elsif vertx.class.method_defined?(:j_del) && flow.class == Symbol && config.class == Hash && !block_given? - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2::OAuth2Auth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxExtAuthOauth2::OAuth2FlowType.java_class,Java::IoVertxExtAuthOauth2::OAuth2ClientOptions.java_class]).call(vertx.j_del,Java::IoVertxExtAuthOauth2::OAuth2FlowType.valueOf(flow.to_s),Java::IoVertxExtAuthOauth2::OAuth2ClientOptions.new(::Vertx::Util::Utils.to_json_object(config))),::VertxAuthOauth2::OAuth2Auth) - end - raise ArgumentError, "Invalid arguments when calling create(#{vertx},#{flow},#{config})" - end - # Generate a redirect URL to the authN/Z backend. It only applies to auth_code flow. - # @param [Hash{String => Object}] params - # @return [String] - def authorize_url(params=nil) - if params.class == Hash && !block_given? - return @j_del.java_method(:authorizeURL, [Java::IoVertxCoreJson::JsonObject.java_class]).call(::Vertx::Util::Utils.to_json_object(params)) - end - raise ArgumentError, "Invalid arguments when calling authorize_url(#{params})" - end - # Returns the Access Token object. - # @param [Hash{String => Object}] params - JSON with the options, each flow requires different options. - # @yield - The handler returning the results. - # @return [void] - def get_token(params=nil) - if params.class == Hash && block_given? - return @j_del.java_method(:getToken, [Java::IoVertxCoreJson::JsonObject.java_class,Java::IoVertxCore::Handler.java_class]).call(::Vertx::Util::Utils.to_json_object(params),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxAuthOauth2::AccessToken) : nil) })) - end - raise ArgumentError, "Invalid arguments when calling get_token(#{params})" - end - # Call OAuth2 APIs. - # @param [:OPTIONS,:GET,:HEAD,:POST,:PUT,:DELETE,:TRACE,:CONNECT,:PATCH,:OTHER] method HttpMethod - # @param [String] path target path - # @param [Hash{String => Object}] params parameters - # @yield handler - # @return [self] - def api(method=nil,path=nil,params=nil) - if method.class == Symbol && path.class == String && params.class == Hash && block_given? - @j_del.java_method(:api, [Java::IoVertxCoreHttp::HttpMethod.java_class,Java::java.lang.String.java_class,Java::IoVertxCoreJson::JsonObject.java_class,Java::IoVertxCore::Handler.java_class]).call(Java::IoVertxCoreHttp::HttpMethod.valueOf(method.to_s),path,::Vertx::Util::Utils.to_json_object(params),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.encode) : nil : nil) })) - return self - end - raise ArgumentError, "Invalid arguments when calling api(#{method},#{path},#{params})" - end - # Returns true if this provider supports JWT tokens as the access_token. This is typically true if the provider - # implements the `openid-connect` protocol. This is a plain return from the config option jwtToken, which is false - # by default. - # - # This information is important to validate grants. Since pure OAuth2 should be used for authorization and when a - # token is requested all grants should be declared, in case of openid-connect this is not true. OpenId will issue - # a token and all grants will be encoded on the token itself so the requester does not need to list the required - # grants. - # @return [true,false] true if openid-connect is used. - def has_jwt_token? - if !block_given? - return @j_del.java_method(:hasJWTToken, []).call() - end - raise ArgumentError, "Invalid arguments when calling has_jwt_token?()" - end - # Decode a token to a {::VertxAuthOauth2::AccessToken} object. This is useful to handle bearer JWT tokens. - # @param [String] token the access token (base64 string) - # @yield A handler to receive the event - # @return [self] - def decode_token(token=nil) - if token.class == String && block_given? - @j_del.java_method(:decodeToken, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(token,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxAuthOauth2::AccessToken) : nil) })) - return self - end - raise ArgumentError, "Invalid arguments when calling decode_token(#{token})" - end - # Query an OAuth 2.0 authorization server to determine the active state of an OAuth 2.0 token and to determine - # meta-information about this token. - # @param [String] token the access token (base64 string) - # @param [String] tokenType hint to the token type e.g.: `access_token` - # @yield A handler to receive the event - # @return [self] - def introspect_token(token=nil,tokenType=nil) - if token.class == String && block_given? && tokenType == nil - @j_del.java_method(:introspectToken, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(token,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxAuthOauth2::AccessToken) : nil) })) - return self - elsif token.class == String && tokenType.class == String && block_given? - @j_del.java_method(:introspectToken, [Java::java.lang.String.java_class,Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(token,tokenType,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.encode) : nil : nil) })) - return self - end - raise ArgumentError, "Invalid arguments when calling introspect_token(#{token},#{tokenType})" - end - # Returns the scope separator. - # - # The RFC 6749 states that a scope is expressed as a set of case-sensitive and space-delimited strings, however - # vendors tend not to agree on this and we see the following cases being used: space, plus sign, comma. - # @return [String] what value was used in the configuration of the object, falling back to the default value which is a space. - def get_scope_separator - if !block_given? - return @j_del.java_method(:getScopeSeparator, []).call() - end - raise ArgumentError, "Invalid arguments when calling get_scope_separator()" - end - end -end diff --git a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/salesforce_auth.rb b/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/salesforce_auth.rb deleted file mode 100644 index 71064d92c..000000000 --- a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/salesforce_auth.rb +++ /dev/null @@ -1,49 +0,0 @@ -require 'vertx/vertx' -require 'vertx-auth-oauth2/o_auth2_auth' -require 'vertx/util/utils.rb' -# Generated from io.vertx.ext.auth.oauth2.providers.SalesforceAuth -module VertxAuthOauth2 - # Simplified factory to create an for Salesforce. - class SalesforceAuth - # @private - # @param j_del [::VertxAuthOauth2::SalesforceAuth] the java delegate - def initialize(j_del) - @j_del = j_del - end - # @private - # @return [::VertxAuthOauth2::SalesforceAuth] the underlying java delegate - def j_del - @j_del - end - @@j_api_type = Object.new - def @@j_api_type.accept?(obj) - obj.class == SalesforceAuth - end - def @@j_api_type.wrap(obj) - SalesforceAuth.new(obj) - end - def @@j_api_type.unwrap(obj) - obj.j_del - end - def self.j_api_type - @@j_api_type - end - def self.j_class - Java::IoVertxExtAuthOauth2Providers::SalesforceAuth.java_class - end - # Create a OAuth2Auth provider for Salesforce - # @param [::Vertx::Vertx] vertx - # @param [String] clientId the client id given to you by Salesforce - # @param [String] clientSecret the client secret given to you by Salesforce - # @param [Hash] httpClientOptions custom http client options - # @return [::VertxAuthOauth2::OAuth2Auth] - def self.create(vertx=nil,clientId=nil,clientSecret=nil,httpClientOptions=nil) - if vertx.class.method_defined?(:j_del) && clientId.class == String && clientSecret.class == String && !block_given? && httpClientOptions == nil - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2Providers::SalesforceAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class]).call(vertx.j_del,clientId,clientSecret),::VertxAuthOauth2::OAuth2Auth) - elsif vertx.class.method_defined?(:j_del) && clientId.class == String && clientSecret.class == String && httpClientOptions.class == Hash && !block_given? - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2Providers::SalesforceAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class,Java::IoVertxCoreHttp::HttpClientOptions.java_class]).call(vertx.j_del,clientId,clientSecret,Java::IoVertxCoreHttp::HttpClientOptions.new(::Vertx::Util::Utils.to_json_object(httpClientOptions))),::VertxAuthOauth2::OAuth2Auth) - end - raise ArgumentError, "Invalid arguments when calling create(#{vertx},#{clientId},#{clientSecret},#{httpClientOptions})" - end - end -end diff --git a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/shopify_auth.rb b/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/shopify_auth.rb deleted file mode 100644 index b73d11fdc..000000000 --- a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/shopify_auth.rb +++ /dev/null @@ -1,50 +0,0 @@ -require 'vertx/vertx' -require 'vertx-auth-oauth2/o_auth2_auth' -require 'vertx/util/utils.rb' -# Generated from io.vertx.ext.auth.oauth2.providers.ShopifyAuth -module VertxAuthOauth2 - # Simplified factory to create an for Shopify. - class ShopifyAuth - # @private - # @param j_del [::VertxAuthOauth2::ShopifyAuth] the java delegate - def initialize(j_del) - @j_del = j_del - end - # @private - # @return [::VertxAuthOauth2::ShopifyAuth] the underlying java delegate - def j_del - @j_del - end - @@j_api_type = Object.new - def @@j_api_type.accept?(obj) - obj.class == ShopifyAuth - end - def @@j_api_type.wrap(obj) - ShopifyAuth.new(obj) - end - def @@j_api_type.unwrap(obj) - obj.j_del - end - def self.j_api_type - @@j_api_type - end - def self.j_class - Java::IoVertxExtAuthOauth2Providers::ShopifyAuth.java_class - end - # Create a OAuth2Auth provider for Shopify - # @param [::Vertx::Vertx] vertx - # @param [String] clientId the client id given to you by Shopify - # @param [String] clientSecret the client secret given to you by Shopify - # @param [String] shop your shop name - # @param [Hash] httpClientOptions custom http client options - # @return [::VertxAuthOauth2::OAuth2Auth] - def self.create(vertx=nil,clientId=nil,clientSecret=nil,shop=nil,httpClientOptions=nil) - if vertx.class.method_defined?(:j_del) && clientId.class == String && clientSecret.class == String && shop.class == String && !block_given? && httpClientOptions == nil - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2Providers::ShopifyAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class]).call(vertx.j_del,clientId,clientSecret,shop),::VertxAuthOauth2::OAuth2Auth) - elsif vertx.class.method_defined?(:j_del) && clientId.class == String && clientSecret.class == String && shop.class == String && httpClientOptions.class == Hash && !block_given? - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2Providers::ShopifyAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class,Java::IoVertxCoreHttp::HttpClientOptions.java_class]).call(vertx.j_del,clientId,clientSecret,shop,Java::IoVertxCoreHttp::HttpClientOptions.new(::Vertx::Util::Utils.to_json_object(httpClientOptions))),::VertxAuthOauth2::OAuth2Auth) - end - raise ArgumentError, "Invalid arguments when calling create(#{vertx},#{clientId},#{clientSecret},#{shop},#{httpClientOptions})" - end - end -end diff --git a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/soundcloud_auth.rb b/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/soundcloud_auth.rb deleted file mode 100644 index 553786260..000000000 --- a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/soundcloud_auth.rb +++ /dev/null @@ -1,49 +0,0 @@ -require 'vertx/vertx' -require 'vertx-auth-oauth2/o_auth2_auth' -require 'vertx/util/utils.rb' -# Generated from io.vertx.ext.auth.oauth2.providers.SoundcloudAuth -module VertxAuthOauth2 - # Simplified factory to create an for SoundCloud. - class SoundcloudAuth - # @private - # @param j_del [::VertxAuthOauth2::SoundcloudAuth] the java delegate - def initialize(j_del) - @j_del = j_del - end - # @private - # @return [::VertxAuthOauth2::SoundcloudAuth] the underlying java delegate - def j_del - @j_del - end - @@j_api_type = Object.new - def @@j_api_type.accept?(obj) - obj.class == SoundcloudAuth - end - def @@j_api_type.wrap(obj) - SoundcloudAuth.new(obj) - end - def @@j_api_type.unwrap(obj) - obj.j_del - end - def self.j_api_type - @@j_api_type - end - def self.j_class - Java::IoVertxExtAuthOauth2Providers::SoundcloudAuth.java_class - end - # Create a OAuth2Auth provider for Dropbox - # @param [::Vertx::Vertx] vertx - # @param [String] clientId the client id given to you by SoundCloud - # @param [String] clientSecret the client secret given to you by SoundCloud - # @param [Hash] httpClientOptions custom http client options - # @return [::VertxAuthOauth2::OAuth2Auth] - def self.create(vertx=nil,clientId=nil,clientSecret=nil,httpClientOptions=nil) - if vertx.class.method_defined?(:j_del) && clientId.class == String && clientSecret.class == String && !block_given? && httpClientOptions == nil - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2Providers::SoundcloudAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class]).call(vertx.j_del,clientId,clientSecret),::VertxAuthOauth2::OAuth2Auth) - elsif vertx.class.method_defined?(:j_del) && clientId.class == String && clientSecret.class == String && httpClientOptions.class == Hash && !block_given? - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2Providers::SoundcloudAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class,Java::IoVertxCoreHttp::HttpClientOptions.java_class]).call(vertx.j_del,clientId,clientSecret,Java::IoVertxCoreHttp::HttpClientOptions.new(::Vertx::Util::Utils.to_json_object(httpClientOptions))),::VertxAuthOauth2::OAuth2Auth) - end - raise ArgumentError, "Invalid arguments when calling create(#{vertx},#{clientId},#{clientSecret},#{httpClientOptions})" - end - end -end diff --git a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/stripe_auth.rb b/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/stripe_auth.rb deleted file mode 100644 index 7e521fbee..000000000 --- a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/stripe_auth.rb +++ /dev/null @@ -1,49 +0,0 @@ -require 'vertx/vertx' -require 'vertx-auth-oauth2/o_auth2_auth' -require 'vertx/util/utils.rb' -# Generated from io.vertx.ext.auth.oauth2.providers.StripeAuth -module VertxAuthOauth2 - # Simplified factory to create an for Stripe. - class StripeAuth - # @private - # @param j_del [::VertxAuthOauth2::StripeAuth] the java delegate - def initialize(j_del) - @j_del = j_del - end - # @private - # @return [::VertxAuthOauth2::StripeAuth] the underlying java delegate - def j_del - @j_del - end - @@j_api_type = Object.new - def @@j_api_type.accept?(obj) - obj.class == StripeAuth - end - def @@j_api_type.wrap(obj) - StripeAuth.new(obj) - end - def @@j_api_type.unwrap(obj) - obj.j_del - end - def self.j_api_type - @@j_api_type - end - def self.j_class - Java::IoVertxExtAuthOauth2Providers::StripeAuth.java_class - end - # Create a OAuth2Auth provider for Dropbox - # @param [::Vertx::Vertx] vertx - # @param [String] clientId the client id given to you by Stripe - # @param [String] clientSecret the client secret given to you by Stripe - # @param [Hash] httpClientOptions custom http client options - # @return [::VertxAuthOauth2::OAuth2Auth] - def self.create(vertx=nil,clientId=nil,clientSecret=nil,httpClientOptions=nil) - if vertx.class.method_defined?(:j_del) && clientId.class == String && clientSecret.class == String && !block_given? && httpClientOptions == nil - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2Providers::StripeAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class]).call(vertx.j_del,clientId,clientSecret),::VertxAuthOauth2::OAuth2Auth) - elsif vertx.class.method_defined?(:j_del) && clientId.class == String && clientSecret.class == String && httpClientOptions.class == Hash && !block_given? - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2Providers::StripeAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class,Java::IoVertxCoreHttp::HttpClientOptions.java_class]).call(vertx.j_del,clientId,clientSecret,Java::IoVertxCoreHttp::HttpClientOptions.new(::Vertx::Util::Utils.to_json_object(httpClientOptions))),::VertxAuthOauth2::OAuth2Auth) - end - raise ArgumentError, "Invalid arguments when calling create(#{vertx},#{clientId},#{clientSecret},#{httpClientOptions})" - end - end -end diff --git a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/twitter_auth.rb b/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/twitter_auth.rb deleted file mode 100644 index afb8796a7..000000000 --- a/vertx-auth-oauth2/src/main/resources/vertx-auth-oauth2/twitter_auth.rb +++ /dev/null @@ -1,49 +0,0 @@ -require 'vertx/vertx' -require 'vertx-auth-oauth2/o_auth2_auth' -require 'vertx/util/utils.rb' -# Generated from io.vertx.ext.auth.oauth2.providers.TwitterAuth -module VertxAuthOauth2 - # Simplified factory to create an for Twitter. - class TwitterAuth - # @private - # @param j_del [::VertxAuthOauth2::TwitterAuth] the java delegate - def initialize(j_del) - @j_del = j_del - end - # @private - # @return [::VertxAuthOauth2::TwitterAuth] the underlying java delegate - def j_del - @j_del - end - @@j_api_type = Object.new - def @@j_api_type.accept?(obj) - obj.class == TwitterAuth - end - def @@j_api_type.wrap(obj) - TwitterAuth.new(obj) - end - def @@j_api_type.unwrap(obj) - obj.j_del - end - def self.j_api_type - @@j_api_type - end - def self.j_class - Java::IoVertxExtAuthOauth2Providers::TwitterAuth.java_class - end - # Create a OAuth2Auth provider for Twitter - # @param [::Vertx::Vertx] vertx - # @param [String] clientId the client id given to you by Twitter - # @param [String] clientSecret the client secret given to you by Twitter - # @param [Hash] httpClientOptions custom http client options - # @return [::VertxAuthOauth2::OAuth2Auth] - def self.create(vertx=nil,clientId=nil,clientSecret=nil,httpClientOptions=nil) - if vertx.class.method_defined?(:j_del) && clientId.class == String && clientSecret.class == String && !block_given? && httpClientOptions == nil - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2Providers::TwitterAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class]).call(vertx.j_del,clientId,clientSecret),::VertxAuthOauth2::OAuth2Auth) - elsif vertx.class.method_defined?(:j_del) && clientId.class == String && clientSecret.class == String && httpClientOptions.class == Hash && !block_given? - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2Providers::TwitterAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class,Java::IoVertxCoreHttp::HttpClientOptions.java_class]).call(vertx.j_del,clientId,clientSecret,Java::IoVertxCoreHttp::HttpClientOptions.new(::Vertx::Util::Utils.to_json_object(httpClientOptions))),::VertxAuthOauth2::OAuth2Auth) - end - raise ArgumentError, "Invalid arguments when calling create(#{vertx},#{clientId},#{clientSecret},#{httpClientOptions})" - end - end -end diff --git a/vertx-auth-shiro/src/main/asciidoc/groovy/index.adoc b/vertx-auth-shiro/src/main/asciidoc/groovy/index.adoc index 87b5c9008..b58fbc946 100644 --- a/vertx-auth-shiro/src/main/asciidoc/groovy/index.adoc +++ b/vertx-auth-shiro/src/main/asciidoc/groovy/index.adoc @@ -12,7 +12,7 @@ project, add the following dependency to the _dependencies_ section of your buil io.vertx vertx-auth-shiro - 3.4.0.Beta1 + 3.4.0-SNAPSHOT ---- @@ -20,7 +20,7 @@ project, add the following dependency to the _dependencies_ section of your buil [source,groovy,subs="+attributes"] ---- -compile 'io.vertx:vertx-auth-shiro:3.4.0.Beta1' +compile 'io.vertx:vertx-auth-shiro:3.4.0-SNAPSHOT' ---- We provide out of the box support for properties and LDAP based auth using Shiro, and you can also plugin in any @@ -34,8 +34,6 @@ Here's an example of creating a Shiro auth provider by specifying the type: [source,java] ---- -import io.vertx.ext.auth.shiro.ShiroAuthRealmType -import io.vertx.ext.auth.shiro.ShiroAuth def config = [ properties_path:"classpath:test-auth.properties" @@ -180,7 +178,6 @@ This is done as follows: [source,java] ---- -import io.vertx.ext.auth.shiro.ShiroAuth def provider = ShiroAuth.create(vertx, realm) diff --git a/vertx-auth-shiro/src/main/asciidoc/java/index.adoc b/vertx-auth-shiro/src/main/asciidoc/java/index.adoc index 6715afe70..328708dfb 100644 --- a/vertx-auth-shiro/src/main/asciidoc/java/index.adoc +++ b/vertx-auth-shiro/src/main/asciidoc/java/index.adoc @@ -12,7 +12,7 @@ project, add the following dependency to the _dependencies_ section of your buil io.vertx vertx-auth-shiro - 3.4.0.Beta1 + 3.4.0-SNAPSHOT ---- @@ -20,7 +20,7 @@ project, add the following dependency to the _dependencies_ section of your buil [source,groovy,subs="+attributes"] ---- -compile 'io.vertx:vertx-auth-shiro:3.4.0.Beta1' +compile 'io.vertx:vertx-auth-shiro:3.4.0-SNAPSHOT' ---- We provide out of the box support for properties and LDAP based auth using Shiro, and you can also plugin in any diff --git a/vertx-auth-shiro/src/main/asciidoc/js/index.adoc b/vertx-auth-shiro/src/main/asciidoc/js/index.adoc index 4f9c9f437..a6ba0acc8 100644 --- a/vertx-auth-shiro/src/main/asciidoc/js/index.adoc +++ b/vertx-auth-shiro/src/main/asciidoc/js/index.adoc @@ -12,7 +12,7 @@ project, add the following dependency to the _dependencies_ section of your buil io.vertx vertx-auth-shiro - 3.4.0.Beta1 + 3.4.0-SNAPSHOT ---- @@ -20,7 +20,7 @@ project, add the following dependency to the _dependencies_ section of your buil [source,groovy,subs="+attributes"] ---- -compile 'io.vertx:vertx-auth-shiro:3.4.0.Beta1' +compile 'io.vertx:vertx-auth-shiro:3.4.0-SNAPSHOT' ---- We provide out of the box support for properties and LDAP based auth using Shiro, and you can also plugin in any diff --git a/vertx-auth-shiro/src/main/asciidoc/kotlin/index.adoc b/vertx-auth-shiro/src/main/asciidoc/kotlin/index.adoc new file mode 100644 index 000000000..99f8a3a7f --- /dev/null +++ b/vertx-auth-shiro/src/main/asciidoc/kotlin/index.adoc @@ -0,0 +1,190 @@ +== The Apache Shiro Auth provider implementation + +This is an auth provider implementation that uses http://shiro.apache.org/[Apache Shiro]. + +To use this +project, add the following dependency to the _dependencies_ section of your build descriptor: + +* Maven (in your `pom.xml`): + +[source,xml,subs="+attributes"] +---- + + io.vertx + vertx-auth-shiro + 3.4.0-SNAPSHOT + +---- + +* Gradle (in your `build.gradle` file): + +[source,groovy,subs="+attributes"] +---- +compile 'io.vertx:vertx-auth-shiro:3.4.0-SNAPSHOT' +---- + +We provide out of the box support for properties and LDAP based auth using Shiro, and you can also plugin in any +other Shiro Realm which expects username and password for credentials. + +To create an instance of the provider you use `link:../../apidocs/io/vertx/ext/auth/shiro/ShiroAuth.html[ShiroAuth]`. You specify the type of +Shiro auth provider that you want with `link:../../apidocs/io/vertx/ext/auth/shiro/ShiroAuthRealmType.html[ShiroAuthRealmType]`, and you specify the +configuration in a JSON object. + +Here's an example of creating a Shiro auth provider by specifying the type: + +[source,java] +---- + +var config = json { + obj("properties_path" to "classpath:test-auth.properties") +} + +var provider = ShiroAuth.create(vertx, ShiroAuthRealmType.PROPERTIES, config) + + +---- + +== Authentication + +When authenticating using this implementation, it assumes `username` and `password` fields are present in the +authentication info: + +[source,java] +---- + +var authInfo = json { + obj( + "username" to "tim", + "password" to "sausages" + ) +} + +authProvider.authenticate(authInfo, { res -> + if (res.succeeded()) { + var user = res.result() + } else { + // Failed! + } +}) + +---- + +== Authorisation - Permission-Role Model + +Although Vert.x auth itself does not mandate any specific model of permissions (they are just opaque strings), this +implementation uses a familiar user/role/permission model, where a user can have zero or more roles and a role +can have zero or more permissions. + +If validating if a user has a particular permission simply pass the permission into. +`link:../../apidocs/io/vertx/ext/auth/User.html#isAuthorised-java.lang.String-io.vertx.core.Handler-[isAuthorised]` as follows: + +[source,java] +---- + +user.isAuthorised("newsletter:edit:13", { res -> + if (res.succeeded()) { + var hasPermission = res.result() + } else { + // Failed to + } +}) + + +---- +If validating that a user has a particular _role_ then you should prefix the argument with the role prefix. + +[source,java] +---- + +user.isAuthorised("role:manager", { res -> + if (res.succeeded()) { + var hasRole = res.result() + } else { + // Failed to + } +}) + + +---- + +The default role prefix is `role:`. You can change this with `link:../../apidocs/io/vertx/ext/auth/shiro/ShiroAuth.html#setRolePrefix-java.lang.String-[setRolePrefix]`. + +=== The Shiro properties auth provider + +This auth provider implementation uses Apache Shiro to get user/role/permission information from a properties file. + +Note that roles are not available directly on the API due to the fact that vertx-auth tries to be as portable as +possible. However one can run assertions on role by using the prefix `role:` or by specifying the prefered prefix +with `link:../../apidocs/io/vertx/ext/auth/shiro/ShiroAuth.html#setRolePrefix-java.lang.String-[setRolePrefix]`. + +The implementation will, by default, look for a file called `vertx-users.properties` on the classpath. + +If you want to change this, you can use the `properties_path` configuration element to define how the properties +file is found. + +The default value is `classpath:vertx-users.properties`. + +If the value is prefixed with `classpath:` then the classpath will be searched for a properties file of that name. + +If the value is prefixed with `file:` then it specifies a file on the file system. + +If the value is prefixed with `url:` then it specifies a URL from where to load the properties. + +The properties file should have the following structure: + +Each line should either contain the username, password and roles for a user or the permissions in a role. + +For a user line it should be of the form: + + user.{username}={password},{roleName1},{roleName2},...,{roleNameN} + +For a role line it should be of the form: + + role.{roleName}={permissionName1},{permissionName2},...,{permissionNameN} + +Here's an example: +---- +user.tim = mypassword,administrator,developer +user.bob = hispassword,developer +user.joe = anotherpassword,manager +role.administrator=* +role.manager=play_golf,say_buzzwords +role.developer=do_actual_work +---- + +When describing roles a wildcard `*` can be used to indicate that the role has all permissions. + +=== The Shiro LDAP auth provider + +The LDAP auth realm gets user/role/permission information from an LDAP server. + +The following configuration properties are used to configure the LDAP realm: + +`ldap-user-dn-template`:: this is used to determine the actual lookup to use when looking up a user with a particular +id. An example is `uid={0},ou=users,dc=foo,dc=com` - the element `{0}` is substituted with the user id to create the +actual lookup. This setting is mandatory. +`ldap_url`:: the url to the LDAP server. The url must start with `ldap://` and a port must be specified. +An example is `ldap://myldapserver.mycompany.com:10389` +`ldap-authentication-mechanism`:: TODO +`ldap-context-factory-class-name`:: TODO +`ldap-pooling-enabled`:: TODO +`ldap-referral`:: TODO +`ldap-system-username`:: TODO +`ldap-system-password`:: TODO + +=== Using another Shiro Realm + +It's also possible to create an auth provider instance using a pre-created Apache Shiro Realm object. + +This is done as follows: + +[source,java] +---- + +var provider = ShiroAuth.create(vertx, realm) + + +---- + +The implementation currently assumes that user/password based authentication is used. +Julien VietTim Fox \ No newline at end of file diff --git a/vertx-auth-shiro/src/main/asciidoc/ruby/index.adoc b/vertx-auth-shiro/src/main/asciidoc/ruby/index.adoc index 2db9d1289..674b81a73 100644 --- a/vertx-auth-shiro/src/main/asciidoc/ruby/index.adoc +++ b/vertx-auth-shiro/src/main/asciidoc/ruby/index.adoc @@ -12,7 +12,7 @@ project, add the following dependency to the _dependencies_ section of your buil io.vertx vertx-auth-shiro - 3.4.0.Beta1 + 3.4.0-SNAPSHOT ---- @@ -20,7 +20,7 @@ project, add the following dependency to the _dependencies_ section of your buil [source,groovy,subs="+attributes"] ---- -compile 'io.vertx:vertx-auth-shiro:3.4.0.Beta1' +compile 'io.vertx:vertx-auth-shiro:3.4.0-SNAPSHOT' ---- We provide out of the box support for properties and LDAP based auth using Shiro, and you can also plugin in any diff --git a/vertx-auth-shiro/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule b/vertx-auth-shiro/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule deleted file mode 100644 index 69e2c3c10..000000000 --- a/vertx-auth-shiro/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule +++ /dev/null @@ -1,4 +0,0 @@ -moduleName = io.vertx.ext.auth.shiro.ShiroAuth-module -moduleVersion = 1.0 -extensionClasses = -staticExtensionClasses = io.vertx.groovy.ext.auth.shiro.ShiroAuth_GroovyStaticExtension diff --git a/vertx-auth-shiro/src/main/resources/vertx-auth-common-js/shiro_auth.js b/vertx-auth-shiro/src/main/resources/vertx-auth-common-js/shiro_auth.js deleted file mode 100644 index e3f20d9ef..000000000 --- a/vertx-auth-shiro/src/main/resources/vertx-auth-common-js/shiro_auth.js +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2014 Red Hat, Inc. - * - * Red Hat 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. - */ - -/** @module vertx-auth-common-js/shiro_auth */ -var utils = require('vertx-js/util/utils'); -var AuthProvider = require('vertx-auth-common-js/auth_provider'); - -var io = Packages.io; -var JsonObject = io.vertx.core.json.JsonObject; -var JShiroAuth = io.vertx.ext.auth.shiro.ShiroAuth; - -/** - - @class -*/ -var ShiroAuth = function(j_val) { - - var j_shiroAuth = j_val; - var that = this; - - // A reference to the underlying Java delegate - // NOTE! This is an internal API and must not be used in user code. - // If you rely on this property your code is likely to break if we change it / remove it without warning. - this._jdel = j_shiroAuth; -}; - -/** - - @memberof module:vertx-auth-common-js/shiro_auth - @param vertx {Vertx} - @param realmType {Object} - @param config {Object} - @return {AuthProvider} - */ -ShiroAuth.create = function(vertx, realmType, config) { - var __args = arguments; - if (__args.length === 3 && typeof __args[0] === 'object' && __args[0]._jdel && typeof __args[1] === 'string' && typeof __args[2] === 'object') { - return new AuthProvider(JShiroAuth["create(io.vertx.core.Vertx,io.vertx.ext.auth.shiro.ShiroAuthRealmType,io.vertx.core.json.JsonObject)"](vertx._jdel, io.vertx.ext.auth.shiro.ShiroAuthRealmType.valueOf(__args[1]), utils.convParamJsonObject(config))); - } else utils.invalidArgs(); -}; - -// We export the Constructor function -module.exports = ShiroAuth; \ No newline at end of file diff --git a/vertx-auth-shiro/src/main/resources/vertx-auth-common/shiro_auth.rb b/vertx-auth-shiro/src/main/resources/vertx-auth-common/shiro_auth.rb deleted file mode 100644 index 0bb123a51..000000000 --- a/vertx-auth-shiro/src/main/resources/vertx-auth-common/shiro_auth.rb +++ /dev/null @@ -1,28 +0,0 @@ -require 'vertx-auth-common/auth_provider' -require 'vertx/util/utils.rb' -# Generated from io.vertx.ext.auth.shiro.ShiroAuth -module VertxAuthCommon - # Factory interface for creating Apache Shiro based {::VertxAuthCommon::AuthProvider} instances. - class ShiroAuth - # @private - # @param j_del [::VertxAuthCommon::ShiroAuth] the java delegate - def initialize(j_del) - @j_del = j_del - end - # @private - # @return [::VertxAuthCommon::ShiroAuth] the underlying java delegate - def j_del - @j_del - end - # @param [::Vertx::Vertx] vertx - # @param [:PROPERTIES,:LDAP] realmType - # @param [Hash{String => Object}] config - # @return [::VertxAuthCommon::AuthProvider] - def self.create(vertx=nil,realmType=nil,config=nil) - if vertx.class.method_defined?(:j_del) && realmType.class == Symbol && config.class == Hash && !block_given? - return ::VertxAuthCommon::AuthProvider.new(Java::IoVertxExtAuthShiro::ShiroAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxExtAuthShiro::ShiroAuthRealmType.java_class,Java::IoVertxCoreJson::JsonObject.java_class]).call(vertx.j_del,Java::IoVertxExtAuthShiro::ShiroAuthRealmType.valueOf(realmType),::Vertx::Util::Utils.to_json_object(config))) - end - raise ArgumentError, "Invalid arguments when calling create(vertx,realmType,config)" - end - end -end diff --git a/vertx-auth-shiro/src/main/resources/vertx-auth-shiro-js/shiro_auth.js b/vertx-auth-shiro/src/main/resources/vertx-auth-shiro-js/shiro_auth.js deleted file mode 100644 index 6b7b8b678..000000000 --- a/vertx-auth-shiro/src/main/resources/vertx-auth-shiro-js/shiro_auth.js +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright 2014 Red Hat, Inc. - * - * Red Hat 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. - */ - -/** @module vertx-auth-shiro-js/shiro_auth */ -var utils = require('vertx-js/util/utils'); -var User = require('vertx-auth-common-js/user'); -var Vertx = require('vertx-js/vertx'); -var AuthProvider = require('vertx-auth-common-js/auth_provider'); - -var io = Packages.io; -var JsonObject = io.vertx.core.json.JsonObject; -var JShiroAuth = Java.type('io.vertx.ext.auth.shiro.ShiroAuth'); -var ShiroAuthOptions = Java.type('io.vertx.ext.auth.shiro.ShiroAuthOptions'); - -/** - - @class -*/ -var ShiroAuth = function(j_val) { - - var j_shiroAuth = j_val; - var that = this; - AuthProvider.call(this, j_val); - - /** - - @public - @param arg0 {Object} - @param arg1 {function} - */ - this.authenticate = function(arg0, arg1) { - var __args = arguments; - if (__args.length === 2 && (typeof __args[0] === 'object' && __args[0] != null) && typeof __args[1] === 'function') { - j_shiroAuth["authenticate(io.vertx.core.json.JsonObject,io.vertx.core.Handler)"](utils.convParamJsonObject(arg0), function(ar) { - if (ar.succeeded()) { - arg1(utils.convReturnVertxGen(User, ar.result()), null); - } else { - arg1(null, ar.cause()); - } - }); - } else throw new TypeError('function invoked with invalid arguments'); - }; - - /** - Set the role prefix to distinguish from permissions when checking for isPermitted requests. - - @public - @param rolePrefix {string} a Prefix e.g.: "role:" - @return {ShiroAuth} a reference to this for fluency - */ - this.setRolePrefix = function(rolePrefix) { - var __args = arguments; - if (__args.length === 1 && typeof __args[0] === 'string') { - return utils.convReturnVertxGen(ShiroAuth, j_shiroAuth["setRolePrefix(java.lang.String)"](rolePrefix)); - } else throw new TypeError('function invoked with invalid arguments'); - }; - - // A reference to the underlying Java delegate - // NOTE! This is an internal API and must not be used in user code. - // If you rely on this property your code is likely to break if we change it / remove it without warning. - this._jdel = j_shiroAuth; -}; - -ShiroAuth._jclass = utils.getJavaClass("io.vertx.ext.auth.shiro.ShiroAuth"); -ShiroAuth._jtype = { - accept: function(obj) { - return ShiroAuth._jclass.isInstance(obj._jdel); - }, - wrap: function(jdel) { - var obj = Object.create(ShiroAuth.prototype, {}); - ShiroAuth.apply(obj, arguments); - return obj; - }, - unwrap: function(obj) { - return obj._jdel; - } -}; -ShiroAuth._create = function(jdel) { - var obj = Object.create(ShiroAuth.prototype, {}); - ShiroAuth.apply(obj, arguments); - return obj; -} -/** - Create a Shiro auth provider - - @memberof module:vertx-auth-shiro-js/shiro_auth - @param vertx {Vertx} the Vert.x instance - @param realmType {Object} the Shiro realm type - @param config {Object} the config - @return {ShiroAuth} the auth provider - */ -ShiroAuth.create = function() { - var __args = arguments; - if (__args.length === 2 && typeof __args[0] === 'object' && __args[0]._jdel && (typeof __args[1] === 'object' && __args[1] != null)) { - return utils.convReturnVertxGen(ShiroAuth, JShiroAuth["create(io.vertx.core.Vertx,io.vertx.ext.auth.shiro.ShiroAuthOptions)"](__args[0]._jdel, __args[1] != null ? new ShiroAuthOptions(new JsonObject(Java.asJSONCompatible(__args[1]))) : null)); - }else if (__args.length === 3 && typeof __args[0] === 'object' && __args[0]._jdel && typeof __args[1] === 'string' && (typeof __args[2] === 'object' && __args[2] != null)) { - return utils.convReturnVertxGen(ShiroAuth, JShiroAuth["create(io.vertx.core.Vertx,io.vertx.ext.auth.shiro.ShiroAuthRealmType,io.vertx.core.json.JsonObject)"](__args[0]._jdel, io.vertx.ext.auth.shiro.ShiroAuthRealmType.valueOf(__args[1]), utils.convParamJsonObject(__args[2]))); - } else throw new TypeError('function invoked with invalid arguments'); -}; - -module.exports = ShiroAuth; \ No newline at end of file diff --git a/vertx-auth-shiro/src/main/resources/vertx-auth-shiro/shiro_auth.rb b/vertx-auth-shiro/src/main/resources/vertx-auth-shiro/shiro_auth.rb deleted file mode 100644 index 08a8558d9..000000000 --- a/vertx-auth-shiro/src/main/resources/vertx-auth-shiro/shiro_auth.rb +++ /dev/null @@ -1,72 +0,0 @@ -require 'vertx-auth-common/user' -require 'vertx/vertx' -require 'vertx-auth-common/auth_provider' -require 'vertx/util/utils.rb' -# Generated from io.vertx.ext.auth.shiro.ShiroAuth -module VertxAuthShiro - # Factory interface for creating Apache Shiro based {::VertxAuthCommon::AuthProvider} instances. - class ShiroAuth < ::VertxAuthCommon::AuthProvider - # @private - # @param j_del [::VertxAuthShiro::ShiroAuth] the java delegate - def initialize(j_del) - super(j_del) - @j_del = j_del - end - # @private - # @return [::VertxAuthShiro::ShiroAuth] the underlying java delegate - def j_del - @j_del - end - @@j_api_type = Object.new - def @@j_api_type.accept?(obj) - obj.class == ShiroAuth - end - def @@j_api_type.wrap(obj) - ShiroAuth.new(obj) - end - def @@j_api_type.unwrap(obj) - obj.j_del - end - def self.j_api_type - @@j_api_type - end - def self.j_class - Java::IoVertxExtAuthShiro::ShiroAuth.java_class - end - # @param [Hash{String => Object}] arg0 - # @yield - # @return [void] - def authenticate(arg0=nil) - if arg0.class == Hash && block_given? - return @j_del.java_method(:authenticate, [Java::IoVertxCoreJson::JsonObject.java_class,Java::IoVertxCore::Handler.java_class]).call(::Vertx::Util::Utils.to_json_object(arg0),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxAuthCommon::User) : nil) })) - end - raise ArgumentError, "Invalid arguments when calling authenticate(#{arg0})" - end - # Create a Shiro auth provider - # @overload create(vertx,options) - # @param [::Vertx::Vertx] vertx the Vert.x instance - # @param [Hash] options the Shiro configuration options - # @overload create(vertx,realmType,config) - # @param [::Vertx::Vertx] vertx the Vert.x instance - # @param [:PROPERTIES,:LDAP] realmType the Shiro realm type - # @param [Hash{String => Object}] config the config - # @return [::VertxAuthShiro::ShiroAuth] the auth provider - def self.create(param_1=nil,param_2=nil,param_3=nil) - if param_1.class.method_defined?(:j_del) && param_2.class == Hash && !block_given? && param_3 == nil - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthShiro::ShiroAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxExtAuthShiro::ShiroAuthOptions.java_class]).call(param_1.j_del,Java::IoVertxExtAuthShiro::ShiroAuthOptions.new(::Vertx::Util::Utils.to_json_object(param_2))),::VertxAuthShiro::ShiroAuth) - elsif param_1.class.method_defined?(:j_del) && param_2.class == Symbol && param_3.class == Hash && !block_given? - return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthShiro::ShiroAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxExtAuthShiro::ShiroAuthRealmType.java_class,Java::IoVertxCoreJson::JsonObject.java_class]).call(param_1.j_del,Java::IoVertxExtAuthShiro::ShiroAuthRealmType.valueOf(param_2.to_s),::Vertx::Util::Utils.to_json_object(param_3)),::VertxAuthShiro::ShiroAuth) - end - raise ArgumentError, "Invalid arguments when calling create(#{param_1},#{param_2},#{param_3})" - end - # Set the role prefix to distinguish from permissions when checking for isPermitted requests. - # @param [String] rolePrefix a Prefix e.g.: "role:" - # @return [::VertxAuthShiro::ShiroAuth] a reference to this for fluency - def set_role_prefix(rolePrefix=nil) - if rolePrefix.class == String && !block_given? - return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:setRolePrefix, [Java::java.lang.String.java_class]).call(rolePrefix),::VertxAuthShiro::ShiroAuth) - end - raise ArgumentError, "Invalid arguments when calling set_role_prefix(#{rolePrefix})" - end - end -end