Skip to content

app.enableAuth should fail when models are not configured correctly #171

Closed

Description

@bajtos

The access control code requires that the following models are present & attached to a datasource:

loopback.User
loopback.AccessToken
loopback.Role
loopback.ACL

Additionally User model must have a hasMany relationship with AccessToken.

Expected behaviour
app.enableAuth() should check that these models are correctly configured, otherwise throw an error.

It would be nice if the pre-build User and AccessToken models have the relationship already defined.

Notes
It's possible the list is not complete, how about RoleMapping or Scope?

Activity

  1. bajtos commented on Feb 5, 2014

    @bajtos
    MemberAuthor

    #158 is attacking the same problem from a different side.

  2. self-assigned this
    on Feb 28, 2014
  3. added this to the milestone on Feb 28, 2014
  4. raymondfeng commented on Jul 23, 2014

    @raymondfeng
    Member

    PersistedModel is now the base class that reports errors if the model is not attached to a data source

  5. bajtos commented on Jul 24, 2014

    @bajtos
    MemberAuthor

    @raymondfeng I disagree, this issue is not resolved. The error should be raised at the time you call app.enableAuth (during startup), not at the time the first request arrives. I am reopening this issue.

  6. reopened this on Jul 24, 2014
  7. removed this from the milestone on Jul 24, 2014
  8. bajtos commented on Apr 7, 2016

    @bajtos
    MemberAuthor

    In #1323, we added an option to enableAuth to auto-attach any missing auth models to a given data-source. When this option is set, enableAuth will validate that all required models are present and attached to a data source.

    However, when the option is not present, the validation is skipped.

    I am proposing to modify enableAuth to run the validation even when the new option is not set. This may break existing applications (although it's not very likely), let's make this change in 3.0 only.

  9. 5 remaining items

  10. removed their assignment
    on Dec 13, 2016
  11. bajtos commented on Mar 23, 2017

    @bajtos
    MemberAuthor

    @ebarault PTAL, this may be something to consider in your current work on verifying auth setup.

  12. ebarault commented on Mar 23, 2017

    @ebarault
    Contributor

    @bajtos : thanks for bringing this to my attention !
    (Gosh we are traveling through time here! 3 years back you were discussing this already, seems like things happen eventually :-) )

    I am proposing to modify enableAuth to run the validation even when the new option is not set. This may break existing applications (although it's not very likely), let's make this change in 3.0 only.

    👍
    Do we implement this right away, or do we use a feature-flag?
    IMO: i don't see valid use cases where enableAuth() is called, models are not set up, and the app is fully functional. So i'd go without a feature-flag.

  13. stale commented on Aug 27, 2017

    @stale

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

  14. stale commented on Sep 11, 2017

    @stale

    This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS file at the top-level of this repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions