@@ -69,12 +69,12 @@ function _validateCertificate(req, res, next) {
69
69
70
70
if ( req . headers [ 'x-ssl-client-verify' ] !== '0' ) {
71
71
this . LOG . info ( 'cf did not validate client certificate.' )
72
- return res . status ( 401 ) . json ( { message : 'Authentication Failed ' } )
72
+ return res . status ( 401 ) . json ( { message : 'Unauthorized ' } )
73
73
}
74
74
75
75
if ( ! req . headers [ 'x-forwarded-client-cert' ] ) {
76
76
this . LOG . info ( 'no certificate in xfcc header.' )
77
- return res . status ( 401 ) . json ( { message : 'Authentication Failed ' } )
77
+ return res . status ( 401 ) . json ( { message : 'Unauthorized ' } )
78
78
}
79
79
80
80
const clientCertObj = new crypto . X509Certificate (
@@ -83,33 +83,33 @@ function _validateCertificate(req, res, next) {
83
83
const clientCert = clientCertObj . toLegacyObject ( )
84
84
85
85
if ( ! this . isMultitenancy && ! clientCertObj . checkPrivateKey ( this . auth . privateKey ) )
86
- return res . status ( 401 ) . josn ( { message : 'Authentication Failed ' } )
86
+ return res . status ( 401 ) . json ( { message : 'Unauthorized ' } )
87
87
88
88
const cfSubject = Buffer . from ( req . headers [ 'x-ssl-client-subject-cn' ] , 'base64' ) . toString ( )
89
89
if (
90
90
this . auth . validationCert . subject . CN !== clientCert . subject . CN ||
91
91
this . auth . validationCert . subject . CN !== cfSubject
92
92
) {
93
93
this . LOG . info ( 'certificate subject does not match' )
94
- return res . status ( 401 ) . json ( { message : 'Authentication Failed ' } )
94
+ return res . status ( 401 ) . json ( { message : 'Unauthorized ' } )
95
95
}
96
96
this . LOG . debug ( 'incoming Subject CN is valid.' )
97
97
98
98
if ( this . auth . validationCert . issuer . CN !== clientCert . issuer . CN ) {
99
99
this . LOG . info ( 'Certificate issuer subject does not match' )
100
- return res . status ( 401 ) . json ( { message : 'Authentication Failed ' } )
100
+ return res . status ( 401 ) . json ( { message : 'Unauthorized ' } )
101
101
}
102
102
this . LOG . debug ( 'incoming issuer subject CN is valid.' )
103
103
104
104
if ( this . auth . validationCert . issuer . O !== clientCert . issuer . O ) {
105
105
this . LOG . info ( 'Certificate issuer org does not match' )
106
- return res . status ( 401 ) . json ( { message : 'Authentication Failed ' } )
106
+ return res . status ( 401 ) . json ( { message : 'Unauthorized ' } )
107
107
}
108
108
this . LOG . debug ( 'incoming Issuer Org is valid.' )
109
109
110
110
if ( this . auth . validationCert . issuer . OU !== clientCert . issuer . OU ) {
111
111
this . LOG . info ( 'certificate issuer OU does not match' )
112
- return res . status ( 401 ) . json ( { message : 'Authentication Failed ' } )
112
+ return res . status ( 401 ) . json ( { message : 'Unauthorized ' } )
113
113
}
114
114
this . LOG . debug ( 'certificate issuer OU is valid.' )
115
115
@@ -121,7 +121,7 @@ function _validateCertificate(req, res, next) {
121
121
next ( )
122
122
} else {
123
123
this . LOG . error ( 'Certificate expired' )
124
- return res . status ( 401 ) . json ( { message : 'Authentication Failed ' } )
124
+ return res . status ( 401 ) . json ( { message : 'Unauthorized ' } )
125
125
}
126
126
}
127
127
@@ -291,7 +291,7 @@ class EventBroker extends cds.MessagingService {
291
291
cds . app . use ( webhookBasePath , cds . middlewares . context ( ) )
292
292
cds . app . use ( webhookBasePath , ias_auth ( this . auth . ias ) )
293
293
cds . app . use ( webhookBasePath , ( err , _req , res , next ) => {
294
- if ( err . code = == 401 ) return res . status ( 401 ) . json ( { message : 'Unauthorized' } )
294
+ if ( err == 401 || err . code == 401 ) return res . status ( 401 ) . json ( { message : 'Unauthorized' } )
295
295
return next ( err )
296
296
} )
297
297
cds . app . use ( webhookBasePath , ( _req , res , next ) => {
0 commit comments