- 
                Notifications
    You must be signed in to change notification settings 
- Fork 93
Add a GitHub OAuth sample for Socket.IO #624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| ## Prerequisites | ||
|  | ||
| 1. [Node.js](https://nodejs.org) | ||
| 2. Create an Web PubSub For Socket.IO resource | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 2. Create an Web PubSub For Socket.IO resource | |
| 2. Create an Web PubSub For Socket.IO resource | 
| Linux: | ||
|  | ||
| ```bash | ||
| export WebPubSubConnectionString="<connection_string>" | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about using dotenv package for env reading?
| @@ -0,0 +1,44 @@ | |||
| # Create a chat app with Web PubSub for Socket.IO And GitHub OAuth | |||
|  | |||
| ## Prerequisites | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this chat app with GitHub OAuth referencing any tutorial? Do you want to mention what are the lines updated specifically for Web PubSub?
Removed pull_request_target trigger for workflows.
| const app = express(); | ||
| const server = require("http").createServer(app); | ||
| const store = new session.MemoryStore(); | ||
| const sessionMiddleware = session({ store: store, secret: "changeit", resave: false, saveUninitialized: false }); | 
Check warning
Code scanning / CodeQL
Clear text transmission of sensitive cookie Medium
          
            
              
                
              
            
            Show autofix suggestion
            Hide autofix suggestion
          
      Copilot Autofix
AI about 2 months ago
To correct the issue, set the cookie.secure property to true in the session middleware options. This enforces that the session cookie will only be sent over HTTPS, protecting it from being intercepted in cleartext. The safest fix is to add a cookie object to the session config (if it’s not already present) and set secure: true within it.
However, for development environments running over plain HTTP, using cookie.secure: true can break authentication because cookies will only be sent over HTTPS. A common pattern is to set cookie.secure conditionally: using true in production, and false during development. But since the CodeQL issue is about cleartext transmission and best-practice code, and unless we've been shown an explicit dev/prod check in the provided code region, defaulting to true is the secure choice for this fix.
Therefore, update the options passed to session() on line 12 of sdk/webpubsub-socketio-extension/examples/chat-with-auth-github/index.js by adding cookie: { secure: true }.
No additional imports or methods are required.
- 
    
    
    Copy modified line R12 
| @@ -9,7 +9,7 @@ | ||
| const app = express(); | ||
| const server = require("http").createServer(app); | ||
| const store = new session.MemoryStore(); | ||
| const sessionMiddleware = session({ store: store, secret: "changeit", resave: false, saveUninitialized: false }); | ||
| const sessionMiddleware = session({ store: store, secret: "changeit", resave: false, saveUninitialized: false, cookie: { secure: true } }); | ||
|  | ||
| app.use(sessionMiddleware); | ||
| app.use(bodyParser.urlencoded({ extended: false })); | 
| document.querySelector('.usernameInput').value = names[idx]; | ||
| </script> | ||
| --> | ||
| <script src="https://code.jquery.com/jquery-1.10.2.min.js"></script> | 
Check warning
Code scanning / CodeQL
Inclusion of functionality from an untrusted source Medium
No description provided.