Class: VertxAuthOauth2::OAuth2RBAC

Inherits:
Object
  • Object
show all
Defined in:
/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/o_auth2_rbac.rb

Overview

Functional interface that allows users to implement custom RBAC verifiers for OAuth2/OpenId Connect. Users are to implement the isAuthorized method to verify authorities. For provides that do not export the permissions/roles in the token, this interface allows you to communicate with 3rd party services such as graph APIs to collect the required data. The contract is that once an authority is checked for a given user, it's value is cached during the execution of the request. If a user is stored to a persistent storage, or the token is introspected, the cache is cleared and a new call will be handled to the implementation.

Constant Summary

@@j_api_type =
Object.new

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)


26
27
28
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/o_auth2_rbac.rb', line 26

def @@j_api_type.accept?(obj)
  obj.class == OAuth2RBAC
end

+ (Object) j_api_type



35
36
37
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/o_auth2_rbac.rb', line 35

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class



38
39
40
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/o_auth2_rbac.rb', line 38

def self.j_class
  Java::IoVertxExtAuthOauth2::OAuth2RBAC.java_class
end

+ (Object) unwrap(obj)



32
33
34
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/o_auth2_rbac.rb', line 32

def @@j_api_type.unwrap(obj)
  obj.j_del
end

+ (Object) wrap(obj)



29
30
31
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/o_auth2_rbac.rb', line 29

def @@j_api_type.wrap(obj)
  OAuth2RBAC.new(obj)
end

Instance Method Details

- (void) is_authorized(user = nil, authority = nil) { ... }

This method returns an undefined value.

This method should verify if the user has the given authority and return either a boolean value or an error. Note that false and errors are not the same. A user might not have a given authority but that doesn't mean that there was an error during the call.

Parameters:

  • user (::VertxAuthOauth2::AccessToken) (defaults to: nil)
    the given user to assert on
  • authority (String) (defaults to: nil)
    the authority to lookup

Yields:

  • the result handler.

Raises:

  • (ArgumentError)


49
50
51
52
53
54
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/o_auth2_rbac.rb', line 49

def is_authorized(user=nil,authority=nil)
  if user.class.method_defined?(:j_del) && authority.class == String && block_given?
    return @j_del.java_method(:isAuthorized, [Java::IoVertxExtAuthOauth2::AccessToken.java_class,Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(user.j_del,authority,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) }))
  end
  raise ArgumentError, "Invalid arguments when calling is_authorized(#{user},#{authority})"
end