Skip to content

Commit

Permalink
docs: add acceptance test for passportfacebook example
Browse files Browse the repository at this point in the history
  • Loading branch information
deepakrkris authored and DEEPAK RAJAMOHAN committed Apr 13, 2020
1 parent ce3626f commit 1c027c3
Show file tree
Hide file tree
Showing 33 changed files with 906 additions and 227 deletions.
17 changes: 12 additions & 5 deletions examples/passport-login/data/db.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
{
"ids": {
"User": 2,
"UserIdentity": 100487451443373280000
"User": 4,
"UserIdentity": 104566694532671,
"UserCredentials": 2
},
"models": {
"User": {
"1": "{\"name\":\"Open Graph Test User\",\"username\":\"[email protected]\",\"email\":\"[email protected]\",\"id\":1}"
"1": "{\"name\":\"{\\\"familyName\\\":\\\"User\\\",\\\"givenName\\\":\\\"Open\\\",\\\"middleName\\\":\\\"Graph Test\\\"}\",\"username\":\"[email protected]\",\"email\":\"[email protected]\",\"id\":1}",
"2": "{\"name\":\"Test User\",\"username\":\"[email protected]\",\"email\":\"[email protected]\",\"id\":2}",
"3": "{\"name\":\"\\\"tinkerbell\\\"\",\"username\":\"[email protected]\",\"email\":\"[email protected]\",\"id\":3}"
},
"UserIdentity": {
"104566694532668": "{\"id\":\"104566694532668\",\"provider\":\"facebook\",\"profile\":{\"emails\":[{\"value\":\"[email protected]\"}]},\"authScheme\":\"facebook\",\"created\":\"2020-04-07T18:40:25.360Z\",\"userId\":1}",
"100487451443373281118": "{\"id\":\"100487451443373281118\",\"provider\":\"google\",\"profile\":{\"emails\":[{\"value\":\"[email protected]\",\"type\":\"account\"}]},\"authScheme\":\"google\",\"created\":\"2020-04-07T18:40:52.941Z\",\"userId\":1}"
"1001": "{\"id\":\"1001\",\"provider\":\"custom-oauth2\",\"profile\":{\"emails\":[{\"value\":\"[email protected]\"}]},\"authScheme\":\"custom-oauth2\",\"created\":\"2020-04-13T04:50:47.249Z\",\"userId\":3}",
"1003": "{\"id\":\"1003\",\"provider\":\"custom-oauth2\",\"profile\":{\"emails\":[{\"value\":\"[email protected]\"}]},\"authScheme\":\"custom-oauth2\",\"created\":\"2020-04-13T04:50:47.110Z\",\"userId\":2}",
"104566694532668": "{\"id\":\"104566694532668\",\"provider\":\"facebook\",\"profile\":{\"emails\":[{\"value\":\"[email protected]\"}]},\"authScheme\":\"facebook\",\"created\":\"2020-04-13T04:05:47.375Z\",\"userId\":1}"
},
"UserCredentials": {
"[email protected]": "{\"id\":\"[email protected]\",\"password\":\"password\",\"userId\":2}"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"profileFields": ["gender", "link", "locale", "name", "timezone",
"verified", "email", "updated_time", "displayName", "id"],
"clientID": "{facebook-client-id}",
"clientSecret": "ad4315e3453b012f6e4b8dd4bc1c0ae6",
"clientSecret": "{facebook-client-secret}",
"callbackURL": "/api/auth/thirdparty/facebook/callback",
"authPath": "/api/auth/thirdparty/facebook",
"callbackPath": "/api/auth/thirdparty/facebook/callback",
Expand All @@ -19,7 +19,7 @@
"module": "passport-google-oauth2",
"strategy": "OAuth2Strategy",
"clientID": "{google-client-id}",
"clientSecret": "FcldSqY5-9usqlRmQhZawN__",
"clientSecret": "{google-client-secret}",
"callbackURL": "/api/auth/thirdparty/google/callback",
"authPath": "/api/auth/thirdparty/google",
"callbackPath": "/api/auth/thirdparty/google/callback",
Expand All @@ -30,18 +30,18 @@
},
"oauth2": {
"provider": "oauth2",
"module": "passport-google-oauth2",
"module": "passport-oauth2",
"strategy": "OAuth2Strategy",
"clientID": "{google-client-id}",
"clientSecret": "FcldSqY5-9usqlRmQhZawN__",
"callbackURL": "/api/auth/thirdparty/google/callback",
"authPath": "/api/auth/thirdparty/google",
"callbackPath": "/api/auth/thirdparty/google/callback",
"authPath": "/api/auth/thirdparty/oauth2",
"callbackPath": "/api/auth/thirdparty/oauth2/callback",
"successRedirect": "/auth/account",
"failureRedirect": "/login",
"scope": ["email", "profile"],
"failureFlash": true,
"authorizationURL": "https://localhost:8080",
"tokenURL": "https://localhost:8080"
"clientID": "1111",
"clientSecret": "app1_secret",
"callbackURL": "http://localhost:3000/api/auth/thirdparty/oauth2/callback",
"authorizationURL": "http://localhost:9000/oauth/dialog",
"tokenURL": "http://localhost:9000/oauth/token"
}
}
17 changes: 1 addition & 16 deletions examples/passport-login/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,7 @@ const application = require('./dist');
module.exports = application;

if (require.main === module) {
// Run the application
const config = {
rest: {
port: +(process.env.PORT || 3000),
host: process.env.HOST,
protocol: 'http',
gracePeriodForClose: 5000, // 5 seconds
openApiSpec: {
// useful when used with OpenAPI-to-GraphQL to locate your application
setServersFromRequest: true,
},
// Use the LB4 application as a route. It should not be listening.
listenOnStart: false,
},
};
application.main(config).catch(err => {
application.main().catch((err) => {
console.error('Cannot start the application.', err);
process.exit(1);
});
Expand Down
5 changes: 5 additions & 0 deletions examples/passport-login/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
// Copyright IBM Corp. 2020. All Rights Reserved.
// Node module: @loopback/example-passport-login
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

export * from './src';
47 changes: 47 additions & 0 deletions examples/passport-login/oauth2-providers.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"facebook-login": {
"provider": "facebook",
"module": "passport-facebook",
"profileFields": ["gender", "link", "locale", "name", "timezone",
"verified", "email", "updated_time", "displayName", "id"],
"clientID": "{facebook-client-id}",
"clientSecret": "{facebook-client-secret}",
"callbackURL": "/api/auth/thirdparty/facebook/callback",
"authPath": "/api/auth/thirdparty/facebook",
"callbackPath": "/api/auth/thirdparty/facebook/callback",
"successRedirect": "/auth/account",
"failureRedirect": "/login",
"scope": ["email"],
"failureFlash": true
},
"google-login": {
"provider": "google",
"module": "passport-google-oauth2",
"strategy": "OAuth2Strategy",
"clientID": "{google-client-id}",
"clientSecret": "{google-client-secret}",
"callbackURL": "/api/auth/thirdparty/google/callback",
"authPath": "/api/auth/thirdparty/google",
"callbackPath": "/api/auth/thirdparty/google/callback",
"successRedirect": "/auth/account",
"failureRedirect": "/login",
"scope": ["email", "profile"],
"failureFlash": true
},
"oauth2": {
"provider": "oauth2",
"module": "passport-oauth2",
"strategy": "OAuth2Strategy",
"authPath": "/api/auth/thirdparty/oauth2",
"callbackPath": "/api/auth/thirdparty/oauth2/callback",
"successRedirect": "/auth/account",
"failureRedirect": "/login",
"scope": ["email", "profile"],
"failureFlash": true,
"clientID": "1111",
"clientSecret": "app1_secret",
"callbackURL": "http://localhost:3000/api/auth/thirdparty/oauth2/callback",
"authorizationURL": "http://localhost:9000/oauth/dialog",
"tokenURL": "http://localhost:9000/oauth/token"
}
}
110 changes: 82 additions & 28 deletions examples/passport-login/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1c027c3

Please sign in to comment.