Module: Riddl::Utils::OAuth2::UnivieApp

Defined in:
lib/ruby/riddl/utils/oauth2-univie.rb

Defined Under Namespace

Classes: RevokeTokenFlow, RevokeUserFlow, VerifyIdentity

Class Method Summary collapse

Class Method Details

.implementation(client_id, client_secret, access_tokens, refresh_tokens) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/ruby/riddl/utils/oauth2-univie.rb', line 70

def self::implementation(client_id, client_secret, access_tokens, refresh_tokens)
  unless access_tokens.is_a?(Riddl::Utils::OAuth2::Helper::Tokens) && refresh_tokens.is_a?(Riddl::Utils::OAuth2::Helper::Tokens) && client_id.is_a?(String) && client_secret.is_a?(String)
    raise "client_id, client_secret or token storage not available."
  end
  Proc.new do
    run Riddl::Utils::OAuth2::UnivieBearer::CheckAuth, client_id, client_secret, access_tokens if get
    on resource 'verify' do
      run VerifyIdentity, access_tokens, refresh_tokens, client_id, client_secret if post 'verify_in'
    end
    on resource 'token' do
      run RefreshToken, access_tokens, refresh_tokens if post 'refresh_token_in'
    end
    on resource 'revoke' do
      run RevokeTokenFlow, access_tokens, refresh_tokens if get 'revoke_token_in'
      run RevokeUserFlow, access_tokens, refresh_tokens if get 'revoke_user_in'
    end
  end
end