Skip to content

Commit

Permalink
Merge pull request #102 from Arquisoft/solid_upgrade
Browse files Browse the repository at this point in the history
Updated solid login and logout flow with SessionProvider. Now tracks
  • Loading branch information
rosagarlo authored Apr 3, 2022
2 parents 622f9bf + b2ac719 commit bc770fd
Show file tree
Hide file tree
Showing 16 changed files with 1,147 additions and 92 deletions.
3 changes: 3 additions & 0 deletions restapi/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ ENV RESTAPI_DB_PASSWORD=$DB_PASSWORD
ARG PORT="5000"
ENV RESTAPI_PORT=$PORT

ARG URI
ENV WEBAPP_URI=$URI

CMD [ "npm", "start" ]
12 changes: 6 additions & 6 deletions restapi/solid/solidFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import {getSessionFromStorage, Session} from "@inrupt/solid-client-authn-node";
import IContactData from "../interfaces/ContactDataInterface";

// Parametros para el logeo
const redirectUrl: string = process.env.REACT_API_URI + "/solid/redirect-from-solid-idp" // Esto se cambiara por otra pagina como por ejemplo /home.
const redirectUrl: string = process.env.WEBAPP_URI + "/solid/redirect-from-solid-idp"
const oidcIssuer: string = "https://solidcommunity.net/" // Name of the pod provider.
const clientName: string = "DeDe" // Name of the app.
const errorRedirect: string = "http://localhost:3000"
const errorRedirect: string = process.env.WEBAPP_URI + ""

export let solidLogin = async (req: Request, res: Response) => {
let session = new Session()
Expand All @@ -37,9 +37,9 @@ export let solidLogin = async (req: Request, res: Response) => {
export let redirectFromSolidIdp = async (req: Request, res: Response) => {
const session = await getSessionFromStorage(req.session.id);
if(session){
await session.handleIncomingRedirect(process.env.REACT_API_URI + "/solid${req.url}");
await session.handleIncomingRedirect(process.env.WEBAPP_URI + "/solid" + req.url);
if(session.info.isLoggedIn)
return res.redirect("http://localhost:3000/solid/login/"+ Buffer.from(`${session.info.webId}`).toString("base64") + "/" + session.info.sessionId)
return res.redirect(process.env.WEBAPP_URI + "/solid/login/"+ Buffer.from(`${session.info.webId}`).toString("base64") + "/" + session.info.sessionId)

} else {
res.redirect(errorRedirect)
Expand All @@ -58,10 +58,10 @@ export let solidLogout = async (req: Request, res: Response) => {
if(session) {
session.logout()
.then(() => {
res.redirect("http://localhost:3000/solid/logout")
res.redirect(process.env.WEBAPP_URI + "/solid/logout")
})
} else {
res.redirect("http://localhost:3000/solid/logout")
res.redirect(process.env.WEBAPP_URI + "/solid/logout")
}
}

Expand Down
Loading

0 comments on commit bc770fd

Please sign in to comment.