Class: MultiAuthSample::AuthenticationController

Inherits:
BaseController show all
Defined in:
lib/multi_auth_sample/controllers/authentication_controller.rb

Overview

AuthenticationController

Constant Summary

Constants inherited from BaseController

BaseController::GLOBAL_ERRORS

Instance Attribute Summary

Attributes inherited from BaseController

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseController

#initialize, #new_api_call_builder, #new_parameter, #new_request_builder, #new_response_handler, user_agent

Constructor Details

This class inherits a constructor from MultiAuthSample::BaseController

Instance Method Details

#basic_auth_and_api_header_authString

TODO: type endpoint description here

Returns:

  • (String)

    response from the API call



105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/multi_auth_sample/controllers/authentication_controller.rb', line 105

def basic_auth_and_api_header_auth
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/auth/basicAndApiKeyAndApiHeader',
                                 Server::DEFAULT)
               .auth(And.new('basicAuth', 'apiKey', 'apiHeader')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:deserialize_primitive_types))
               .deserialize_into(proc do |response| response.to_s end)
               .is_primitive_response(true))
    .execute
end

#custom_authenticationString

TODO: type endpoint description here

Returns:

  • (String)

    response from the API call



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/multi_auth_sample/controllers/authentication_controller.rb', line 26

def custom_authentication
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/auth/customAuthentication',
                                 Server::DEFAULT)
               .auth(Single.new('CustomAuth')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:deserialize_primitive_types))
               .deserialize_into(proc do |response| response.to_s end)
               .is_primitive_response(true))
    .execute
end

#custom_query_or_header_authenticationString

TODO: type endpoint description here

Returns:

  • (String)

    response from the API call



41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/multi_auth_sample/controllers/authentication_controller.rb', line 41

def custom_query_or_header_authentication
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/auth/customQueryOrHeaderParam',
                                 Server::DEFAULT)
               .auth(Or.new('apiKey', 'apiHeader')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:deserialize_primitive_types))
               .deserialize_into(proc do |response| response.to_s end)
               .is_primitive_response(true))
    .execute
end

#multiple_auth_combinationString

This endpoint uses globally applied auth which is a hypothetical scneraio but covers the worst case.

Returns:

  • (String)

    response from the API call



136
137
138
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/multi_auth_sample/controllers/authentication_controller.rb', line 136

def multiple_auth_combination
  warn 'Endpoint multiple_auth_combination in AuthenticationController is '\
       'deprecated'
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/auth/multipleAuthCombination',
                                 Server::DEFAULT)
               .auth(Or.new('CustomAuth', 'OAuthBearerToken', And.new('basicAuth', 'apiKey', 'apiHeader'))))
    .response(new_response_handler
               .deserializer(APIHelper.method(:deserialize_primitive_types))
               .deserialize_into(proc do |response| response.to_s end)
               .is_primitive_response(true))
    .execute
end

#no_authString

This endpoint does not use auth.

Returns:

  • (String)

    response from the API call



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/multi_auth_sample/controllers/authentication_controller.rb', line 71

def no_auth
  warn 'Endpoint no_auth in AuthenticationController is deprecated since v'\
       'ersion 0.0.1-alpha.    You should not use this method as it requir'\
       'es no auth and can bring security issues to the server and api cal'\
       'l itself!!'
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/auth/noAuth',
                                 Server::DEFAULT)
               .query_param(new_parameter(true, key: 'array')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:deserialize_primitive_types))
               .deserialize_into(proc do |response| response.to_s end)
               .is_primitive_response(true))
    .execute
end

#o_auth_authorization_grantUser

TODO: type endpoint description here

Returns:

  • (User)

    response from the API call



120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/multi_auth_sample/controllers/authentication_controller.rb', line 120

def o_auth_authorization_grant
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/oauth2/non-auth-server/user',
                                 Server::DEFAULT)
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(And.new('OAuthACG', 'OAuthROPCG')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:custom_type_deserializer))
               .deserialize_into(User.method(:from_hash)))
    .execute
end

#o_auth_bearer_tokenString

TODO: type endpoint description here

Returns:

  • (String)

    response from the API call



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/multi_auth_sample/controllers/authentication_controller.rb', line 11

def o_auth_bearer_token
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/auth/oauth2',
                                 Server::DEFAULT)
               .auth(Single.new('OAuthBearerToken')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:deserialize_primitive_types))
               .deserialize_into(proc do |response| response.to_s end)
               .is_primitive_response(true))
    .execute
end

#o_auth_client_credentials_grantServiceStatus

TODO: type endpoint description here

Returns:



90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/multi_auth_sample/controllers/authentication_controller.rb', line 90

def o_auth_client_credentials_grant
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/oauth2/non-auth-server/status',
                                 Server::DEFAULT)
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('OAuthCCG')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:custom_type_deserializer))
               .deserialize_into(ServiceStatus.method(:from_hash)))
    .execute
end

#o_auth_grant_types_or_combinationsString

This endpoint tests or combinations of OAuth types

Returns:

  • (String)

    response from the API call



56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/multi_auth_sample/controllers/authentication_controller.rb', line 56

def o_auth_grant_types_or_combinations
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/oauth2/oauthOrCombination',
                                 Server::DEFAULT)
               .auth(Or.new('OAuthCCG', 'OAuthBearerToken')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:deserialize_primitive_types))
               .deserialize_into(proc do |response| response.to_s end)
               .is_primitive_response(true))
    .execute
end