-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
31b2ac8
commit 53e2ea7
Showing
3 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"bindings": [ | ||
{ | ||
"authLevel": "function", | ||
"type": "httpTrigger", | ||
"direction": "in", | ||
"name": "req", | ||
"methods": [ | ||
"get" | ||
], | ||
"route": ".auth/login/done" | ||
}, | ||
{ | ||
"type": "http", | ||
"direction": "out", | ||
"name": "res" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
const { response } = require("../utils"); | ||
const jwt = require("jsonwebtoken"); | ||
|
||
const jwtKey = "123"; | ||
const jwtExpirySeconds = 300; | ||
|
||
module.exports = async function (context, req) { | ||
const payload = { | ||
...{ | ||
identityprovider: "github", | ||
useridfromprovider: "1699357", | ||
userid: "59cd31faa8c34919ac22c19af50482b8", | ||
userdetails: "manekinekko", | ||
isnewuser: "False", | ||
existingroles: "", | ||
}, | ||
nonce: context.invocationId, | ||
iss: "https://localhost/", | ||
aud: "https://localhost/", | ||
}; | ||
const user_login_jwt = jwt.sign(payload, jwtKey, { | ||
algorithm: "HS256", | ||
expiresIn: jwtExpirySeconds, | ||
}); | ||
|
||
context.res = response({ | ||
context, | ||
status: 200, | ||
cookies: [ | ||
{ | ||
name: "StaticWebAppsAuthContextCookie", | ||
value: "deleted", | ||
path: "/", | ||
expires: new Date("Thu, 01 Jan 1970 00:00:00 GMT"), | ||
domain: "localhost", | ||
} | ||
], | ||
headers: { | ||
"Content-Type": "text/html", | ||
status: 200, | ||
}, | ||
body: ` | ||
<title>Working...</title> | ||
<form id="f" method="POST" action="http://localhost:4242/app/.auth/complete"> | ||
<input type="hidden" name="user_login_jwt" value="${user_login_jwt}" /> | ||
<noscript> | ||
<p>Script is disabled.Click Submit to continue.</p> | ||
<input type="submit" value="Submit" /> | ||
</noscript> | ||
</form> | ||
<script>f.submit();</script>`, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[ | ||
{ | ||
"identityProvider": "github", | ||
"userId": "59cd31faa8c34919ac22c19af50482b8", | ||
"userDetails": "manekinekko", | ||
"userRoles": ["anonymous", "authenticated"] | ||
} | ||
] |