[add] added query string support

This commit was merged in pull request #2.
This commit is contained in:
2021-03-07 19:11:49 -05:00
parent c0a05f653c
commit 297016e799
4 changed files with 53 additions and 26 deletions

View File

@@ -178,10 +178,12 @@ class ClientsController < ApplicationController
# check if the api is valid and has the appropriate prefix
def parse_api_key_header
# TODO: move api_key checks and formatting to helper class
# check if api key is present and can be split into 3 parts: <prefix>.<name_id>.<api_key>
# check if api key is present in header or param and can be split into 3 parts: <prefix>.<name_id>.<api_key>
# NOTE: .compact is more for got measure than really necessary, but this ensures no nil values in the array
api_key_header = request.headers[RynDNS::Application::API_KEY_HEADER].split('.').compact unless
request.headers[RynDNS::Application::API_KEY_HEADER].nil?
api_key_header ||= params[RynDNS::Application::API_KEY_HEADER].split('.').compact if
params.has_key?(RynDNS::Application::API_KEY_HEADER)
return head(401) if api_key_header.nil? || api_key_header.length < 3
prefix, @name_id, @api_key = api_key_header