express-sessions | ExpressJS MongoDB/Redis Session Storage | Runtime Evironment library

 by   konteck JavaScript Version: Current License: No License

kandi X-RAY | express-sessions Summary

kandi X-RAY | express-sessions Summary

express-sessions is a JavaScript library typically used in Server, Runtime Evironment, Angular, Nodejs, MongoDB, Express.js applications. express-sessions has no bugs, it has no vulnerabilities and it has low support. You can install using 'npm i express-sessions' or download it from GitHub, npm.

ExpressJS MongoDB/Redis Session Storage
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              express-sessions has a low active ecosystem.
              It has 29 star(s) with 15 fork(s). There are 3 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              There are 5 open issues and 0 have been closed. There are 2 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of express-sessions is current.

            kandi-Quality Quality

              express-sessions has no bugs reported.

            kandi-Security Security

              express-sessions has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.

            kandi-License License

              express-sessions does not have a standard license declared.
              Check the repository for any license declaration and review the terms closely.
              OutlinedDot
              Without a license, all rights are reserved, and you cannot use the library in your applications.

            kandi-Reuse Reuse

              express-sessions releases are not available. You will need to build from source code and install.
              Deployable package is available in npm.
              Installation instructions are not available. Examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of express-sessions
            Get all kandi verified functions for this library.

            express-sessions Key Features

            No Key Features are available at this moment for express-sessions.

            express-sessions Examples and Code Snippets

            No Code Snippets are available at this moment for express-sessions.

            Community Discussions

            QUESTION

            How to get cookie in Vue Router in Vue 3? this undefined in router/index.js
            Asked 2021-Jun-02 at 05:16

            Use case: Vue3 app using express as API backend. Express uses express-sessions to establish a server-side session which is sent to the browser and received in every subsequent request.

            I'm trying to create a route guard to prevent access to certain routes if the session cookie doesn't exist.

            ...

            ANSWER

            Answered 2021-Jun-02 at 05:16

            Vue Router 4 removes router.app, but you could add it yourself when setting up the router:

            Source https://stackoverflow.com/questions/67790324

            QUESTION

            How to authentication React Front End with back-end Node.js Express-Sessions?
            Asked 2021-May-20 at 02:50

            I'm moving away from using firestore auth to understand how to make my own authentication system.

            My goal:

            1. Create a react web app that lets user sign up and sign in .
            2. Authenticated users can operate on restAPI, which is NodeJS hooked up to Postgres.

            I've watched a lot of tutorials. Most of them talk about express-sessions as as solution. However, when i tried it - these session cookie are only provided when my browser is on the express uri.

            The issue is... On the front-end, when I send CRUD operation via fetch to my express api, my react-app do not get that cookie.

            is what I'm doing the conventional way to handle authentication with backend server? How can i fix this?

            EXPRESS:

            ...

            ANSWER

            Answered 2021-May-20 at 02:50
            1. In Server
            • Please enable cors(install cors library).

            Source https://stackoverflow.com/questions/67613185

            QUESTION

            My express-session is getting overwritten every time I send a new request, and I'm wondering if it is because of my dev environment? REACT + EXPRESS
            Asked 2021-Apr-09 at 00:38

            EDIT - I no longer think it is a development environment issue as the same thing persists in production.

            First off, appreciate anytime spent on this - I know that this is a commonly asked question, but I've perused so many questions and tried applying so many of the solutions to no avail.

            To summarize, I currently have a React Front-end that is sending request with the Fetch API to my Express server. I want to use express-sessions to save my logged in user information for the session to use and authenticate as the user uses the application.

            I'm having this weird issue where every time a new request is sent, the cookie in my browser in the application tab gets set to something completely new. I might be understanding this wrong, but I thought that that was supposed to remain consistent throughout the session, but it doesn't seem to be the case. This is making it so that every time I call a new request, req.session is completely reset with nothing.

            Here is some code from my application:

            Express- server.js [my setup for express-session and cors]

            ...

            ANSWER

            Answered 2021-Apr-09 at 00:38

            If you're running the backend and frontend on different hosts, there could be a CORS problem. Also you said that you checked the cookie in the application tab, but if you haven't tried looking at the request and response cookie headers in the network tab, you should check those out to further diagnose the problem. The cookie should be set on the authentication request, and it should be included in the requests following that.

            Source https://stackoverflow.com/questions/67011113

            QUESTION

            Redis(Memorystore) clearing out keys
            Asked 2021-Apr-06 at 02:18

            I am using express-sessions and Redis(Memorystore) 5.0 to save sessions and it appears Redis is clearing out all the keys(randomly and not at intervals) way before the TTL on a key runs out. Leaving only a couple of backup entries

            This entry should be valid for another week judging from the TTL.

            I have never configured a Redis instance before and it is likely I misconfigured this one, some insight would be appreciated.

            Also, this is what I get when I run monitor

            ...

            ANSWER

            Answered 2021-Apr-06 at 02:18

            Avoid exposing your Memorystore instance through the external IP of your Compute Engine. Combined with the fact that Memorystore instances currently requires no authentication, this will lead to a vulnerability that will allow anyone to read, write and execute scripts on your instance. On the worst case scenario, it will allow someone to mine cryptocurrency using your instance, hence causing a suspension on your project or account unfortunately.

            There are multiple guides online to connect to Memorystore remotely. I suggest connecting through SSH by following this thread: Accessing GCP Memorystore from local machines

            For reference, I will paste the answer here (credits to the person who posted it):

            "If your Redis machine has internal IP address 10.0.0.3 you'd do:

            Source https://stackoverflow.com/questions/66911909

            QUESTION

            Where to store user info after being logged in: React JS
            Asked 2021-Jan-11 at 23:06

            I am using express-sessions, cookies, and React, to build a login system. Currently, once the user is logged in, they are allowed to make requests to certain routes, but if they're not, they're not allowed to.

            However, my question is where I should store the user's username. Would storing it in localstorage cause security issues? Or is that a safe way to store something like a username?

            The reason I'm not storing it in a cookie is because the cookie is httpOnly. Is this a good idea? All I'm storing in the cookie will be the user's username, so I'm not sure if I'm overdoing security, and I can just access the user's username from my frontend by having the cookie not being httpOnly.

            Thanks!

            ...

            ANSWER

            Answered 2021-Jan-11 at 23:06

            If you are also using passport.js, once the login is successful, you can make the backend send the response containing related user info. (but not sensitive information such as passwords)

            I see no problem with storing usernames in cookies. It is displayed in the end anyway.

            In terms of security, there is always a trade-off.

            So, in the end, it depends on what is acceptable and safe for you.

            Source https://stackoverflow.com/questions/65605529

            QUESTION

            Passport.js, Sessions, & React | Accessing req.user from any route other than the /login route is undefined
            Asked 2020-Aug-08 at 11:01

            I have a React client setup at localhost:3000 and a node.js server at localhost:5000

            I'm trying a simple auth flow in which the client tries to authenticate with the server using Passport.js Google OAuth2.0 and staying authenticated using express-sessions with a MongoDB store.

            I believe the reason I'm finding req.user is undefined is because of my lack of understanding of how the auth flow is supposed to work versus any issues with the actual code.

            I'm initiating the auth flow through the following code in the react client:

            ...

            ANSWER

            Answered 2020-Aug-08 at 11:01

            Finally got it to work.

            I had to edit two things,

            First (Server Side):

            I had to setup CORS to allow cookies to pass through as such:

            Source https://stackoverflow.com/questions/63152640

            QUESTION

            Express Session Cookie Not Being Set when using React Axios POST Request
            Asked 2020-Aug-04 at 17:48

            The Setup

            I have setup a frontend environment using create-react-app. In this environment I use Axios to make a POST request to my Node JS Express Backend Server /login endpoint. I setup sessions middleware using express-sessions and storing the sessions in Redis. I have all this running in localhost currently.

            Environment

            • React App - http://localhost:3005/kp (Note: the service runs on http://localhost:3005 however, all the routes have /kp in them)

            • Express Backend - http://localhost:5001

            • Redis - http://localhost:6379

            What Works

            When the frontend sends the request to the backend the Express server does it's thing and authenticates the user; it stores the username in the req.session.username (this is just as a test), Redis console shows that the key value store was successful, the frontend network tab shows a 200 status with a Set-Cookie response header and a tab that shows the cookie (screenshots below).

            The Problem

            Everything seems to be working fine but the cookie is not set in the Browser. I have refreshed the page, tried again many times and yet it will not set the cookie in any browser (Google Chrome & Safari). I am getting frustrated because it seems as though Chrome acknowledges that the Set-Cookie is present but ignores it for some reason.

            What I've Tried

            Axios

            1. I have tried setting withCredentials: true - Does not work
            2. Verified the cookie with Set-Cookie is being sent back to the frontend after the POST request

            Backend

            1. I have checked my CORS policies to but they seem fine; however, I am not great with CORS so there could be misconfiguration there
            2. Tried setting credentials to true in CORS policy
            3. Verified the session with variables are being set with Redis.

            Code

            React Frontend Axios POST Request

            ...

            ANSWER

            Answered 2020-Aug-04 at 17:15

            Are you sure, you are setting axios options correctly ?

            You have :

            Source https://stackoverflow.com/questions/63251837

            QUESTION

            req.session returns undefined in the next POST request after is defined
            Asked 2020-Jul-16 at 08:04

            I'm working with a back-end made with Node.js and front-end made with Angular. I use express-sessions for login, at first, it returns the correct req.session.usuario. But in the next POST request for checking if the user is logged in it returns undefined.

            Here is the app.js of node

            ...

            ANSWER

            Answered 2020-Jul-16 at 00:44

            I finally got the answer! I was doing everything ok but the second request was actually not including the withCredentials json as options, it was passed as body so I added empty brackets to simulate the body and now it works like a charm!

            Source https://stackoverflow.com/questions/62925372

            QUESTION

            Getting a Cast to ObjectId error when trying to refrence users when creating post (express -sessions, mongoose)
            Asked 2020-Mar-20 at 02:41

            When user logs into the application, I am using express-sessions to verify them, I attach a user_id to the sessions object , this I will use when I am creating a post, to refrence the user who created that post, eventually I want to have all those post a user created , inside a collection, such that I can easily show it on users dashboard.

            You can recreate the bug by my github: https://github.com/fullstackaccount/auth_cookies-Session, use the postman information to : create user,login, then try to submit post. postman Docs: https://documenter.getpostman.com/view/8427997/SWEB1amP?version=latest

            I am attempting to use this solution to create this refrence to posts: https://teamtreehouse.com/community/how-to-assign-a-user-a-post-with-mongoose-and-express

            THANK YOU FOR YOUR TIME!

            This is the login:

            ...

            ANSWER

            Answered 2019-Dec-17 at 17:31

            I believe the issue has to do with pushing the post onto the User model. What you have is user.posts.push(newPost);, which is the whole post object, but the user model defines posts as:

            Source https://stackoverflow.com/questions/59373896

            QUESTION

            Unable to get collection user as a JSON object (getuser())
            Asked 2019-Aug-02 at 16:56

            getUser() doesnt exist in MongoDB Node.js Native Driver .

            See this : https://mongodb.github.io/node-mongodb-native/api-generated/

            or

            db.getUser in node.js mongodb

            I'm using mongoDb shell v4.0.10 . And this is a part of my package.json :

            ...

            ANSWER

            Answered 2019-Aug-02 at 16:56

            --------------------SOLVED-----------------

            Thanks to this post : MongoDb: db.getUser() in PHP

            I can get my user data with this code now (please notice, usersInfo() exists , but getUser() doesnt exist. :

            Source https://stackoverflow.com/questions/57329571

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install express-sessions

            You can install using 'npm i express-sessions' or download it from GitHub, npm.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/konteck/express-sessions.git

          • CLI

            gh repo clone konteck/express-sessions

          • sshUrl

            git@github.com:konteck/express-sessions.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link