Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wiki-js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
wiki-js
Commits
5911867b
Unverified
Commit
5911867b
authored
Oct 15, 2021
by
NGPixel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: various OAuth2 fixes
parent
2d4cbb07
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
15 deletions
+28
-15
authentication.js
server/modules/authentication/oauth2/authentication.js
+13
-6
definition.yml
server/modules/authentication/oauth2/definition.yml
+15
-9
No files found.
server/modules/authentication/oauth2/authentication.js
View file @
5911867b
...
...
@@ -3,7 +3,7 @@ const _ = require('lodash')
/* global WIKI */
// ------------------------------------
// OAuth2
Connect
Account
// OAuth2 Account
// ------------------------------------
const
OAuth2Strategy
=
require
(
'passport-oauth2'
).
Strategy
...
...
@@ -17,15 +17,15 @@ module.exports = {
clientSecret
:
conf
.
clientSecret
,
userInfoURL
:
conf
.
userInfoURL
,
callbackURL
:
conf
.
callbackURL
,
passReqToCallback
:
true
,
passReqToCallback
:
true
},
async
(
req
,
accessToken
,
refreshToken
,
profile
,
cb
)
=>
{
try
{
const
user
=
await
WIKI
.
models
.
users
.
processProfile
({
providerKey
:
req
.
params
.
strategy
,
profile
:
{
...
profile
,
id
:
_
.
get
(
profile
,
conf
.
userId
),
displayName
:
_
.
get
(
profile
,
conf
.
displayName
,
'
'
),
id
:
_
.
get
(
profile
,
conf
.
userId
Claim
),
displayName
:
_
.
get
(
profile
,
conf
.
displayName
Claim
,
'???
'
),
email
:
_
.
get
(
profile
,
conf
.
emailClaim
)
}
})
...
...
@@ -36,19 +36,26 @@ module.exports = {
})
client
.
userProfile
=
function
(
accesstoken
,
done
)
{
this
.
_oauth2
.
_useAuthorizationHeaderForGET
=
true
;
this
.
_oauth2
.
_useAuthorizationHeaderForGET
=
true
this
.
_oauth2
.
get
(
conf
.
userInfoURL
,
accesstoken
,
(
err
,
data
)
=>
{
if
(
err
)
{
return
done
(
err
)
}
try
{
data
=
JSON
.
parse
(
data
)
}
catch
(
e
)
{
}
catch
(
e
)
{
return
done
(
e
)
}
done
(
null
,
data
)
})
}
passport
.
use
(
'oauth2'
,
client
)
},
logout
(
conf
)
{
if
(
!
conf
.
logoutURL
)
{
return
'/'
}
else
{
return
conf
.
logoutURL
}
}
}
server/modules/authentication/oauth2/definition.yml
View file @
5911867b
key
:
oauth2
title
:
OAuth2
description
:
OAuth 2.0
protocol
.
title
:
Generic
OAuth2
description
:
OAuth 2.0
is the industry-standard protocol for authorization
.
author
:
requarks.io
logo
:
https://static.requarks.io/logo/oauth2.svg
color
:
blue-grey darken-2
...
...
@@ -33,23 +33,29 @@ props:
title
:
User Info Endpoint URL
hint
:
User Info Endpoint URL
order
:
5
userId
:
userId
Claim
:
type
:
String
title
:
ID
hint
:
U
ser ID
title
:
ID
Claim
hint
:
Field containing the u
ser ID
default
:
id
maxWidth
:
500
order
:
6
displayName
:
displayName
Claim
:
type
:
String
title
:
Display Name
hint
:
Field containing display name
title
:
Display Name
Claim
hint
:
Field containing
user
display name
default
:
displayName
maxWidth
:
500
order
:
7
emailClaim
:
type
:
String
title
:
Email Claim
hint
:
Field containing the email address
hint
:
Field containing the
user
email address
default
:
email
maxWidth
:
500
order
:
8
logoutURL
:
type
:
String
title
:
Logout URL
hint
:
(optional) Logout URL on the OAuth2 provider where the user will be redirected to complete the logout process.
order
:
9
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment