Last active
September 6, 2020 11:31
-
-
Save myselfneerav/1305ad4e8b5793d75d92a2a0dab835ce to your computer and use it in GitHub Desktop.
Revisions
-
myselfneerav revised this gist
Sep 6, 2020 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,6 @@ ffi.cdef([[ ]]); local result = 0 local typeString = ffi.typeof("GoString") @@ -19,7 +18,7 @@ if ngx.var.http_Authorization and string.len(ngx.var.http_Authorization) > 0 the result = authlib.Authenticate(accessTokenString) if tonumber(result)~=0 then -- proceed to route to upstream else return ngx.exit(ngx.HTTP_UNAUTHORIZED) end -
myselfneerav revised this gist
Sep 6, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ local ffi = require("ffi") local authlib = ffi.load("/gateway/auth/main/libauth.so") ffi.cdef([[ typedef long long GoInt64; -
myselfneerav revised this gist
Sep 6, 2020 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,7 +13,6 @@ ffi.cdef([[ local accessToken = "" local result = 0 local typeString = ffi.typeof("GoString") if ngx.var.http_Authorization and string.len(ngx.var.http_Authorization) > 0 then local accessTokenString= typeString(ngx.var.http_Authorization, string.len(ngx.var.http_Authorization)) -
myselfneerav revised this gist
Sep 6, 2020 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,4 @@ local ffi = require("ffi") local authlib = ffi.load("/gateway/auth/main/auth.so") ffi.cdef([[ -
myselfneerav created this gist
Sep 6, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ local ffi = require("ffi") local cjson = require("cjson") local authlib = ffi.load("/gateway/auth/main/auth.so") ffi.cdef([[ typedef long long GoInt64; typedef unsigned long long GoUint64; typedef GoInt64 GoInt; typedef struct { const char *p; GoInt n; } GoString; extern GoInt Authenticate(GoString p0); ]]); local accessToken = "" local result = 0 local typeString = ffi.typeof("GoString") local unauthorizedJson={} if ngx.var.http_Authorization and string.len(ngx.var.http_Authorization) > 0 then local accessTokenString= typeString(ngx.var.http_Authorization, string.len(ngx.var.http_Authorization)) result = authlib.Authenticate(accessTokenString) if tonumber(result)~=0 then -- we are ok here and proceed to route to upstream else return ngx.exit(ngx.HTTP_UNAUTHORIZED) end else return ngx.exit(ngx.HTTP_UNAUTHORIZED) end