Class: VertxAuthOauth2::OAuth2Auth
- Inherits:
-
VertxAuthCommon::AuthProvider
- Object
- VertxAuthCommon::AuthProvider
- VertxAuthOauth2::OAuth2Auth
- Defined in:
- /Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/o_auth2_auth.rb
Overview
Factory interface for creating OAuth2 based VertxAuthCommon::AuthProvider instances.
Constant Summary
- @@j_api_type =
Object.new
Class Method Summary (collapse)
- + (Boolean) accept?(obj)
-
+ (::VertxAuthOauth2::OAuth2Auth) create(param_1 = nil, param_2 = nil, param_3 = nil)
Create a OAuth2 auth provider.
-
+ (::VertxAuthOauth2::OAuth2Auth) create_keycloak(vertx = nil, flow = nil, config = nil)
The auth provider.
- + (Object) j_api_type
- + (Object) j_class
- + (Object) unwrap(obj)
- + (Object) wrap(obj)
Instance Method Summary (collapse)
-
- (void) authenticate(authInfo = nil) { ... }
Authenticate a user.
-
- (String) authorize_url(params = nil)
Generate a redirect URL to the authN/Z backend.
-
- (self) decode_token(token = nil) { ... }
Decode a token to a AccessToken object.
-
- (:AUTH_CODE, ...) get_flow_type
Returns the configured flow type for the Oauth2 provider.
-
- (String) get_scope_separator
Returns the scope separator.
-
- (void) get_token(params = nil) { ... }
Returns the Access Token object.
-
- (self) introspect_token(token = nil, tokenType = nil) { ... }
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.
-
- (self) load_jwk { ... }
Loads a JWK Set from the remote provider.
-
- (self) missing_key_handler { ... }
Handled to be called when a key (mentioned on a JWT) is missing from the current config.
- - (self) rbac_handler(rbac = nil)
Class Method Details
+ (Boolean) accept?(obj)
22 23 24 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/o_auth2_auth.rb', line 22 def @@j_api_type.accept?(obj) obj.class == OAuth2Auth end |
+ (::VertxAuthOauth2::OAuth2Auth) create(vertx) + (::VertxAuthOauth2::OAuth2Auth) create(vertx, flow) + (::VertxAuthOauth2::OAuth2Auth) create(vertx, config) + (::VertxAuthOauth2::OAuth2Auth) create(vertx, flow, config)
Create a OAuth2 auth provider
85 86 87 88 89 90 91 92 93 94 95 96 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/o_auth2_auth.rb', line 85 def self.create(param_1=nil,param_2=nil,param_3=nil) if param_1.class.method_defined?(:j_del) && !block_given? && param_2 == nil && param_3 == nil return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2::OAuth2Auth.java_method(:create, [Java::IoVertxCore::Vertx.java_class]).call(param_1.j_del),::VertxAuthOauth2::OAuth2Auth) elsif param_1.class.method_defined?(:j_del) && param_2.class == Symbol && !block_given? && param_3 == nil return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2::OAuth2Auth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxExtAuthOauth2::OAuth2FlowType.java_class]).call(param_1.j_del,Java::IoVertxExtAuthOauth2::OAuth2FlowType.valueOf(param_2.to_s)),::VertxAuthOauth2::OAuth2Auth) elsif param_1.class.method_defined?(:j_del) && param_2.class == Hash && !block_given? && param_3 == nil return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2::OAuth2Auth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxExtAuthOauth2::OAuth2ClientOptions.java_class]).call(param_1.j_del,Java::IoVertxExtAuthOauth2::OAuth2ClientOptions.new(::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? 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(param_1.j_del,Java::IoVertxExtAuthOauth2::OAuth2FlowType.valueOf(param_2.to_s),Java::IoVertxExtAuthOauth2::OAuth2ClientOptions.new(::Vertx::Util::Utils.to_json_object(param_3))),::VertxAuthOauth2::OAuth2Auth) end raise ArgumentError, "Invalid arguments when calling create(#{param_1},#{param_2},#{param_3})" end |
+ (::VertxAuthOauth2::OAuth2Auth) create_keycloak(vertx = nil, flow = nil, config = nil)
Returns the auth provider
65 66 67 68 69 70 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/o_auth2_auth.rb', line 65 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 |
+ (Object) j_api_type
31 32 33 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/o_auth2_auth.rb', line 31 def self.j_api_type @@j_api_type end |
+ (Object) j_class
34 35 36 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/o_auth2_auth.rb', line 34 def self.j_class Java::IoVertxExtAuthOauth2::OAuth2Auth.java_class end |
+ (Object) unwrap(obj)
28 29 30 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/o_auth2_auth.rb', line 28 def @@j_api_type.unwrap(obj) obj.j_del end |
+ (Object) wrap(obj)
25 26 27 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/o_auth2_auth.rb', line 25 def @@j_api_type.wrap(obj) OAuth2Auth.new(obj) end |
Instance Method Details
- (void) authenticate(authInfo = nil) { ... }
This method returns an undefined value.
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 object is passed to the handler in an AsyncResult. The user object can then be used for authorisation.
55 56 57 58 59 60 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/o_auth2_auth.rb', line 55 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 |
- (String) authorize_url(params = nil)
Generate a redirect URL to the authN/Z backend. It only applies to auth_code flow.
100 101 102 103 104 105 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/o_auth2_auth.rb', line 100 def (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 |
- (self) decode_token(token = nil) { ... }
Decode a token to a AccessToken object. This is useful to handle bearer JWT tokens.
120 121 122 123 124 125 126 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/o_auth2_auth.rb', line 120 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 |
- (:AUTH_CODE, ...) get_flow_type
Returns the configured flow type for the Oauth2 provider.
156 157 158 159 160 161 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/o_auth2_auth.rb', line 156 def get_flow_type if !block_given? return @j_del.java_method(:getFlowType, []).call().name.intern end raise ArgumentError, "Invalid arguments when calling get_flow_type()" end |
- (String) get_scope_separator
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.
148 149 150 151 152 153 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/o_auth2_auth.rb', line 148 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 |
- (void) get_token(params = nil) { ... }
This method returns an undefined value.
Returns the Access Token object.
110 111 112 113 114 115 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/o_auth2_auth.rb', line 110 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 |
- (self) introspect_token(token = nil, tokenType = nil) { ... }
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.
133 134 135 136 137 138 139 140 141 142 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/o_auth2_auth.rb', line 133 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 ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxAuthOauth2::AccessToken) : nil) })) return self end raise ArgumentError, "Invalid arguments when calling introspect_token(#{token},#{tokenType})" end |
- (self) load_jwk { ... }
Loads a JWK Set from the remote provider.
When calling this method several times, the loaded JWKs are updated in the underlying JWT object.
167 168 169 170 171 172 173 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/o_auth2_auth.rb', line 167 def load_jwk if block_given? @j_del.java_method(:loadJWK, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil) })) return self end raise ArgumentError, "Invalid arguments when calling load_jwk()" end |
- (self) missing_key_handler { ... }
Handled to be called when a key (mentioned on a JWT) is missing from the current config.
Users are advised to call #load_jwk but being careful to implement
some rate limiting function.
This method isn't generic for several reasons. The provider is not aware of the capabilities
of the backend IdP in terms of max allowed API calls. Some validation could be done at the
key id, which only the end user is aware of.
192 193 194 195 196 197 198 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/o_auth2_auth.rb', line 192 def missing_key_handler if block_given? @j_del.java_method(:missingKeyHandler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(event) })) return self end raise ArgumentError, "Invalid arguments when calling missing_key_handler()" end |
- (self) rbac_handler(rbac = nil)
176 177 178 179 180 181 182 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/o_auth2_auth.rb', line 176 def rbac_handler(rbac=nil) if rbac.class.method_defined?(:j_del) && !block_given? @j_del.java_method(:rbacHandler, [Java::IoVertxExtAuthOauth2::OAuth2RBAC.java_class]).call(rbac.j_del) return self end raise ArgumentError, "Invalid arguments when calling rbac_handler(#{rbac})" end |