REMEMBER_COOKIE_DURATION in flask is not working

I am trying to configure my application to expire cookies after some amount of time however they are not working as expected, my cookies don’t get expired at all.

I have the following configuration in my app.py file:

from flask_login import LoginManager
from datetime import timedelta

app.config['REMEMBER_COOKIE_DURATION'] = timedelta(seconds=30)

login = LoginManager(app)
login.init_app(app)
login.login_view = 'login'

The following is my remember_me input:

<input type="checkbox" class="form-check-input" id="remember_me" name="remember_me">
<label class="form-check-label" for="remember_me">Remember me for 1 week</label>

Finally the following is my view function:

@app.route('/login', methods=['GET', 'POST'])
def login():
    if current_user.is_authenticated:
        return flask.redirect(flask.url_for('home'))
    if flask.request.method == 'POST':
        member_username = flask.request.form['member_username']
        member_password = flask.request.form['member_password']
        remember_me = flask.request.form.get('remember_me')

        existing_user = Users.query.filter_by(username=member_username).first()

        if existing_user is None or not existing_user.check_password(member_password):
            flask.flash('Invalid username or password')
            return flask.redirect(flask.url_for('login'))

        if existing_user:
            login_user(existing_user, remember=remember_me)

        next_page = flask.request.args.get('next')
        if not next_page or url_parse(next_page).netloc != '':
            next_page = flask.url_for('home')
        return flask.redirect(next_page)
    return flask.render_template('login.html')

The resources I have already followed:
https://code.luasoftware.com/tutorials/flask/how-to-configure-flask-login/
https://www.youtube.com/watch?v=CRvV9nFKoPI
flask-login: Chrome ignoring cookie expiration?

What am I missing?

Go to Source
Author: sherlock

Ubuntu Installation Stuck at “update-grub”

I have gone through all the similar questions asked about this problem and tried the workarounds mentioned over there but nothing works. Like the ” ps | grep ‘dmsetup create’ ” workaround simply doesn’t work, because I don’t get any output displaying any PID (so I can’t kill any process), then the one regarding deleting 30_os-prober just deletes the file but has no effect on the installation. I am trying to do a clean install on a HDD, can anyone please help me solve this problem. [I am installing Ubuntu LTS 20.04.1 from a live USB]

Go to Source
Author: Utkarsh Jha

Do I need to associate my backend API server with a domain name to get an SSL certificate for it (HTTPS)?

I have developed my DRF back-end API locally, deployed it on an AWS Lightsail instance (with a public static IP) and I now want to secure it with HTTPS.

I understand that in order to use Let’s Encrypt (and not pay for an SSL certificate), I have to have a domain name associated to my instance IP since Let’s Encrypt doesn’t provide certificates for public IPs. As this is my back-end API (and not just a website), I don’t intend to buy a domain specifically for this.

  1. Can I, somehow, associate my Lightsail IP with another domain that I’ve already purchased (and is used to host my company’s landing page)? If yes, will there be any impact on my API’s performance?

  2. Is there any other alternative to obtain an SSL? (Apart from paying another CA to issue this for my public IP?)

Go to Source
Author: kingJulian

WordPress Multisite determine the correct domain to be set as current/default domain when setting multisite in Local fresh installation

I am unsuccessfully trying to setup multisite with WordPress’s fresh setup(WordPress installed in subfolder under htdocs of Localhost), but existing copy of Database already imported(provided by client).

Now the database already has atleast 15-16 different domain URLs already as entries of siteurl and home field in various wp_options tables for each site-domain.

And I want to use the same site-domains with little modifications to be able to work in Localhost WP multisite(like .com replaced with .local or so).

But even after doing all that and setting up multisite with following wp-config.php settings, when I try to access domain1.local, it tries to redirect to domain2.local like http://domain2.local/wp_signup.php?domain1.local and never redirects properly:

....
/* Multisite */
define('MULTISITE', true);
define('WP_ALLOW_MULTISITE', true);
define('SUBDOMAIN_INSTALL', true);
define('DOMAIN_CURRENT_SITE', 'domain1.local');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);
....

.htaccess:

RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*.php)$ $1 [L]
RewriteRule . index.php [L]

Can anyone help in figuring out what’s wrong here ?

Go to Source
Author: Vicky Dev

Running Windows in QEMU with LVM causes very slow disk acess

I have the problem, that whenever I try to run Windows within QEMU, it seems that disk access is becomming very slow after a short while. Surprisingly both access to the disk from within the VM as well as outside of the VM seems to become slow.

