File tree 3 files changed +20
-3
lines changed
packages/npm/@amazeelabs/publisher
3 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,22 @@ export default defineConfig({
12
12
username : 'test' ,
13
13
password : 'test' ,
14
14
} ,
15
+ // When several authentication methods are configured,
16
+ // oAuth2 takes precedence.
17
+ oAuth2 : {
18
+ clientId : process . env . OAUTH2_CLIENT_ID || 'publisher' ,
19
+ clientSecret : process . env . OAUTH2_CLIENT_SECRET || 'publisher' ,
20
+ // Applies for ResourceOwnerPassword only.
21
+ scope : process . env . OAUTH2_SCOPE || 'publisher' ,
22
+ tokenHost : process . env . OAUTH2_TOKEN_HOST || 'http://127.0.0.1:8888' ,
23
+ tokenPath : process . env . OAUTH2_TOKEN_PATH || '/oauth/token' ,
24
+ authorizePath :
25
+ process . env . OAUTH2_AUTHORIZE_PATH ||
26
+ '/oauth/authorize?response_type=code' ,
27
+ sessionSecret : process . env . OAUTH2_SESSION_SECRET || 'banana' ,
28
+ environmentType : process . env . OAUTH2_ENVIRONMENT_TYPE || 'development' ,
29
+ grantType : 0 , // AuthorizationCode
30
+ } ,
15
31
mode : 'local' ,
16
32
commands : {
17
33
clean :
Original file line number Diff line number Diff line change @@ -137,6 +137,7 @@ const runServer = async (): Promise<HttpTerminator> => {
137
137
ws . on ( 'close' , sub . unsubscribe ) ;
138
138
} ) ;
139
139
140
+ app . use ( '/___status/history' , authMiddleware ) ;
140
141
app . get ( '/___status/history' , async ( req , res ) => {
141
142
const { Build } = await getDatabase ( ) ;
142
143
const result = await Build . findAll ( {
@@ -145,6 +146,7 @@ const runServer = async (): Promise<HttpTerminator> => {
145
146
res . json ( result ) ;
146
147
} ) ;
147
148
149
+ app . use ( '/___status/history' , authMiddleware ) ;
148
150
app . get ( '/___status/history/:id' , async ( req , res ) => {
149
151
const { Build } = await getDatabase ( ) ;
150
152
const result = await Build . findByPk ( req . params . id ) ;
Original file line number Diff line number Diff line change @@ -27,8 +27,7 @@ declare module 'express-session' {
27
27
}
28
28
29
29
// In seconds
30
- export const SESSION_MAX_AGE = 300 ;
31
- export const ACCESS_TOKEN_EXPIRATION_TIME = 300 ;
30
+ export const SESSION_MAX_AGE = 60 * 60 * 12 ;
32
31
33
32
const ENCRYPTION_KEY =
34
33
process . env . ENCRYPTION_KEY || crypto . randomBytes ( 32 ) . toString ( 'hex' ) ;
@@ -319,7 +318,7 @@ export const isAuthenticated = async (req: Request): Promise<boolean> => {
319
318
let result = false ;
320
319
let accessToken = getPersistedAccessToken ( req ) ;
321
320
if ( accessToken ) {
322
- if ( ! accessToken . expired ( ACCESS_TOKEN_EXPIRATION_TIME ) ) {
321
+ if ( ! accessToken . expired ( ) ) {
323
322
result = true ;
324
323
} else {
325
324
try {
You can’t perform that action at this time.
0 commit comments