lib/ocean/ocean_application_controller.rb
def require_x_api_token
    return true if ENV['NO_OCEAN_AUTH']
    @x_api_token = request.headers['X-API-Token']
    Thread.current[:x_api_token] = @x_api_token
    @x_metadata = request.headers['X-Metadata']
    @x_metadata = @x_metadata.to_s[0, 128] if @x_metadata
    Thread.current[:metadata] = @x_metadata
    return true if @x_api_token.present?
    logger.info "X-API-Token missing"
    render_api_error 400, "X-API-Token missing"
    expires_in 0, must_revalidate: true
    false
  end
#
# Ensures that there is an +X-API-Token+ HTTP header in the request.
# Stores the token in @x_api_token for use during authorisation of the
# current controller action. If there's no +X-API-Token+ header, the
# request is aborted and an API error with status 400 is returned.
#
# 400 error responses will always contain a body with error information
# explaining the API error:
#
#  {"_api_error": ["X-API-Token missing"]}
#
# or
#
#  {"_api_error": ["Authentication expired"]}
#
Ensures that there is an +X-API-Token+ HTTP header in the request.
Stores the token in @x_api_token for use during authorisation of the
current controller action. If there's no +X-API-Token+ header, the
request is aborted and an API error with status 400 is returned.

400 error responses will always contain a body with error information
explaining the API error.



or


Ensures that there is an + X - API - Token + HTTP header in the request . Stores the token in @x_api_token for use during authorisation of the current controller action . If there ' s no + X - API - Token + header the request is aborted and an API error with status 400 is returned . 400 error responses will always contain a body with error information explaining the API error . or
def require_x_api_token
    return true if ENV['NO_OCEAN_AUTH']
    @x_api_token = request.headers['X-API-Token']
    Thread.current[:x_api_token] = @x_api_token
    @x_metadata = request.headers['X-Metadata']
    @x_metadata = @x_metadata.to_s[0, 128] if @x_metadata
    Thread.current[:metadata] = @x_metadata
    return true if @x_api_token.present?
    logger.info "X-API-Token missing"
    render_api_error 400, "X-API-Token missing"
    expires_in 0, must_revalidate: true
    false
  end
def require_x_api_token return true if ENV [ 'NO_OCEAN_AUTH' ] @x_api_token = request . headers [ 'X-API-Token' ] Thread . current [ :x_api_token ] = @x_api_token @x_metadata = request . headers [ 'X-Metadata' ] @x_metadata = @x_metadata . to_s [ 0 , 128 ] if @x_metadata Thread . current [ :metadata ] = @x_metadata return true if @x_api_token . present? logger . info "X-API-Token missing" render_api_error 400 , "X-API-Token missing" expires_in 0 , must_revalidate : true false end
Ensures that there is an +X-API-Token+ HTTP header in the request.
Ensures that there is an + X - API - Token + HTTP header in the request .