I have both my home and my QEMU windows drive on the same disk (this is a laptop, so I cannot use multiple disks), but on different LVM volumes (no qcow or anything, just the raw LV). Just after few minutes, windows becomes unusably slow, and the host also becomes slow. As soon as I disable the VM, the host becomes usable again. I have traced back the problem in windows to slow disk access using the resource monitor. But the problem seems to be in on the LVM side of the host. If I run iostat -xz I get the following:

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
          17,36   10,14    5,41   38,51    0,00   28,58

Device            r/s     rkB/s   rrqm/s  %rrqm r_await rareq-sz     w/s     wkB/s   wrqm/s  %wrqm w_await wareq-sz     d/s     dkB/s   drqm/s  %drqm d_await dareq-sz  aqu-sz  %util
dm-0             7,63     82,81     0,00   0,00   84,37    10,85   22,74    209,61     0,00   0,00  121,53     9,22    0,00      0,00     0,00   0,00    0,00     0,00    3,41   3,32
dm-1             0,05      0,27     0,00   0,00    5,05     5,49    0,00      0,00     0,00   0,00    0,00     0,00    0,00      0,00     0,00   0,00    0,00     0,00    0,00   0,00
dm-2             0,00      0,09     0,00   0,00    6,10    21,75    0,00      0,00     0,00   0,00    0,00     0,00    0,00      0,00     0,00   0,00    0,00     0,00    0,00   0,00
dm-3             2,28      9,12     0,00   0,00   21,28     4,00    0,00      0,00     0,00   0,00    0,00     0,00    0,00      0,00     0,00   0,00    0,00     0,00    0,05   0,53
dm-4             0,02      0,09     0,00   0,00    4,95     4,00    0,00      0,00     0,00   0,00    0,00     0,00    0,00      0,00     0,00   0,00    0,00     0,00    0,00   0,00
dm-5             0,00      0,00     0,00   0,00   31,64     4,00    0,00      0,00     0,00   0,00    0,00     0,00    0,00      0,00     0,00   0,00    0,00     0,00    0,00   0,00
dm-6             0,02      0,09     0,00   0,00    4,94     4,00    0,00      0,00     0,00   0,00    0,00     0,00    0,00      0,00     0,00   0,00    0,00     0,00    0,00   0,00
dm-7             0,00      0,09     0,00   0,00    6,85    21,75    0,00      0,00     0,00   0,00    0,00     0,00    0,00      0,00     0,00   0,00    0,00     0,00    0,00   0,00
dm-8            36,13   1454,39     0,00   0,00   46,74    40,25  528,37   2107,50     0,00   0,00  122,58     3,99    0,00      0,00     0,00   0,00    0,00     0,00   66,46  12,66
dm-9             7,63     82,77     0,00   0,00   84,49    10,85   22,74    213,86     0,00   0,00 1578,74     9,40    0,00      0,00     0,00   0,00    0,00     0,00   36,55   3,18
nvme0n1          4,49    176,13     5,82  56,45    0,19    39,26  101,54    445,00     0,07   0,07    0,95     4,38    0,00      0,00     0,00   0,00    0,00     0,00    0,07   0,38
sda             41,89   1547,29     4,19   9,10   46,21    36,93   41,60   2317,08   509,51  92,45  158,29    55,70    0,00      0,00     0,00   0,00    0,00     0,00    8,40  15,35

dm-8 is the windows LV and dm-9 is my home drive. So for some reason it seems that data is being queued for both these drives. The write speed isn’t terribly fast while the system is sluggish, somewhere around 1-5MB/s at most, which is very slow for the drive I have in the system.

CPU Usage is very low, while the VM is running (both inside the VM using resource monitor, as well as on the host). Usually, it is only around 10%.

I am using Virtio as a storage adapter and I already tried different configurations (threads, caching etc), but nothing seems to change this problem.

Is there some other configuration that I could try to get a better disk access?

Go to Source
Author: LiKao

Queue Implementation with Custom Consistent Absolute Ordering

H!

I need to create a schema for a queue. Elements in this queue will be processed in an order based on a column. However, this is not always the e.g. date_added column. Users should be able to freely re-order items in the queue, thus setting a custom position – let’s call that field position. Therefore, queue items that have a position >= to the new position I set for a specific item need to be re-ordered on each update.

I really want to avoid using a server-side script to manually go through each of the now outdated elements and updating their position. Is there a way to do this automatically, and with relatively low resource usage? I’m sure people have implemented such a queue in MySQL before, but there don’t seem to be relevant answers anywhere, although the task sounds trivial. Any ideas?

Go to Source
Author: XedinUnknown

How to auto-reply to reply-to field?

