Module: SimpleAuthSdk::API::AuthenticationEndpoints
- Includes:
- Mixins::HTTPProxy
- Defined in:
- lib/simple_auth_sdk/api/authentication_endpoints.rb
Overview
This module provides authentication endpoints. It includes methods for authenticating a user and creating a new user account.
Constant Summary collapse
- DEFAULT_LOGIN_URL =
'/v1/auth/login'
- DEFAULT_CREATE_USER_PATH =
'/v1/auth/create-account'
Constants included from Mixins::HTTPProxy
Mixins::HTTPProxy::BASE_DELAY, Mixins::HTTPProxy::DEFAULT_RETRIES, Mixins::HTTPProxy::MAX_ALLOWED_RETRIES, Mixins::HTTPProxy::MAX_REQUEST_RETRY_DELAY, Mixins::HTTPProxy::MAX_REQUEST_RETRY_JITTER, Mixins::HTTPProxy::MIN_REQUEST_RETRY_DELAY
Instance Attribute Summary
Attributes included from Mixins::HTTPProxy
#base_uri, #headers, #retry_count, #timeout
Instance Method Summary collapse
-
#authenticate_user(login:, password:, uri: DEFAULT_LOGIN_URL, auth_headers: {}) ⇒ Hash, String
Authenticates a user with the given credentials.
-
#create_user(login:, confirmed_login:, password:, confirmed_password:, uri: DEFAULT_CREATE_USER_PATH, auth_headers: {}) ⇒ Hash, String
Creates a new user account with the given credentials.
Methods included from Mixins::HTTPProxy
#add_headers, #call, #encode_uri, #method, #request, #request_with_retry, #retry_options, #safe_parse_json, #url
Instance Method Details
#authenticate_user(login:, password:, uri: DEFAULT_LOGIN_URL, auth_headers: {}) ⇒ Hash, String
Authenticates a user with the given credentials.
22 23 24 |
# File 'lib/simple_auth_sdk/api/authentication_endpoints.rb', line 22 def authenticate_user(login:, password:, uri: DEFAULT_LOGIN_URL, auth_headers: {}) request_with_retry(:post, uri, { login: login, password: password }, auth_headers) end |
#create_user(login:, confirmed_login:, password:, confirmed_password:, uri: DEFAULT_CREATE_USER_PATH, auth_headers: {}) ⇒ Hash, String
Creates a new user account with the given credentials.
37 38 39 40 41 42 43 44 45 |
# File 'lib/simple_auth_sdk/api/authentication_endpoints.rb', line 37 def create_user(login:, confirmed_login:, password:, confirmed_password:, uri: DEFAULT_CREATE_USER_PATH, auth_headers: {}) body = { 'login': login, 'login-confirm': confirmed_login, 'password': password, 'password-confirm': confirmed_password } request_with_retry(:post, uri, body, auth_headers) end |