Class: LosantRest::Auth
- Inherits:
-
Object
- Object
- LosantRest::Auth
- Defined in:
- lib/losant_rest/auth.rb
Overview
Class containing all the actions for the Auth Resource
Instance Method Summary collapse
-
#authenticate_device(params = {}) ⇒ Object
Authenticates a device using the provided credentials.
-
#authenticate_user(params = {}) ⇒ Object
Authenticates a user using the provided credentials.
-
#authenticate_user_github(params = {}) ⇒ Object
Authenticates a user via GitHub OAuth.
-
#authenticate_user_saml(params = {}) ⇒ Object
Authenticates a user via a SAML response.
-
#initialize(client) ⇒ Auth
constructor
A new instance of Auth.
-
#sso_domain(params = {}) ⇒ Object
Checks email domain for SSO configuration.
Constructor Details
#initialize(client) ⇒ Auth
Returns a new instance of Auth.
30 31 32 |
# File 'lib/losant_rest/auth.rb', line 30 def initialize(client) @client = client end |
Instance Method Details
#authenticate_device(params = {}) ⇒ Object
Authenticates a device using the provided credentials.
Authentication: No api access token is required to call this action.
Parameters:
-
hash credentials - Device authentication credentials (api.losant.com/#/definitions/deviceCredentials)
-
string losantdomain - Domain scope of request (rarely needed)
-
boolean _actions - Return resource actions in response
-
boolean _links - Return resource link in response
-
boolean _embedded - Return embedded resources in response
Responses:
-
200 - Successful authentication. The included api access token by default has the scope ‘all.Device’. (api.losant.com/#/definitions/authedDevice)
Errors:
-
400 - Error if malformed request (api.losant.com/#/definitions/error)
-
401 - Unauthorized error if authentication fails (api.losant.com/#/definitions/error)
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/losant_rest/auth.rb', line 52 def authenticate_device(params = {}) params = Utils.symbolize_hash_keys(params) query_params = { _actions: false, _links: true, _embedded: true } headers = {} body = nil raise ArgumentError.new("credentials is required") unless params.has_key?(:credentials) body = params[:credentials] if params.has_key?(:credentials) headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain) query_params[:_actions] = params[:_actions] if params.has_key?(:_actions) query_params[:_links] = params[:_links] if params.has_key?(:_links) query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded) path = "/auth/device" @client.request( method: :post, path: path, query: query_params, headers: headers, body: body) end |
#authenticate_user(params = {}) ⇒ Object
Authenticates a user using the provided credentials.
Authentication: No api access token is required to call this action.
Parameters:
-
hash credentials - User authentication credentials (api.losant.com/#/definitions/userCredentials)
-
string losantdomain - Domain scope of request (rarely needed)
-
boolean _actions - Return resource actions in response
-
boolean _links - Return resource link in response
-
boolean _embedded - Return embedded resources in response
Responses:
-
200 - Successful authentication. The included api access token has the scope ‘all.User’. (api.losant.com/#/definitions/authedUser)
Errors:
-
400 - Error if malformed request (api.losant.com/#/definitions/error)
-
401 - Unauthorized error if authentication fails (api.losant.com/#/definitions/error)
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/losant_rest/auth.rb', line 94 def authenticate_user(params = {}) params = Utils.symbolize_hash_keys(params) query_params = { _actions: false, _links: true, _embedded: true } headers = {} body = nil raise ArgumentError.new("credentials is required") unless params.has_key?(:credentials) body = params[:credentials] if params.has_key?(:credentials) headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain) query_params[:_actions] = params[:_actions] if params.has_key?(:_actions) query_params[:_links] = params[:_links] if params.has_key?(:_links) query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded) path = "/auth/user" @client.request( method: :post, path: path, query: query_params, headers: headers, body: body) end |
#authenticate_user_github(params = {}) ⇒ Object
Authenticates a user via GitHub OAuth.
Authentication: No api access token is required to call this action.
Parameters:
-
hash oauth - User authentication credentials (access token) (api.losant.com/#/definitions/githubLogin)
-
string losantdomain - Domain scope of request (rarely needed)
-
boolean _actions - Return resource actions in response
-
boolean _links - Return resource link in response
-
boolean _embedded - Return embedded resources in response
Responses:
-
200 - Successful authentication. The included api access token has the scope ‘all.User’. (api.losant.com/#/definitions/authedUser)
Errors:
-
400 - Error if malformed request (api.losant.com/#/definitions/error)
-
401 - Unauthorized error if authentication fails (api.losant.com/#/definitions/error)
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/losant_rest/auth.rb', line 136 def authenticate_user_github(params = {}) params = Utils.symbolize_hash_keys(params) query_params = { _actions: false, _links: true, _embedded: true } headers = {} body = nil raise ArgumentError.new("oauth is required") unless params.has_key?(:oauth) body = params[:oauth] if params.has_key?(:oauth) headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain) query_params[:_actions] = params[:_actions] if params.has_key?(:_actions) query_params[:_links] = params[:_links] if params.has_key?(:_links) query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded) path = "/auth/user/github" @client.request( method: :post, path: path, query: query_params, headers: headers, body: body) end |
#authenticate_user_saml(params = {}) ⇒ Object
Authenticates a user via a SAML response.
Authentication: No api access token is required to call this action.
Parameters:
-
hash saml - Encoded SAML response from an IDP for a user. (api.losant.com/#/definitions/samlResponse)
-
string losantdomain - Domain scope of request (rarely needed)
-
boolean _actions - Return resource actions in response
-
boolean _links - Return resource link in response
-
boolean _embedded - Return embedded resources in response
Responses:
-
200 - Successful authentication. The included api access token has the scope ‘all.User’. (api.losant.com/#/definitions/authedUser)
Errors:
-
400 - Error if malformed request (api.losant.com/#/definitions/error)
-
401 - Unauthorized error if authentication fails (api.losant.com/#/definitions/error)
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
# File 'lib/losant_rest/auth.rb', line 178 def authenticate_user_saml(params = {}) params = Utils.symbolize_hash_keys(params) query_params = { _actions: false, _links: true, _embedded: true } headers = {} body = nil raise ArgumentError.new("saml is required") unless params.has_key?(:saml) body = params[:saml] if params.has_key?(:saml) headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain) query_params[:_actions] = params[:_actions] if params.has_key?(:_actions) query_params[:_links] = params[:_links] if params.has_key?(:_links) query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded) path = "/auth/user/saml" @client.request( method: :post, path: path, query: query_params, headers: headers, body: body) end |
#sso_domain(params = {}) ⇒ Object
Checks email domain for SSO configuration.
Authentication: No api access token is required to call this action.
Parameters:
-
string email - The email address associated with the user login
-
string losantdomain - Domain scope of request (rarely needed)
-
boolean _actions - Return resource actions in response
-
boolean _links - Return resource link in response
-
boolean _embedded - Return embedded resources in response
Responses:
-
200 - Successful finding SSO for domain. Returns SSO request URL and type. (api.losant.com/#/definitions/ssoRequest)
-
204 - No domain associated with an SSO configuration
Errors:
-
400 - Error if malformed request (api.losant.com/#/definitions/error)
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
# File 'lib/losant_rest/auth.rb', line 220 def sso_domain(params = {}) params = Utils.symbolize_hash_keys(params) query_params = { _actions: false, _links: true, _embedded: true } headers = {} body = nil raise ArgumentError.new("email is required") unless params.has_key?(:email) query_params[:email] = params[:email] if params.has_key?(:email) headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain) query_params[:_actions] = params[:_actions] if params.has_key?(:_actions) query_params[:_links] = params[:_links] if params.has_key?(:_links) query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded) path = "/auth/ssoDomain" @client.request( method: :get, path: path, query: query_params, headers: headers, body: body) end |