Skip to content

Commit

Permalink
docs: migrate loopback-example-passport repo as lb4 example
Browse files Browse the repository at this point in the history
  • Loading branch information
deepakrkris committed Apr 10, 2020
1 parent 848272d commit ce3626f
Show file tree
Hide file tree
Showing 55 changed files with 4,339 additions and 0 deletions.
3 changes: 3 additions & 0 deletions examples/passport-login/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
dist/
coverage/
3 changes: 3 additions & 0 deletions examples/passport-login/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: '@loopback/eslint-config',
};
64 changes: 64 additions & 0 deletions examples/passport-login/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Typescript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# Transpiled JavaScript files from Typescript
/dist

# Cache used by TypeScript's incremental build
*.tsbuildinfo
2 changes: 2 additions & 0 deletions examples/passport-login/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Exclude *.tsbuildinfo - cache for tsc incremental builds
*.tsbuildinfo
1 change: 1 addition & 0 deletions examples/passport-login/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=true
2 changes: 2 additions & 0 deletions examples/passport-login/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
*.json
6 changes: 6 additions & 0 deletions examples/passport-login/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"bracketSpacing": false,
"singleQuote": true,
"printWidth": 80,
"trailingComma": "all"
}
15 changes: 15 additions & 0 deletions examples/passport-login/data/db.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"ids": {
"User": 2,
"UserIdentity": 100487451443373280000
},
"models": {
"User": {
"1": "{\"name\":\"Open Graph Test User\",\"username\":\"[email protected]\",\"email\":\"[email protected]\",\"id\":1}"
},
"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}"
}
}
}
30 changes: 30 additions & 0 deletions examples/passport-login/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// 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

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 => {
console.error('Cannot start the application.', err);
process.exit(1);
});
}
1 change: 1 addition & 0 deletions examples/passport-login/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './src';
47 changes: 47 additions & 0 deletions examples/passport-login/oauth2-providers.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": "ad4315e3453b012f6e4b8dd4bc1c0ae6",
"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": "FcldSqY5-9usqlRmQhZawN__",
"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-google-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",
"successRedirect": "/auth/account",
"failureRedirect": "/login",
"scope": ["email", "profile"],
"failureFlash": true,
"authorizationURL": "https://localhost:8080",
"tokenURL": "https://localhost:8080"
}
}
Loading

0 comments on commit ce3626f

Please sign in to comment.