I would like send auto-reply mails to email addresses written in reply-to field. How this can be achieved?

  Sample Mail Received :
 
 from:  abc@gmail.com
 reply-to:  def@gmail.com
 to:    ghi@gmail.com
 date:  Aug 31, 2020, 12:43 AM    

By using the template and filter options I am able to send auto-reply e-mails to addresses written in from field (abc@gmail.com in this case). But I am not able to figure how to send auto-reply to addresses written in reply-to field (def@gmail.com in this case).

Go to Source
Author: deepak sharma

How to create an Event-Driven Architecture with many external sources

I work for this Accounting company – as a Product Owner – that uses several external services (one for Contract management, another one for Accounting Demands management, a third one for Financial purposes and so on).

My IT Director wants us to build an Event-Driven Architecture to gather all the events that happen externally and bring them into our NoSQL in as-close-as-possible realtime.

The problem specifically is: how can I gather this data from external sources? What would be the best procedure for hundreds of events every day from different services? Consuming their APIs periodically?

Can you guys shine a light on how this can be properly done?

Go to Source
Author: Otto Neres

Extracting all data from a list tag using HTML Agility Pack in C#

I am using the HTML Agility Pack to extract data. I want to extract all list items from the source:

<div id="feature-bullets" class="a-section a-spacing-medium a-spacing-top-small">

<ul class="a-unordered-list a-vertical a-spacing-mini">

<li><span class="a-list-item">
some data 1

</span></li>

<li><span class="a-list-item">
some data 2

</span></li>

<li><span class="a-list-item">
some data 3

</span></li>

<li><span class="a-list-item">
some data 4

</span></li>

</ul>

My code so far:

string source = someSource

var htmlDoc = new HtmlAgilityPack.HtmlDocument();
htmlDoc.LoadHtml(source);

How can I extract all the list items to get a result similar to this:

List value 1 is: some data 1
List value 2 is: some data 2
List value 3 is: some data 3
List value 4 is: some data 4

Go to Source
Author: Josie

Operating VirtualBox on Win10 with KVM Nested

My current environment is Ubuntu 20.04.
CPU: AMD 3950X

I want to install and operate VirtualBox on Win10 using KVM Nested.

Host: Ubuntu 20.04
L1: Windows10
L2: VirtualBox(Win10 Or Win7)

Neste setting situation

kimcar@kimcar-Ubuntu:~$ cat /proc/cpuinfo | grep -c svm
32
kimcar@kimcar-Ubuntu:~$ cat /sys/module/kvm_amd/parameters/nested
1
kimcar@kimcar-Ubuntu:~$ cat /etc/modprobe.d/qemu-system-x86.conf
options kvm_amd nested=1
kimcar@kimcar-Ubuntu:~$

L1 XML Setting

Windows10_GAME
853e7548-3870-4587-a64a-0270b79d8924

8392704
8392704
8
2

hvm
/usr/share/OVMF/OVMF_CODE.fd
/var/lib/libvirt/qemu/nvram/Windows10_GAME_VARS.fd

destroy
restart
destroy

—————————————————————————

I searched for various information and tried it, but the symptom of turning on and stopping when running the Client in VirtualBox keeps appearing.

Go to Source
Author: Chul Hwam Kim

WordPress Settings API using angularJS

i’m trying to update WordPress General Settings page with AngularJS with a $http.post

$scope.update = function(genSet){
       $scope.generalSettings = angular.copy(genSet);
       $http.post('options-general.php', JSON.stringify($scope.generalSettings)).then(function (response) {
          alert("success");
          console.log($scope.generalSettings);                        
       }, function (response) {                 
          alert("fail");                                             
       });                            
       }

The form itself is composed of two input fields with the same name as those in options-general.php

The form posts and the response is successful, though the settings page itself doesn’t change.

Am i missing something here?

Go to Source
Author: Alexandru Andrei

Google slides for non gmail accounts … can they copy the presentation and edit?

So essentially, I have spent most of the summer creating a digital notebook for my students. I am using google slides for this presentation and want to send the presentation to my students, have them create their own copy and then be able to edit their copy and do their work in the slides. Then, at the end of the week, send me a link to their work and I can look at it, edit it and grade it. Is this possible if the student does not have a gmail account?? Thank you!!!!

Go to Source
Author: Rachel

Applications in Azure how connect to Microsoft Exchange on-premise

We are moving an application to Azure from on-premise which uses on-premise exchange 2019. The application will be moved as it is life and shift. Once the application is moved to Azure can you guide how the application will be authonicating back for exchange activity, We will have a local domain controller in Azure on VM

Any changes needed in Exchange on-premise side?
Any changes needed in the application?

Go to Source
Author: Azure-begin