├── react-app ├── public │ ├── robots.txt │ ├── favicon.ico │ ├── logo192.png │ ├── logo512.png │ ├── manifest.json │ └── index.html ├── src │ ├── NotesAPI.js │ ├── setupTests.js │ ├── App.test.js │ ├── Note.js │ ├── index.css │ ├── Config.js │ ├── App.css │ ├── index.js │ ├── NoteForm.js │ ├── logo.svg │ ├── App.js │ └── serviceWorker.js ├── .gitignore ├── README.md └── package.json ├── mw-app ├── .vscode │ └── extensions.json ├── host.json ├── echo │ ├── function.json │ ├── datasources.js │ └── index.js ├── package.json ├── .gitignore ├── README.md └── package-lock.json ├── .vscode ├── settings.json └── tasks.json ├── CODE_OF_CONDUCT.md ├── LICENSE ├── SUPPORT.md ├── .gitignore ├── SECURITY.md └── README.md /react-app/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /react-app/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/aadb2c-starter-kit/main/react-app/public/favicon.ico -------------------------------------------------------------------------------- /react-app/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/aadb2c-starter-kit/main/react-app/public/logo192.png -------------------------------------------------------------------------------- /react-app/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/aadb2c-starter-kit/main/react-app/public/logo512.png -------------------------------------------------------------------------------- /mw-app/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "ms-azuretools.vscode-azurefunctions" 4 | ] 5 | } -------------------------------------------------------------------------------- /react-app/src/NotesAPI.js: -------------------------------------------------------------------------------- 1 | import { ApolloClient, InMemoryCache } from '@apollo/client'; 2 | import { config } from './Config'; 3 | 4 | const NotesApi = new ApolloClient({ 5 | uri: config.apiurl, 6 | cache: new InMemoryCache() 7 | }); 8 | 9 | export default NotesApi; 10 | -------------------------------------------------------------------------------- /react-app/src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom/extend-expect'; 6 | -------------------------------------------------------------------------------- /react-app/src/App.test.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { render } from '@testing-library/react'; 3 | import App from './App'; 4 | 5 | test('renders learn react link', () => { 6 | const { getByText } = render(); 7 | const linkElement = getByText(/learn react/i); 8 | expect(linkElement).toBeInTheDocument(); 9 | }); 10 | -------------------------------------------------------------------------------- /react-app/src/Note.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | 3 | class Note extends Component { 4 | 5 | 6 | render(){ 7 | 8 | 9 | return ( 10 |
11 | {this.props.note.id} 12 |

Text:{this.props.note.text}

