aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/lib/peertube-socket.ts2
-rw-r--r--server/middlewares/oauth.ts3
-rw-r--r--server/typings/express/index.d.ts126
3 files changed, 66 insertions, 65 deletions
diff --git a/server/lib/peertube-socket.ts b/server/lib/peertube-socket.ts
index e27963e60..c91407a59 100644
--- a/server/lib/peertube-socket.ts
+++ b/server/lib/peertube-socket.ts
@@ -22,7 +22,7 @@ class PeerTubeSocket {
22 io.of('/user-notifications') 22 io.of('/user-notifications')
23 .use(authenticateSocket) 23 .use(authenticateSocket)
24 .on('connection', socket => { 24 .on('connection', socket => {
25 const userId = socket.handshake.query.user.id 25 const userId = socket.handshake.auth.user.id
26 26
27 logger.debug('User %d connected on the notification system.', userId) 27 logger.debug('User %d connected on the notification system.', userId)
28 28
diff --git a/server/middlewares/oauth.ts b/server/middlewares/oauth.ts
index 47799153a..280595acc 100644
--- a/server/middlewares/oauth.ts
+++ b/server/middlewares/oauth.ts
@@ -32,6 +32,7 @@ function authenticateSocket (socket: Socket, next: (err?: any) => void) {
32 logger.debug('Checking socket access token %s.', accessToken) 32 logger.debug('Checking socket access token %s.', accessToken)
33 33
34 if (!accessToken) return next(new Error('No access token provided')) 34 if (!accessToken) return next(new Error('No access token provided'))
35 if (typeof accessToken !== 'string') return next(new Error('Access token is invalid'))
35 36
36 getAccessToken(accessToken) 37 getAccessToken(accessToken)
37 .then(tokenDB => { 38 .then(tokenDB => {
@@ -41,7 +42,7 @@ function authenticateSocket (socket: Socket, next: (err?: any) => void) {
41 return next(new Error('Invalid access token.')) 42 return next(new Error('Invalid access token.'))
42 } 43 }
43 44
44 socket.handshake.query['user'] = tokenDB.User 45 socket.handshake.auth.user = tokenDB.User
45 46
46 return next() 47 return next()
47 }) 48 })
diff --git a/server/typings/express/index.d.ts b/server/typings/express/index.d.ts
index a83619a0e..66acfb3f5 100644
--- a/server/typings/express/index.d.ts
+++ b/server/typings/express/index.d.ts
@@ -8,9 +8,9 @@ import {
8 MVideoChangeOwnershipFull, 8 MVideoChangeOwnershipFull,
9 MVideoFile, 9 MVideoFile,
10 MVideoImmutable, 10 MVideoImmutable,
11 MVideoLive,
11 MVideoPlaylistFull, 12 MVideoPlaylistFull,
12 MVideoPlaylistFullSummary, 13 MVideoPlaylistFullSummary
13 MVideoLive
14} from '@server/types/models' 14} from '@server/types/models'
15import { MOAuthTokenUser } from '@server/types/models/oauth/oauth-token' 15import { MOAuthTokenUser } from '@server/types/models/oauth/oauth-token'
16import { MPlugin, MServer, MServerBlocklist } from '@server/types/models/server' 16import { MPlugin, MServer, MServerBlocklist } from '@server/types/models/server'
@@ -43,97 +43,97 @@ declare module 'express' {
43 export interface Request { 43 export interface Request {
44 query: any 44 query: any
45 } 45 }
46
47 interface Response { 46 interface Response {
47 locals: PeerTubeLocals
48 }
49}
48 50
49 locals: { 51interface PeerTubeLocals {
50 bypassLogin?: { 52 bypassLogin?: {
51 bypass: boolean 53 bypass: boolean
52 pluginName: string 54 pluginName: string
53 authName?: string 55 authName?: string
54 user: { 56 user: {
55 username: string 57 username: string
56 email: string 58 email: string
57 displayName: string 59 displayName: string
58 role: UserRole 60 role: UserRole
59 } 61 }
60 } 62 }
61 63
62 refreshTokenAuthName?: string 64 refreshTokenAuthName?: string
63 65
64 explicitLogout: boolean 66 explicitLogout?: boolean
65 67
66 videoAll?: MVideoFullLight 68 videoAll?: MVideoFullLight
67 onlyImmutableVideo?: MVideoImmutable 69 onlyImmutableVideo?: MVideoImmutable
68 onlyVideo?: MVideoThumbnail 70 onlyVideo?: MVideoThumbnail
69 onlyVideoWithRights?: MVideoWithRights 71 onlyVideoWithRights?: MVideoWithRights
70 videoId?: MVideoIdThumbnail 72 videoId?: MVideoIdThumbnail
71 73
72 videoLive?: MVideoLive 74 videoLive?: MVideoLive
73 75
74 videoShare?: MVideoShareActor 76 videoShare?: MVideoShareActor
75 77
76 videoFile?: MVideoFile 78 videoFile?: MVideoFile
77 79
78 videoImport?: MVideoImportDefault 80 videoImport?: MVideoImportDefault
79 81
80 videoBlacklist?: MVideoBlacklist 82 videoBlacklist?: MVideoBlacklist
81 83
82 videoCaption?: MVideoCaptionVideo 84 videoCaption?: MVideoCaptionVideo
83 85
84 abuse?: MAbuseReporter 86 abuse?: MAbuseReporter
85 abuseMessage?: MAbuseMessage 87 abuseMessage?: MAbuseMessage
86 88
87 videoStreamingPlaylist?: MStreamingPlaylist 89 videoStreamingPlaylist?: MStreamingPlaylist
88 90
89 videoChannel?: MChannelAccountDefault 91 videoChannel?: MChannelAccountDefault
90 92
91 videoPlaylistFull?: MVideoPlaylistFull 93 videoPlaylistFull?: MVideoPlaylistFull
92 videoPlaylistSummary?: MVideoPlaylistFullSummary 94 videoPlaylistSummary?: MVideoPlaylistFullSummary
93 95
94 videoPlaylistElement?: MVideoPlaylistElement 96 videoPlaylistElement?: MVideoPlaylistElement
95 videoPlaylistElementAP?: MVideoPlaylistElementVideoUrlPlaylistPrivacy 97 videoPlaylistElementAP?: MVideoPlaylistElementVideoUrlPlaylistPrivacy
96 98
97 accountVideoRate?: MAccountVideoRateAccountVideo 99 accountVideoRate?: MAccountVideoRateAccountVideo
98 100
99 videoCommentFull?: MCommentOwnerVideoReply 101 videoCommentFull?: MCommentOwnerVideoReply
100 videoCommentThread?: MComment 102 videoCommentThread?: MComment
101 103
102 follow?: MActorFollowActorsDefault 104 follow?: MActorFollowActorsDefault
103 subscription?: MActorFollowActorsDefaultSubscription 105 subscription?: MActorFollowActorsDefaultSubscription
104 106
105 nextOwner?: MAccountDefault 107 nextOwner?: MAccountDefault
106 videoChangeOwnership?: MVideoChangeOwnershipFull 108 videoChangeOwnership?: MVideoChangeOwnershipFull
107 109
108 account?: MAccountDefault 110 account?: MAccountDefault
109 111
110 actorUrl?: MActorUrl 112 actorUrl?: MActorUrl
111 actorFull?: MActorFull 113 actorFull?: MActorFull
112 114
113 user?: MUserDefault 115 user?: MUserDefault
114 116
115 server?: MServer 117 server?: MServer
116 118
117 videoRedundancy?: MVideoRedundancyVideo 119 videoRedundancy?: MVideoRedundancyVideo
118 120
119 accountBlock?: MAccountBlocklist 121 accountBlock?: MAccountBlocklist
120 serverBlock?: MServerBlocklist 122 serverBlock?: MServerBlocklist
121 123
122 oauth?: { 124 oauth?: {
123 token: MOAuthTokenUser 125 token: MOAuthTokenUser
124 } 126 }
125 127
126 signature?: { 128 signature?: {
127 actor: MActorAccountChannelId 129 actor: MActorAccountChannelId
128 } 130 }
129 131
130 authenticated?: boolean 132 authenticated?: boolean
131 133
132 registeredPlugin?: RegisteredPlugin 134 registeredPlugin?: RegisteredPlugin
133 135
134 externalAuth?: RegisterServerAuthExternalOptions 136 externalAuth?: RegisterServerAuthExternalOptions
135 137
136 plugin?: MPlugin 138 plugin?: MPlugin
137 }
138 }
139} 139}