Skip to content

Commit

Permalink
Merge branch 'joao/use_auth_js' of github.com:signalwire/call-fabric-…
Browse files Browse the repository at this point in the history
…client-beta into joao/use_auth_js

# Conflicts:
#	env.example
#	index.js
  • Loading branch information
jpsantosbh committed Jan 10, 2024
2 parents 5041bc0 + 4ba9eb9 commit e63e7bd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions env.example
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ FIREBASE_MEASUREMENT_ID=<foo>
FIREBASE_VAPID_KEY=<foo>

#OAUTH Settings
AUTH_SECRET=<foo> # See https://authjs.dev/reference/core/errors/#missingsecret
OAUTH_CLIENT_ID=<foo>
OAUTH_SECRET=<foo>
OAUTH_TOKEN_URI=https://id.fabric.swire.io/oauth/token
OAUTH_AUTH_URI=https://id.fabric.swire.io/login/oauth/authorize
OAUTH_REDIRECT_URI=https://<foo>.ngrok-free.app/callback
OAUTH_USERINFO_URI=https://fabric.swire.io/subscriber/info

AUTH_SECRET= //use "openssl rand -hex 32" to get one
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ const token_request = {
const host = process.env.RELAY_HOST


const authtentication = async (req, res, next) => {
const authentication = async (req, res, next) => {
const session = res.locals.session ?? (await authGetSession(req, authConfig))

if (!session?.user) {
callbackUrl = process.env.OAUTH_REDIRECT_URI ?? `${process.env.BASE_HOST_URL}/oauth`
res.redirect(`/api/auth/signing?callbackUrl=${callbackUrl`)
res.redirect(`/api/auth/signing?callbackUrl=${callbackUrl}`)
} else {
res.locals['session'] = session
next()
Expand Down Expand Up @@ -150,7 +150,7 @@ app.get('/minimal', async (req, res) => {
});
});

app.get('/oauth', authtentication, (req, res) => {
app.get('/oauth', authentication, (req, res) => {
const { session } = res.locals

res.render('index', {
Expand Down

0 comments on commit e63e7bd

Please sign in to comment.