13 |
14 | ); 15 | } 16 | } 17 | 18 | export default Note; 19 | -------------------------------------------------------------------------------- /mw-app/host.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0", 3 | "logging": { 4 | "applicationInsights": { 5 | "samplingSettings": { 6 | "isEnabled": true, 7 | "excludedTypes": "Request" 8 | } 9 | } 10 | }, 11 | "extensionBundle": { 12 | "id": "Microsoft.Azure.Functions.ExtensionBundle", 13 | "version": "[1.*, 2.0.0)" 14 | } 15 | } -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "azureFunctions.projectSubpath": "mw-app", 3 | "azureFunctions.deploySubpath": "mw-app", 4 | "azureFunctions.postDeployTask": "npm install", 5 | "azureFunctions.projectLanguage": "JavaScript", 6 | "azureFunctions.projectRuntime": "~3", 7 | "debug.internalConsoleOptions": "neverOpen", 8 | "azureFunctions.preDeployTask": "npm prune" 9 | } -------------------------------------------------------------------------------- /react-app/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /mw-app/echo/function.json: -------------------------------------------------------------------------------- 1 | { 2 | "bindings": [ 3 | { 4 | "authLevel": "anonymous", 5 | "type": "httpTrigger", 6 | "direction": "in", 7 | "name": "req", 8 | "route": "u/{uid}", 9 | "methods": [ 10 | "get", 11 | "post", 12 | "options" 13 | ] 14 | }, 15 | { 16 | "type": "http", 17 | "direction": "out", 18 | "name": "$return" 19 | } 20 | ] 21 | } -------------------------------------------------------------------------------- /react-app/README.md: -------------------------------------------------------------------------------- 1 | This is the REACT app 2 | 3 | # Run 4 | 1. run ``npm install```` to install dependencies 5 | 2. take a look at /src/config.js the app uses the middleware in azure. If you want to change the app to run against a local middleware just uncomment the localhost address 6 | 7 | # Build 8 | If you want an all static version of this app just run 9 | ```npm run build``` 10 | The static content will be in build directory. 11 | 12 | -------------------------------------------------------------------------------- /react-app/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Microsoft Open Source Code of Conduct 2 | 3 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). 4 | 5 | Resources: 6 | 7 | - [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/) 8 | - [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) 9 | - Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns 10 | -------------------------------------------------------------------------------- /mw-app/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "", 3 | "version": "", 4 | "description": "", 5 | "scripts": { 6 | "test": "echo \"No tests yet...\"" 7 | }, 8 | "dependencies": { 9 | "@azure/cosmos": "^3.10.5", 10 | "@azure/service-bus": "^7.0.0", 11 | "apollo-datasource": "^0.1.3", 12 | "apollo-datasource-rest": "^0.1.5", 13 | "apollo-server-azure-functions": "^2.23.0", 14 | "azure-function-log-intercept": "^1.0.7", 15 | "cors": "^2.8.5", 16 | "graphql": "^15.5.0", 17 | "uuid": "^8.3.2" 18 | }, 19 | "author": "" 20 | } 21 | -------------------------------------------------------------------------------- /mw-app/.gitignore: -------------------------------------------------------------------------------- 1 | bin 2 | obj 3 | csx 4 | .vs 5 | edge 6 | Publish 7 | 8 | *.user 9 | *.suo 10 | *.cscfg 11 | *.Cache 12 | project.lock.json 13 | 14 | /packages 15 | /TestResults 16 | 17 | /tools/NuGet.exe 18 | /App_Data 19 | /secrets 20 | /data 21 | .secrets 22 | appsettings.json 23 | local.settings.json 24 | 25 | node_modules 26 | dist 27 | 28 | # Local python packages 29 | .python_packages/ 30 | 31 | # Python Environments 32 | .env 33 | .venv 34 | env/ 35 | venv/ 36 | ENV/ 37 | env.bak/ 38 | venv.bak/ 39 | 40 | # Byte-compiled / optimized / DLL files 41 | __pycache__/ 42 | *.py[cod] 43 | *$py.class -------------------------------------------------------------------------------- /react-app/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /react-app/src/Config.js: -------------------------------------------------------------------------------- 1 | const prod = { 2 | apiurl: 'https://adb2cstarterkitmw.azurewebsites.net/api/u/', 3 | clientId: '0da90f62-a335-4338-a70a-3d73ea275926', 4 | authority: 'https://aadb2cstarterkit.b2clogin.com/tfp/aadb2cstarterkit.onmicrosoft.com/B2C_1_signup_signin/', 5 | 6 | }; 7 | const dev = { 8 | apiurl: 'https://adb2cstarterkitmw.azurewebsites.net/api/u/', 9 | //uncomment to run against local 10 | //apiurl: 'http://localhost:7071/api/u/', 11 | clientId: prod.clientId, 12 | authority: prod.authority, 13 | 14 | }; 15 | export const config = process.env.NODE_ENV === 'development' ? dev: prod; -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "type": "func", 6 | "command": "host start", 7 | "problemMatcher": "$func-node-watch", 8 | "isBackground": true, 9 | "dependsOn": "npm install", 10 | "options": { 11 | "cwd": "${workspaceFolder}/mw-app" 12 | } 13 | }, 14 | { 15 | "type": "shell", 16 | "label": "npm install", 17 | "command": "npm install", 18 | "options": { 19 | "cwd": "${workspaceFolder}/mw-app" 20 | } 21 | }, 22 | { 23 | "type": "shell", 24 | "label": "npm prune", 25 | "command": "npm prune --production", 26 | "problemMatcher": [], 27 | "options": { 28 | "cwd": "${workspaceFolder}/mw-app" 29 | } 30 | } 31 | ] 32 | } -------------------------------------------------------------------------------- /react-app/src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | height: 40vmin; 7 | pointer-events: none; 8 | } 9 | 10 | @media (prefers-reduced-motion: no-preference) { 11 | .App-logo { 12 | animation: App-logo-spin infinite 20s linear; 13 | } 14 | } 15 | 16 | .App-header { 17 | background-color: #282c34; 18 | min-height: 100vh; 19 | display: flex; 20 | flex-direction: column; 21 | align-items: center; 22 | justify-content: center; 23 | font-size: calc(10px + 2vmin); 24 | color: white; 25 | } 26 | 27 | .App-link { 28 | color: #61dafb; 29 | } 30 | 31 | @keyframes App-logo-spin { 32 | from { 33 | transform: rotate(0deg); 34 | } 35 | to { 36 | transform: rotate(360deg); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /react-app/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "reactadb2c", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@apollo/client": "^3.3.15", 7 | "@testing-library/jest-dom": "^4.2.4", 8 | "@testing-library/react": "^9.5.0", 9 | "@testing-library/user-event": "^7.2.1", 10 | "bootstrap": "^4.6.0", 11 | "graphql": "^15.5.0", 12 | "msal": "^1.4.9", 13 | "react": "^16.14.0", 14 | "react-bootstrap": "^1.5.2", 15 | "react-dom": "^16.14.0", 16 | "react-scripts": "3.4.1", 17 | "semantic-ui-css": "^2.4.1", 18 | "semantic-ui-react": "^2.0.3" 19 | }, 20 | "scripts": { 21 | "start": "react-scripts start", 22 | "build": "react-scripts build", 23 | "test": "react-scripts test", 24 | "eject": "react-scripts eject" 25 | }, 26 | "eslintConfig": { 27 | "extends": "react-app" 28 | }, 29 | "browserslist": { 30 | "production": [ 31 | ">0.2%", 32 | "not dead", 33 | "not op_mini all" 34 | ], 35 | "development": [ 36 | "last 1 chrome version", 37 | "last 1 firefox version", 38 | "last 1 safari version" 39 | ] 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE 22 | -------------------------------------------------------------------------------- /react-app/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import * as serviceWorker from './serviceWorker'; 6 | import * as Msal from "msal"; 7 | import { Button } from 'react-bootstrap'; 8 | 9 | 10 | 11 | 12 | 13 | var apiTokenRequest = { 14 | scopes: ["https://ssdadb2cdevbackend.azurewebsites.net/api/echo"] // optional Array 15 | }; 16 | let token; 17 | let apiresponse; 18 | let givenname; 19 | let email; 20 | let displayname; 21 | let id; 22 | 23 | 24 | 25 | let fetchFromAPI = function () { 26 | var headers = new Headers(); 27 | var bearer = "Bearer " + token; 28 | headers.append("Authorization", bearer); 29 | var options = { 30 | method: "GET", 31 | headers: headers 32 | }; 33 | var graphEndpoint = "https://ssdadb2cdevbackend.azurewebsites.net/api/echo?name=hihihi";//"https://graph.microsoft.com/v1.0/me"; 34 | 35 | fetch(graphEndpoint, options) 36 | .then(response => response.json()) 37 | .then(data => { 38 | console.log("hey"); 39 | 40 | apiresponse = data.text; 41 | 42 | render(); 43 | }); 44 | 45 | } 46 | 47 | let render = function () { 48 | ReactDOM.render( 49 | 50 | 51 | , 52 | document.getElementById('root') 53 | ); 54 | }; 55 | render(); 56 | -------------------------------------------------------------------------------- /SUPPORT.md: -------------------------------------------------------------------------------- 1 | # TODO: The maintainer of this repo has not yet edited this file 2 | 3 | **REPO OWNER**: Do you want Customer Service & Support (CSS) support for this product/project? 4 | 5 | - **No CSS support:** Fill out this template with information about how to file issues and get help. 6 | - **Yes CSS support:** Fill out an intake form at [aka.ms/spot](https://aka.ms/spot). CSS will work with/help you to determine next steps. More details also available at [aka.ms/onboardsupport](https://aka.ms/onboardsupport). 7 | - **Not sure?** Fill out a SPOT intake as though the answer were "Yes". CSS will help you decide. 8 | 9 | *Then remove this first heading from this SUPPORT.MD file before publishing your repo.* 10 | 11 | # Support 12 | 13 | ## How to file issues and get help 14 | 15 | This project uses GitHub Issues to track bugs and feature requests. Please search the existing 16 | issues before filing new issues to avoid duplicates. For new issues, file your bug or 17 | feature request as a new Issue. 18 | 19 | For help and questions about using this project, please **REPO MAINTAINER: INSERT INSTRUCTIONS HERE 20 | FOR HOW TO ENGAGE REPO OWNERS OR COMMUNITY FOR HELP. COULD BE A STACK OVERFLOW TAG OR OTHER 21 | CHANNEL. WHERE WILL YOU HELP PEOPLE?**. 22 | 23 | ## Microsoft Support Policy 24 | 25 | Support for this **PROJECT or PRODUCT** is limited to the resources listed above. 26 | -------------------------------------------------------------------------------- /mw-app/echo/datasources.js: -------------------------------------------------------------------------------- 1 | const { RESTDataSource } = require('apollo-datasource-rest'); 2 | const { CosmosClient } = require('@azure/cosmos'); 3 | const { v4: uuidv4 } =require('uuid'); 4 | 5 | 6 | 7 | class CosmosBackend extends RESTDataSource { 8 | constructor() { 9 | super(); 10 | this.client = new CosmosClient(process.env.cosmos); 11 | } 12 | getNotesCollection(){ 13 | 14 | return this.client.database("notesdb").container("notescontainer"); 15 | } 16 | 17 | async getNotesByUserid({ userid }) { 18 | 19 | let results = await this.getNotesCollection() 20 | .items.query({ 21 | query: 'SELECT * FROM c where c.userid="'+userid +'"', 22 | }) 23 | .fetchAll(); 24 | 25 | 26 | return results.resources.length >=1 ?results.resources:[]; 27 | } 28 | 29 | async updateNote({id,pk,text}){ 30 | 31 | let {resource} = await this.getNotesCollection().item(id,pk).read(); 32 | if(resource){ 33 | resource.text=text; 34 | await this.getNotesCollection().item(id,pk).replace(resource); 35 | return resource; 36 | } 37 | return null; 38 | } 39 | 40 | async newNote({userid,text}){ 41 | let nNote={ 42 | id: uuidv4(), 43 | userid: userid, 44 | text: text 45 | }; 46 | let { resource: createdItem } = await this.getNotesCollection().items.create(nNote); 47 | return createdItem?createdItem:null; 48 | } 49 | 50 | 51 | 52 | } 53 | module.exports = CosmosBackend; -------------------------------------------------------------------------------- /react-app/src/NoteForm.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | 3 | 4 | 5 | 6 | class NoteForm extends Component { 7 | constructor(props) { 8 | super(props); 9 | this.state = { 10 | submitting: false, 11 | title: '', 12 | content: '' 13 | }; 14 | } 15 | formChangeHandler=(event)=>{ 16 | let nam = event.target.name; 17 | let val = event.target.value; 18 | this.setState({[nam]: val}); 19 | } 20 | 21 | 22 | 23 | 24 | submitForm = (event) => { 25 | event.preventDefault(); 26 | this.setState({ submitting: true }); 27 | this.props.submitCallback({text:this.state.content}); 28 | this.setState({contents:""}); 29 | } 30 | 31 | render() { 32 | 33 | 34 | return ( 35 |
36 | {!this.props.submitting ? 37 |
38 | 39 | 40 | 41 |