logo
down
shadow

Can I extend Traefik in a way to open the request header check user identity and update request url?


Can I extend Traefik in a way to open the request header check user identity and update request url?

By : Michael H
Date : October 17 2020, 06:10 AM
this one helps. For the time being, the only way to add a custom middleware to Traefik is to fork it and add your custom middleware into the source code and build it for yourself. Actually this is not too difficult but of course it comes with all the downsides of forking. There is an example here: https://github.com/negasus/traefik2-luascript. You need to edit it a bit because it is somewhat outdated but I was able to add my custom middleware by following it.
code :


Share : facebook icon twitter icon
php open an asynchronous request and allow client to check if the request has finished

php open an asynchronous request and allow client to check if the request has finished


By : Nguyen Manh Cuong
Date : March 29 2020, 07:55 AM
will be helpful for those in need so Christian Davénpost on this page inspired my solution to my own problem which is as follows:
code :
if(array_key_exists('async', $_GET)){
   //short-task spawns the child(fakeLongTask())
   testing::curl_request_async();
}else{
    //short task, aka child task
    testing::fakeLongTask();
}

class testing{
    /**
     * asynch trigger a event(parent/short Task)
     */
    public static function curl_request_async(){
        //set file path to a unique file name for you...maybe consider using tmp type functionality
            $file = 'C:\\filepath\\logFile.txt';
        $fp = curl_init('http://localhost/testing.php?file='.$file);
            //send the request off
        curl_exec($fp);
            //because I am not sure that the socket is closed when it interperets the header, and because its a best practice
        curl_close($fp);

        while(file_exists($file)){
            echo 'we are waiting because the process is still going and the lock is still imposed.<br />'.PHP_EOL;
            sleep(3);
        }
    }

    /**
     * this is to mimic a long task that we might be running.
     * basic setup is clear the buffer, set the raw header to the close value to let the browser
     * know that the request has 'finished' so it can return to the calling function after the output is sent.
     * specify the size of the information being sent as this is required for the header. Then send the buffer and start
     * processing asynchronously
     * 
     * child/long/orphaned Task
     */
    public static function fakeLongTask(){
        //clear the buffer
        while(ob_get_level()){
             ob_end_clean();
        }
        //specify that this is a non-persistant connection
        header('Connection: close');
        //if the user kills the script ignore there request and keep on, nice feature to avoid early termination
        ignore_user_abort(true);
        ob_start();
        //if you need to send any information to the user specify that here
        $size = ob_get_length();
        header("Content-Length: $size");
        //since flush might not get everything we must do a 'power flush'
        ob_end_flush();
        flush();
        //from this point on the original function that had the curl op in it will continue and this will also continue on asynchronously
        //create the new file(this is our only way to communicate to the parent script as this function is now running rouge.
        $file = $_GET['file'];
        $fileHandle = fopen($file, 'w') or die('');
        fclose($fileHandle);
        //now that we have our file lets do our process, or in this case just stall for 10 seconds
        sleep(10);
        //we are done with our task delete the file
        unlink($file);
    }
}
Identity 2.0: Creating custom ClaimsIdentity eg: User.Identity.GetUserById<int>(int id) for Per Request Validation

Identity 2.0: Creating custom ClaimsIdentity eg: User.Identity.GetUserById<int>(int id) for Per Request Validation


By : user2946756
Date : March 29 2020, 07:55 AM
wish help you to fix your issue The IIdentity object in MVC is going to be the issued token that corresponds to the identity of the user. This differs from whatever object or method you use on the back-end that represents the user (say a User class). If you want to use the user's identity to get a custom value then you need to put it into their claims object (ie the identity token) when they sign in (or at some other point in time).
You can add a claim at any time by giving the user an identity.
code :
AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie);
var identity = await UserManager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie);
identity.AddClaim(new Claim("PhoneNumber", "123-456-7890"));
AuthenticationManager.SignIn(new AuthenticationProperties() { IsPersistent = isPersistent }, identity);
public static string GetPhoneNumber(this IIdentity identity)
{
    return ((ClaimsIdentity)identity).FindFirstValue("PhoneNumber");
}
@using MyProject.Web.Extensions

<img src="@User.Identity.GetPhoneNumber()" />
Proxy a request - get a parameter from URL, add a header and update request URL using Nginx

Proxy a request - get a parameter from URL, add a header and update request URL using Nginx


By : salazar_x
Date : March 29 2020, 07:55 AM
Does that help Since the data exists within the request URI itself (available by the $uri variable in nginx), you can parse that using the nginx lua module. nginx will need to be compiled with lua for this to work, see: openresty's nginx lua module.
From there you can use the set_by_lua_block or set_by_lua_file directive given $uri as a parameter.
code :
location / {
    ...
    set_by_lua_file $var_to_set /path/to/script.lua $uri;
    # $var_to_set would contain the result of the script from this point
    proxy_set_header X-Replica $var_to_set;
    ...
}
function parse_uri( uri )
    parsed_uri = uri
    -- Parse logic here
    return parsed_uri
end

