Skip to content
This repository has been archived by the owner. It is now read-only.

Commit c4f8e1f

Browse files
authored
Merge pull request #52 from Azure-Samples/derisen-refactoring
refactoring
2 parents 7c926d2 + 77867c7 commit c4f8e1f

18 files changed

+1422
-635
lines changed

.gitignore

Lines changed: 2 additions & 252 deletions
Original file line numberDiff line numberDiff line change
@@ -1,252 +1,2 @@
1-
## Ignore Visual Studio temporary files, build results, and
2-
## files generated by popular Visual Studio add-ons.
3-
4-
# User-specific files
5-
*.suo
6-
*.user
7-
*.userosscache
8-
*.sln.docstates
9-
10-
# User-specific files (MonoDevelop/Xamarin Studio)
11-
*.userprefs
12-
13-
# Build results
14-
[Dd]ebug/
15-
[Dd]ebugPublic/
16-
[Rr]elease/
17-
[Rr]eleases/
18-
x64/
19-
x86/
20-
bld/
21-
[Bb]in/
22-
[Oo]bj/
23-
[Ll]og/
24-
25-
# Visual Studio 2015 cache/options directory
26-
.vs/
27-
# Uncomment if you have tasks that create the project's static files in wwwroot
28-
#wwwroot/
29-
30-
# MSTest test Results
31-
[Tt]est[Rr]esult*/
32-
[Bb]uild[Ll]og.*
33-
34-
# NUNIT
35-
*.VisualState.xml
36-
TestResult.xml
37-
38-
# Build Results of an ATL Project
39-
[Dd]ebugPS/
40-
[Rr]eleasePS/
41-
dlldata.c
42-
43-
# DNX
44-
project.lock.json
45-
artifacts/
46-
47-
*_i.c
48-
*_p.c
49-
*_i.h
50-
*.ilk
51-
*.meta
52-
*.obj
53-
*.pch
54-
*.pdb
55-
*.pgc
56-
*.pgd
57-
*.rsp
58-
*.sbr
59-
*.tlb
60-
*.tli
61-
*.tlh
62-
*.tmp
63-
*.tmp_proj
64-
*.log
65-
*.vspscc
66-
*.vssscc
67-
.builds
68-
*.pidb
69-
*.svclog
70-
*.scc
71-
72-
# Chutzpah Test files
73-
_Chutzpah*
74-
75-
# Visual C++ cache files
76-
ipch/
77-
*.aps
78-
*.ncb
79-
*.opendb
80-
*.opensdf
81-
*.sdf
82-
*.cachefile
83-
*.VC.db
84-
*.VC.VC.opendb
85-
86-
# Visual Studio profiler
87-
*.psess
88-
*.vsp
89-
*.vspx
90-
*.sap
91-
92-
# TFS 2012 Local Workspace
93-
$tf/
94-
95-
# Guidance Automation Toolkit
96-
*.gpState
97-
98-
# ReSharper is a .NET coding add-in
99-
_ReSharper*/
100-
*.[Rr]e[Ss]harper
101-
*.DotSettings.user
102-
103-
# JustCode is a .NET coding add-in
104-
.JustCode
105-
106-
# TeamCity is a build add-in
107-
_TeamCity*
108-
109-
# DotCover is a Code Coverage Tool
110-
*.dotCover
111-
112-
# NCrunch
113-
_NCrunch_*
114-
.*crunch*.local.xml
115-
nCrunchTemp_*
116-
117-
# MightyMoose
118-
*.mm.*
119-
AutoTest.Net/
120-
121-
# Web workbench (sass)
122-
.sass-cache/
123-
124-
# Installshield output folder
125-
[Ee]xpress/
126-
127-
# DocProject is a documentation generator add-in
128-
DocProject/buildhelp/
129-
DocProject/Help/*.HxT
130-
DocProject/Help/*.HxC
131-
DocProject/Help/*.hhc
132-
DocProject/Help/*.hhk
133-
DocProject/Help/*.hhp
134-
DocProject/Help/Html2
135-
DocProject/Help/html
136-
137-
# Click-Once directory
138-
publish/
139-
140-
# Publish Web Output
141-
*.[Pp]ublish.xml
142-
*.azurePubxml
143-
# TODO: Comment the next line if you want to checkin your web deploy settings
144-
# but database connection strings (with potential passwords) will be unencrypted
145-
*.pubxml
146-
*.publishproj
147-
148-
# Microsoft Azure Web App publish settings. Comment the next line if you want to
149-
# checkin your Azure Web App publish settings, but sensitive information contained
150-
# in these scripts will be unencrypted
151-
PublishScripts/
152-
153-
# NuGet Packages
154-
*.nupkg
155-
# The packages folder can be ignored because of Package Restore
156-
**/packages/*
157-
# except build/, which is used as an MSBuild target.
158-
!**/packages/build/
159-
# Uncomment if necessary however generally it will be regenerated when needed
160-
#!**/packages/repositories.config
161-
# NuGet v3's project.json files produces more ignoreable files
162-
*.nuget.props
163-
*.nuget.targets
164-
165-
# Microsoft Azure Build Output
166-
csx/
167-
*.build.csdef
168-
169-
# Microsoft Azure Emulator
170-
ecf/
171-
rcf/
172-
173-
# Windows Store app package directories and files
174-
AppPackages/
175-
BundleArtifacts/
176-
Package.StoreAssociation.xml
177-
_pkginfo.txt
178-
179-
# Visual Studio cache files
180-
# files ending in .cache can be ignored
181-
*.[Cc]ache
182-
# but keep track of directories ending in .cache
183-
!*.[Cc]ache/
184-
185-
# Others
186-
ClientBin/
187-
~$*
188-
*~
189-
*.dbmdl
190-
*.dbproj.schemaview
191-
*.pfx
192-
*.publishsettings
193-
node_modules/
194-
orleans.codegen.cs
195-
196-
# Since there are multiple workflows, uncomment next line to ignore bower_components
197-
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
198-
#bower_components/
199-
200-
# RIA/Silverlight projects
201-
Generated_Code/
202-
203-
# Backup & report files from converting an old project file
204-
# to a newer Visual Studio version. Backup files are not needed,
205-
# because we have git ;-)
206-
_UpgradeReport_Files/
207-
Backup*/
208-
UpgradeLog*.XML
209-
UpgradeLog*.htm
210-
211-
# SQL Server files
212-
*.mdf
213-
*.ldf
214-
215-
# Business Intelligence projects
216-
*.rdl.data
217-
*.bim.layout
218-
*.bim_*.settings
219-
220-
# Microsoft Fakes
221-
FakesAssemblies/
222-
223-
# GhostDoc plugin setting file
224-
*.GhostDoc.xml
225-
226-
# Node.js Tools for Visual Studio
227-
.ntvs_analysis.dat
228-
229-
# Visual Studio 6 build log
230-
*.plg
231-
232-
# Visual Studio 6 workspace options file
233-
*.opt
234-
235-
# Visual Studio LightSwitch build output
236-
**/*.HTMLClient/GeneratedArtifacts
237-
**/*.DesktopClient/GeneratedArtifacts
238-
**/*.DesktopClient/ModelManifest.xml
239-
**/*.Server/GeneratedArtifacts
240-
**/*.Server/ModelManifest.xml
241-
_Pvt_Extensions
242-
243-
# Paket dependency manager
244-
.paket/paket.exe
245-
paket-files/
246-
247-
# FAKE - F# Make
248-
.fake/
249-
250-
# JetBrains Rider
251-
.idea/
252-
*.sln.iml
1+
node_modules
2+
package-lock.json

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# CHANGELOG
2+
3+
## 2/21/2020
4+
5+
* Source code refactored.
6+
* Ajax calls replaced with Fetch API.
7+
* Corrected HTML structure.
8+
* UI redesigned with Bootstrap 4 framework.
9+
* Corrected README.md.
10+
* Added login with redirect.
11+
* Authentication decoupled from access token request.

CODE_OF_CONDUCT.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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

CONTRIBUTING.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Contributing
2+
3+
This project welcomes contributions and suggestions. Most contributions require you to agree to a
4+
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
5+
the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
6+
7+
When you submit a pull request, a CLA bot will automatically determine whether you need to provide
8+
a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
9+
provided by the bot. You will only need to do this once across all repos using our CLA.
10+
11+
## Instructions
12+
13+
Follow these instructions to download and run the sample locally.
14+
15+
1. Install [Node](https://nodejs.org/).
16+
2. Clone and download this repository.
17+
3. Navigate to the root of this repository, and install the dependencies: `npm install`
18+
4. Start the application: `npm start`

JavaScriptSPA/api.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// helper function to access the resource with the token
2+
function callApiWithAccessToken(endpoint, token) {
3+
const headers = new Headers();
4+
const bearer = `Bearer ${token}`;
5+
6+
headers.append("Authorization", bearer);
7+
8+
const options = {
9+
method: "GET",
10+
headers: headers
11+
};
12+
13+
fetch(endpoint, options)
14+
.then(response => response.json())
15+
.then(response => {
16+
logMessage("Web API returned:\n" + JSON.stringify(response));
17+
}).catch(error => {
18+
logMessage("Error calling the Web api:\n" + error);
19+
});
20+
}

JavaScriptSPA/apiConfig.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// The current application coordinates were pre-registered in a B2C tenant.
2+
const apiConfig = {
3+
b2cScopes: ["https://fabrikamb2c.onmicrosoft.com/helloapi/demo.read"],
4+
webApi: "https://fabrikamb2chello.azurewebsites.net/hello"
5+
};

JavaScriptSPA/authConfig.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
// Config object to be passed to Msal on creation.
3+
// For a full list of msal.js configuration parameters,
4+
// visit https://azuread.github.io/microsoft-authentication-library-for-js/docs/msal/modules/_configuration_.html
5+
const msalConfig = {
6+
auth: {
7+
clientId: "e760cab2-b9a1-4c0d-86fb-ff7084abd902",
8+
authority: "https://fabrikamb2c.b2clogin.com/fabrikamb2c.onmicrosoft.com/b2c_1_susi",
9+
validateAuthority: false
10+
},
11+
cache: {
12+
cacheLocation: "localStorage", // This configures where your cache will be stored
13+
storeAuthStateInCookie: false // Set this to "true" to save cache in cookies to address trusted zones limitations in IE (see: https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/Known-issues-on-IE-and-Edge-Browser)
14+
}
15+
};
16+
17+
// Add here scopes for id token to be used at the MS Identity Platform endpoint
18+
// For a full list of available authentication parameters,
19+
// visit https://azuread.github.io/microsoft-authentication-library-for-js/docs/msal/modules/_authenticationparameters_.html
20+
const loginRequest = {
21+
scopes: ["openid", "profile"],
22+
};
23+
24+
// Add here scopes for access token to be used at the API endpoints.
25+
const tokenRequest = {
26+
scopes: apiConfig.b2cScopes, // e.g. ["https://fabrikamb2c.onmicrosoft.com/helloapi/demo.read"]
27+
};

0 commit comments

Comments
 (0)