lib/ocean/ocean_application_controller.rb
def authorize_action
    return true if ENV['NO_OCEAN_AUTH']
    # Obtain any nonstandard actions
    @@extra_actions[controller_name] ||= begin
      extra_actions
    rescue NameError => e
      {}
    end
    # Create a query string and call Auth
    qs = Api.authorization_string(@@extra_actions, controller_name, action_name)
    response = Api.permitted?(@x_api_token, query: qs)
    if response.status == 200
      a = response.body['authentication']
      @auth_api_user_id = a['user_id']  # Deprecate and remove
      @auth_api_user_uri = a['_links']['creator']['href']  # Keep
      Thread.current[:username] = a['username']
      @right_restrictions = a['right']
      params['_right_restrictions'] = @right_restrictions if @right_restrictions
      @group_names = a['group_names'].to_set if a['group_names']
      return true
    end
    error_messages = response.body['_api_error']
    render_api_error response.status, *error_messages
    expires_in 0, must_revalidate: true
    false
  end
#
# Performs authorisation of the current action. Returns true if allowed,
# false if not. Calls the Auth service using a +GET+, which means previous
# authorisations using the same token and args will be cached in Varnish.
#
Performs authorisation of the current action. Returns true if allowed,
false if not. Calls the Auth service using a +GET+, which means previous
authorisations using the same token and args will be cached in Varnish.
Performs authorisation of the current action . Returns true if allowed false if not . Calls the Auth service using a + GET + which means previous authorisations using the same token and args will be cached in Varnish .
def authorize_action
    return true if ENV['NO_OCEAN_AUTH']
    @@extra_actions[controller_name] ||= begin
      extra_actions
    rescue NameError => e
      {}
    end
    qs = Api.authorization_string(@@extra_actions, controller_name, action_name)
    response = Api.permitted?(@x_api_token, query: qs)
    if response.status == 200
      a = response.body['authentication']
      @auth_api_user_id = a['user_id']  
      @auth_api_user_uri = a['_links']['creator']['href']  
      Thread.current[:username] = a['username']
      @right_restrictions = a['right']
      params['_right_restrictions'] = @right_restrictions if @right_restrictions
      @group_names = a['group_names'].to_set if a['group_names']
      return true
    end
    error_messages = response.body['_api_error']
    render_api_error response.status, *error_messages
    expires_in 0, must_revalidate: true
    false
  end
def authorize_action return true if ENV [ 'NO_OCEAN_AUTH' ] @@extra_actions [ controller_name ] ||= begin extra_actions rescue NameError => e { } end qs = Api . authorization_string ( @@extra_actions , controller_name , action_name ) response = Api . permitted? ( @x_api_token , query : qs ) if response . status == 200 a = response . body [ 'authentication' ] @auth_api_user_id = a [ 'user_id' ] @auth_api_user_uri = a [ '_links' ] [ 'creator' ] [ 'href' ] Thread . current [ :username ] = a [ 'username' ] @right_restrictions = a [ 'right' ] params [ '_right_restrictions' ] = @right_restrictions if @right_restrictions @group_names = a [ 'group_names' ] . to_set if a [ 'group_names' ] return true end error_messages = response . body [ '_api_error' ] render_api_error response . status , * error_messages expires_in 0 , must_revalidate : true false end
Performs authorisation of the current action.
Performs authorisation of the current action .
# Obtain any nonstandard actions # Create a query string and call Auth # Deprecate and remove # Keep