Skip to content

Commit

Permalink
feat: add app .auth/login/{provider} rule
Browse files Browse the repository at this point in the history
  • Loading branch information
manekinekko committed Jun 26, 2020
1 parent 4bb150c commit d6b109f
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
19 changes: 19 additions & 0 deletions app_auth_login_provider/function.json
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": "app/.auth/login/{provider:regex(aad|github|twitter|google|facebook)}"
},
{
"type": "http",
"direction": "out",
"name": "res"
}
]
}
26 changes: 26 additions & 0 deletions app_auth_login_provider/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const { response } = require("../utils");

module.exports = async function (context, req) {
const { provider } = context.bindingData;
const { post_login_redirect_uri } = req.query;

const location = `http://localhost:4242/.redirect/${provider}?hostName=localhost&staticWebAppsAuthNonce=${context.invocationId}`;
context.res = response({
context,
status: 302,
cookies: [
{
name: "StaticWebAppsAuthContextCookie",
value: "KKK",
path: "/",
secure: true,
HttpOnly: true,
domain: "localhost",
SameSite: "None",
},
],
headers: {
location,
},
});
};

0 comments on commit d6b109f

Please sign in to comment.