return parse_uri( ngx.arg[1] )
How do I check an OWIN request before HttpContext.Current.User.Identity is set?

How do I check an OWIN request before HttpContext.Current.User.Identity is set?


By : Daniel
Date : March 29 2020, 07:55 AM
like below fixes the issue You could create an owin middleware which checks the Ip adress as the first step in the chain. Place it as the first middleware being attached to the IAppBuilder to make sure it will invoke before the rest of the chain
code :
public class Startup
{
    public void Configuration(IAppBuilder app)
    {
        app.Use((context, next) =>
        {
            if (!IsIpAdressOk(context.Request)) //if the ip is invalid, stop the process and just return a response to the client
            {
                return context.Response.WriteAsync("Get lost!");
            }
            return Next.Invoke(context); //if the ip is correct then continue to the next middleware
        });

        ...add OAuthAuthorizationServerProvider and the rest here   
    }
}
Duplicate request with `Sec-Fetch-User: ?1` header messes up my request throttling

Duplicate request with `Sec-Fetch-User: ?1` header messes up my request throttling


By : Josh Cai
Date : March 29 2020, 07:55 AM
hope this fix your issue The answer can be found into this IETF draft, ?1 actually means true. So the first request you observe is likely being triggered by the user (when submitting the form), and the second one isn't.
Related Posts Related Posts :
  • Help writing database queries for derby?
  • Issues with Trac (installed with BitNami)
  • Using Ghostscript in server mode to convert PDFs to PNGs
  • What's the case when using software licensed under GPL or LGPL
  • Is there any less or more convenient iDoc Script editor for Oracle 10g UCM?
  • What are the most popular RSS readers? (software/web apps)
  • MPICH vs OpenMPI
  • Why are not all texts of my MFC applicatiopn displayed using ClearType?
  • Should I focus on code quality while Rapid prototyping?
  • how to get response in QtWebKit
  • Silverlight - Access the Layout Grid's DataContext in a DataGrid CellTemplate's DataTemplate?
  • is it possible to set specific file extensions as exclusive check out only, with TFS
  • JasperReports: is it possible to use multiple data sources, or if not, to use collections in parameters?
  • Is there a 2d sprite library for webgl?
  • Error: NAND: could not write file /hd2/android-sdk-linux_86/add-ons/google_apis-7_r01/images//system.img, File exists
  • how to configure and use jstl in websphere
  • What does => mean in Ada?
  • Maven best practice for generating artifacts for multiple environments [prod, test, dev] with CI/Hudson support?
  • Maven best practice for generating multiple jars with different/filtered classes?
  • Usage of # in Pascal
  • Generics and polymorphism
  • Concurrent call to conversation
  • polymorphism relates inheritance
  • Maximum values in wherein clause of mysql
  • Forbid developer to commit code because of making weekly build
  • Automatically adjustment of wxPython Frame Size
  • how to import a file into mathematica and reference a column by header name
  • How to integrate junit/pmd/findbugs report into hudson build email?
  • In Symfony, sharing data across subdomains
  • In MediaWiki, is it possible to capture user search terms that don't return results?
  • How to check in what language a program (.exe) has been written. How to view the code?
  • Can I automap a tree hierarchy with Fluent NHibernate?
  • How to adjust the distribution of values in a random data stream?
  • Optimizing SMO with RBFKernel (C and gamma)
  • How to wait for one second on an 8051 microcontroller?
  • Major sites browser incompatibilities
  • What tools do you use to manage Change requests and Bug Reports
  • Silverlight -RIA Services-This EntitySet of type <> does not support the 'Add' operation
  • How to monitor windows manchine in grafana using prometheus?
  • Produce new word2vec model from existing one
  • Migrating Rails from Asset Pipeline to Webpacker: Uncaught ReferenceError: $ is not defined in rails-ujs.js
  • Extract lines with string and variable number pattern
  • Configuration priority - best practise
  • WebAssembly dynamic module unloading
  • Call SWS Via Sabre Red Workspace From Native API Bridge Application
  • How to set query timeout when using Presto CLI?
  • What's the difference between agent.add() and conv.ask() on dialogflow
  • Pymodbus - Read input register of Energy meter over rs485 on uart of raspberry pi3
  • Execute bash script on a dataproc cluster from a composer
  • Gremlin: select vertex based on comparison of two property values
  • How do you createRef in Suave Fable?
  • I am having trouble building Azerothcore on Windows 10 Home, VS 2017
  • Why is testcafe-docker.sh ignoring app-init-delay parameter?
  • DynamoDB Adjacency List Pattern
  • Is there a way for my aplication to detect beacons in Powerapps?
  • "Initialize interactive with Project" is missing for .Net Core Projects in Visual Studio 2019
  • Cosmos db Order by on 'computed field'
  • let a rpm to automatically install centos-release-scl-rh
  • What is the "Stage" folder inside MarkLogic Installed Directory? How does MarkLogic use this folder?
  • Implement requestHooks in cucumber/testCafe
  • shadow
    Privacy Policy - Terms - Contact Us © 35dp-dentalpractice.co.uk