[njs] Refactored njs_parser_call_expression().
details: https://hg.nginx.org/njs/rev/d1cedbc86bc2 branches: changeset: 867:d1cedbc86bc2 user: hongzhidao date: Wed Apr 03 11:27:05 2019 +0800 description: Refactored njs_parser_call_expression(). diffstat: njs/njs_parser.h|2 + njs/njs_parser_expression.c | 164 ++- 2 files changed, 71 insertions(+), 95 deletions(-) diffs (247 lines): diff -r 42da1521a827 -r d1cedbc86bc2 njs/njs_parser.h --- a/njs/njs_parser.h Wed Apr 03 11:19:14 2019 +0800 +++ b/njs/njs_parser.h Wed Apr 03 11:27:05 2019 +0800 @@ -87,6 +87,8 @@ njs_token_t njs_parser_function_expressi njs_token_t njs_parser_module_lambda(njs_vm_t *vm, njs_parser_t *parser); njs_token_t njs_parser_terminal(njs_vm_t *vm, njs_parser_t *parser, njs_token_t token); +njs_parser_node_t *njs_parser_argument(njs_vm_t *vm, njs_parser_t *parser, +njs_parser_node_t *expr, njs_index_t index); njs_token_t njs_parser_property_token(njs_vm_t *vm, njs_parser_t *parser); nxt_int_t njs_parser_string_create(njs_vm_t *vm, njs_value_t *value); njs_token_t njs_parser_lambda_statements(njs_vm_t *vm, njs_parser_t *parser, diff -r 42da1521a827 -r d1cedbc86bc2 njs/njs_parser_expression.c --- a/njs/njs_parser_expression.c Wed Apr 03 11:19:14 2019 +0800 +++ b/njs/njs_parser_expression.c Wed Apr 03 11:27:05 2019 +0800 @@ -62,6 +62,8 @@ static njs_token_t njs_parser_property_e njs_parser_t *parser, njs_token_t token); static njs_token_t njs_parser_property_brackets(njs_vm_t *vm, njs_parser_t *parser, njs_token_t token); +static njs_token_t njs_parser_call(njs_vm_t *vm, njs_parser_t *parser, +njs_token_t token, uint8_t ctor); static njs_token_t njs_parser_arguments(njs_vm_t *vm, njs_parser_t *parser, njs_parser_node_t *parent); @@ -787,8 +789,6 @@ static njs_token_t njs_parser_call_expression(njs_vm_t *vm, njs_parser_t *parser, njs_token_t token) { -njs_parser_node_t *func, *node; - if (token == NJS_TOKEN_NEW) { token = njs_parser_new_expression(vm, parser, token); @@ -806,66 +806,11 @@ njs_parser_call_expression(njs_vm_t *vm, return token; } -node = parser->node; - if (token != NJS_TOKEN_OPEN_PARENTHESIS) { return token; } -switch (node->token) { - -case NJS_TOKEN_NAME: -func = node; -func->token = NJS_TOKEN_FUNCTION_CALL; -func->scope = parser->scope; - -break; - -case NJS_TOKEN_PROPERTY: -func = njs_parser_node_new(vm, parser, NJS_TOKEN_METHOD_CALL); -if (nxt_slow_path(func == NULL)) { -return NJS_TOKEN_ERROR; -} - -func->left = node; - -break; - -default: -/* - * NJS_TOKEN_METHOD_CALL, - * NJS_TOKEN_FUNCTION_CALL, - * NJS_TOKEN_FUNCTION_EXPRESSION, - * NJS_TOKEN_OPEN_PARENTHESIS, - * NJS_TOKEN_OBJECT_CONSTRUCTOR, - * NJS_TOKEN_ARRAY_CONSTRUCTOR, - * NJS_TOKEN_BOOLEAN_CONSTRUCTOR, - * NJS_TOKEN_NUMBER_CONSTRUCTOR, - * NJS_TOKEN_STRING_CONSTRUCTOR, - * NJS_TOKEN_FUNCTION_CONSTRUCTOR, - * NJS_TOKEN_REGEXP_CONSTRUCTOR, - * NJS_TOKEN_EVAL. - */ -func = njs_parser_node_new(vm, parser, NJS_TOKEN_FUNCTION_CALL); -if (nxt_slow_path(func == NULL)) { -return NJS_TOKEN_ERROR; -} - -func->left = node; - -break; -} - -func->ctor = 0; - -token = njs_parser_arguments(vm, parser, func); -if (nxt_slow_path(token <= NJS_TOKEN_ILLEGAL)) { -return token; -} - -parser->node = func; - -token = njs_parser_token(vm, parser); +token = njs_parser_call(vm, parser, token, 0); if (nxt_slow_path(token <= NJS_TOKEN_ILLEGAL)) { return token; } @@ -874,32 +819,11 @@ njs_parser_call_expression(njs_vm_t *vm, static njs_token_t -njs_parser_new_expression(njs_vm_t *vm, njs_parser_t *parser, -njs_token_t token) +njs_parser_call(njs_vm_t *vm, njs_parser_t *parser, njs_token_t token, +uint8_t ctor) { njs_parser_node_t *func, *node; -token = njs_parser_token(vm, parser); -if (nxt_slow_path(token <= NJS_TOKEN_ILLEGAL)) { -return token; -} - -if (token == NJS_TOKEN_NEW) { -token = njs_parser_new_expression(vm, parser, token); - -} else { -token = njs_parser_terminal(vm, parser, token); -if (nxt_slow_path(token <= NJS_TOKEN_ILLEGAL)) { -return token; -} - -token = njs_parser_property_expression(vm, parser, token); -} - -if (nxt_slow_path(token <= NJS_TOKEN_ILLEGAL)) { -return token; -} - node = parser->node; switch (node->token) { @@ -945,21 +869,54 @@
[njs] Refactored njs_parser_object() and njs_parser_array().
details: https://hg.nginx.org/njs/rev/42da1521a827 branches: changeset: 866:42da1521a827 user: hongzhidao date: Wed Apr 03 11:19:14 2019 +0800 description: Refactored njs_parser_object() and njs_parser_array(). diffstat: njs/njs_parser_terminal.c | 210 ++--- 1 files changed, 102 insertions(+), 108 deletions(-) diffs (316 lines): diff -r bbba5c9fcbf1 -r 42da1521a827 njs/njs_parser_terminal.c --- a/njs/njs_parser_terminal.c Tue Apr 02 19:32:43 2019 +0300 +++ b/njs/njs_parser_terminal.c Wed Apr 03 11:19:14 2019 +0800 @@ -17,8 +17,13 @@ static nxt_int_t njs_parser_builtin(njs_ uint32_t hash); static njs_token_t njs_parser_object(njs_vm_t *vm, njs_parser_t *parser, njs_parser_node_t *obj); +static nxt_int_t njs_parser_object_property(njs_vm_t *vm, njs_parser_t *parser, +njs_parser_node_t *parent, njs_parser_node_t *property, +njs_parser_node_t *value); static njs_token_t njs_parser_array(njs_vm_t *vm, njs_parser_t *parser, -njs_parser_node_t *obj); +njs_parser_node_t *array); +static nxt_int_t njs_parser_array_item(njs_vm_t *vm, njs_parser_t *parser, +njs_parser_node_t *array, njs_parser_node_t *value); static njs_token_t njs_parser_escape_string_create(njs_vm_t *vm, njs_parser_t *parser, njs_value_t *value); @@ -59,17 +64,7 @@ njs_parser_terminal(njs_vm_t *vm, njs_pa return NJS_TOKEN_ERROR; } -parser->node = node; - -token = njs_parser_object(vm, parser, node); - -if (parser->node != node) { -/* The object is not empty. */ -node->left = parser->node; -parser->node = node; -} - -return token; +return njs_parser_object(vm, parser, node); case NJS_TOKEN_OPEN_BRACKET: nxt_thread_log_debug("JS: ARRAY"); @@ -79,17 +74,7 @@ njs_parser_terminal(njs_vm_t *vm, njs_pa return NJS_TOKEN_ERROR; } -parser->node = node; - -token = njs_parser_array(vm, parser, node); - -if (parser->node != node) { -/* The array is not empty. */ -node->left = parser->node; -parser->node = node; -} - -return token; +return njs_parser_array(vm, parser, node); case NJS_TOKEN_DIVISION: node = njs_parser_node_new(vm, parser, NJS_TOKEN_REGEXP); @@ -445,12 +430,12 @@ static njs_token_t njs_parser_object(njs_vm_t *vm, njs_parser_t *parser, njs_parser_node_t *obj) { uint32_t hash, token_line; +nxt_int_t ret; nxt_str_t name; njs_token_ttoken; njs_lexer_t*lexer; -njs_parser_node_t *stmt, *assign, *object, *propref, *left, *expression; +njs_parser_node_t *object, *property, *expression; -left = NULL; lexer = parser->lexer; /* GCC and Clang complain about uninitialized hash. */ @@ -467,13 +452,14 @@ njs_parser_object(njs_vm_t *vm, njs_pars for ( ;; ) { token = njs_parser_property_token(vm, parser); +if (token == NJS_TOKEN_CLOSE_BRACE) { +break; +} + name.start = NULL; switch (token) { -case NJS_TOKEN_CLOSE_BRACE: -return njs_parser_token(vm, parser); - case NJS_TOKEN_NAME: name = *njs_parser_text(parser); @@ -497,13 +483,7 @@ njs_parser_object(njs_vm_t *vm, njs_pars return token; } -propref = njs_parser_node_new(vm, parser, NJS_TOKEN_PROPERTY); -if (nxt_slow_path(propref == NULL)) { -return NJS_TOKEN_ERROR; -} - -propref->left = object; -propref->right = parser->node; +property = parser->node; if (name.start != NULL && (token == NJS_TOKEN_COMMA || token == NJS_TOKEN_CLOSE_BRACE) @@ -530,47 +510,75 @@ njs_parser_object(njs_vm_t *vm, njs_pars expression = parser->node; } -assign = njs_parser_node_new(vm, parser, NJS_TOKEN_ASSIGNMENT); -if (nxt_slow_path(assign == NULL)) { +ret = njs_parser_object_property(vm, parser, obj, property, expression); +if (nxt_slow_path(ret != NXT_OK)) { return NJS_TOKEN_ERROR; } -assign->u.operation = njs_vmcode_move; -assign->left = propref; -assign->right = expression; - -stmt = njs_parser_node_new(vm, parser, NJS_TOKEN_STATEMENT); -if (nxt_slow_path(stmt == NULL)) { -return NJS_TOKEN_ERROR; -} - -stmt->left = left; -stmt->right = assign; - -parser->node = stmt; - -left = stmt; - if (token == NJS_TOKEN_CLOSE_BRACE) { -return njs_parser_token(vm, parser); +break; } if (nxt_slow_path(token != NJS_TOKEN_COMMA)) { return NJS_TOKEN_ILLEGAL; } } + +parser->node = obj; + +return njs_parser_token(vm, parser); +} + + +static
Re: Secondary auth - guidance and configuration help
Totally depends on your setup. Send a pm, we'll think it through! On 03-04-19 16:08, Ramachandra Bhaskar via nginx wrote: ok any rough configuration suggestion using redis ? I havent dirtied yet into lua. Regards Bhaskar On Wednesday, 3 April, 2019, 7:37:10 pm IST, Valery Kholodkov wrote: Yes, it's achievable with scripting/separate fixture. Requires shared storage, like memcached/redis/etc. On 03-04-19 15:37, Ramachandra Bhaskar via nginx wrote: > Hello > > We are having a legacy system(say a.b.c.d) which uses http basic > authentication (username/password) > Currently we are using nginx ingress controller to pass all the requests > coming to webserver(say 1.2.3.4) using kubernetes "auth-url" annotation > to the legacy system and if successful we are forwarding to our > application server.(say w.s.x.c) > > We want to do few things > > we want a consolidated nginx server(/container) which can use do > secondary authentication with legacy system and also cache successful > requests. > is that possible ? We want to reduce number of hits going to legacy > system for authentication thats our end goal -- Valery Kholodkov Coldrift Technologies B.V. http://coldrift.com/ Tel.: +31611223927 ___ nginx mailing list nginx@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx
Re: Secondary auth - guidance and configuration help
ok any rough configuration suggestion using redis ?I havent dirtied yet into lua. RegardsBhaskar On Wednesday, 3 April, 2019, 7:37:10 pm IST, Valery Kholodkov wrote: Yes, it's achievable with scripting/separate fixture. Requires shared storage, like memcached/redis/etc. On 03-04-19 15:37, Ramachandra Bhaskar via nginx wrote: > Hello > > We are having a legacy system(say a.b.c.d) which uses http basic > authentication (username/password) > Currently we are using nginx ingress controller to pass all the requests > coming to webserver(say 1.2.3.4) using kubernetes "auth-url" annotation > to the legacy system and if successful we are forwarding to our > application server.(say w.s.x.c) > > We want to do few things > > we want a consolidated nginx server(/container) which can use do > secondary authentication with legacy system and also cache successful > requests. > is that possible ? We want to reduce number of hits going to legacy > system for authentication thats our end goal -- Valery Kholodkov Coldrift Technologies B.V. http://coldrift.com/ Tel.: +31611223927 ___ nginx mailing list nginx@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx ___ nginx mailing list nginx@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx
Re: Secondary auth - guidance and configuration help
Yes, it's achievable with scripting/separate fixture. Requires shared storage, like memcached/redis/etc. On 03-04-19 15:37, Ramachandra Bhaskar via nginx wrote: Hello We are having a legacy system(say a.b.c.d) which uses http basic authentication (username/password) Currently we are using nginx ingress controller to pass all the requests coming to webserver(say 1.2.3.4) using kubernetes "auth-url" annotation to the legacy system and if successful we are forwarding to our application server.(say w.s.x.c) We want to do few things we want a consolidated nginx server(/container) which can use do secondary authentication with legacy system and also cache successful requests. is that possible ? We want to reduce number of hits going to legacy system for authentication thats our end goal -- Valery Kholodkov Coldrift Technologies B.V. http://coldrift.com/ Tel.: +31611223927 ___ nginx mailing list nginx@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx
Secondary auth - guidance and configuration help
Hello We are having a legacy system(say a.b.c.d) which uses http basic authentication (username/password)Currently we are using nginx ingress controller to pass all the requests coming to webserver(say 1.2.3.4) using kubernetes "auth-url" annotation to the legacy system and if successful we are forwarding to our application server.(say w.s.x.c) We want to do few things we want a consolidated nginx server(/container) which can use do secondary authentication with legacy system and also cache successful requests.is that possible ? We want to reduce number of hits going to legacy system for authentication thats our end goal https://docs.nginx.com/nginx/admin-guide/security-controls/configuring-subrequest-authentication/#https://docs.nginx.com/nginx/admin-guide/content-cache/content-caching/ RegardsBhaskar - ___ nginx mailing list nginx@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx
Re: secondary auth caching
Hello! On Wed, Apr 03, 2019 at 12:52:22PM +, Ramachandra Bhaskar via nginx-devel wrote: > Hello > We are having a legacy system which uses http basic authentication > (username/password)Currently we are using nginx ingress controller to pass > all the requests coming to webserver using kubernetes "auth-url" annotation > to the legacy system and if successful we are forwarding to our application > server. > We want to do few things > we want a consolidated nginx server(/container) which can use do secondary > authentication with legacy system and also cache successful requests.is that > possible ? We want to reduce number of hits going to legacy system for > authentication thats our end goal > https://docs.nginx.com/nginx/admin-guide/security-controls/configuring-subrequest-authentication/#https://docs.nginx.com/nginx/admin-guide/content-cache/content-caching/ > RegardsBhaskar This mailing list is about nginx development. For questions on how to configure nginx please use the nginx@ mailing list instead. See http://nginx.org/en/support.html for details. Thank you. -- Maxim Dounin http://mdounin.ru/ ___ nginx-devel mailing list nginx-devel@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx-devel
secondary auth caching
Hello We are having a legacy system which uses http basic authentication (username/password)Currently we are using nginx ingress controller to pass all the requests coming to webserver using kubernetes "auth-url" annotation to the legacy system and if successful we are forwarding to our application server. We want to do few things we want a consolidated nginx server(/container) which can use do secondary authentication with legacy system and also cache successful requests.is that possible ? We want to reduce number of hits going to legacy system for authentication thats our end goal https://docs.nginx.com/nginx/admin-guide/security-controls/configuring-subrequest-authentication/#https://docs.nginx.com/nginx/admin-guide/content-cache/content-caching/ RegardsBhaskar ___ nginx-devel mailing list nginx-devel@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx-devel
Re: Не работает location или я что-то делаю не так?
Dmytro Lavryk Wrote: --- > Выдержки из конфига: Сам сразу и разобрался. Вдруг кому пригодится: Выше по конфигу были прописаны error_page на статические файлы, которых (файлов) не было. Потому все ошибки в итоге выдавались как 404 Posted at Nginx Forum: https://forum.nginx.org/read.php?21,283594,283595#msg-283595 ___ nginx-ru mailing list nginx-ru@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx-ru
Не работает location или я что-то делаю не так?
Выдержки из конфига: location = /robots.txt { add_header X-uri "robots"; allow all; } location = "/someuri" { add_header X-uri "someuri"; try_files $uri =403; } Проверяем: # curl -v https://mydomain.com/robots.txt < HTTP/2 200 < server: nginx < date: Wed, 03 Apr 2019 12:03:41 GMT < content-type: text/plain; charset=utf-8 < content-length: 444 < last-modified: Sun, 10 Mar 2019 12:35:47 GMT < vary: Accept-Encoding < etag: "5c8504a3-1bc" < x-uri: robots < accept-ranges: bytes # curl -v https://lekos.com.ua/someuri < HTTP/2 404 < server: nginx < date: Wed, 03 Apr 2019 12:05:30 GMT < content-type: text/html; charset=utf-8 < content-length: 162 < Что я делаю не так??? Вообще это все как тест, проблема была в том, что не уходит в именованый локейшин location = "/someuri" { try_files $uri @back; } Для чистоты эксперимента и НЕ пересечения с другими локейшенами /someuri так и есть в конфиге. Posted at Nginx Forum: https://forum.nginx.org/read.php?21,283594,283594#msg-283594 ___ nginx-ru mailing list nginx-ru@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx-ru
Caching OPTIONS Response
We are using Nginx to deliver Widevine Streaming over Web. Website sends OPTIONS request as a preflight check with every fragment request for streaming. Since Nginx by default caches GET, HEAD, we tried including OPTIONS method to cache on Nginx. proxy_cache_methods GET HEAD OPTIONS; Gives error messsage as Invalid value. Below links says OPTIONS cannot be cached https://forum.nginx.org/read.php?2,253403,253408 This is causing all the request of preflight check from Browser to load Origin Server having Nginx. Please suggest a way to handle OPTIONS request Regards, Anish Posted at Nginx Forum: https://forum.nginx.org/read.php?2,283592,283592#msg-283592 ___ nginx mailing list nginx@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx