strongloop / loopback-component-oauth2

oAuth 2.0 server for LoopBack
http://www.strongloop.com
Other
62 stars 60 forks source link

Allow declarative config of OAuth2 component #9

Closed bajtos closed 9 years ago

bajtos commented 9 years ago

Implement a new middleware factory loopback-component-oauth2#authenticate that can be configured in server/middleware.json and which invokes the authentication middleware created by loopback-component-oauth2(app).

Modify the main exported function to store the list of OAuth2 handlers/endpoints on the app object, so that the new middleware can retrieve it from there.

/to @raymondfeng please review

This is the Gateway configuration that works for me (I'll send a pull request shortly):

server/component-config.json

{
  "loopback-component-oauth2": {
    "dataSource": "db",
    "loginPage": "/login",
    "loginPath": "/login"
  }
}

server/middleware.json (snippet)

{
  "auth": {
    "loopback-component-oauth2#authenticate": {
      "paths": [
        "/protected",
        "/api",
        "/me"
      ],
      "params": {
        "session": false,
        "scope": "demo"
      }
    }
  }
}
raymondfeng commented 9 years ago

LGTM

raymondfeng commented 9 years ago

LGTM