Sieve filter rule - postfix-mta

I want using SIEVE to filter e-mails in a postfix/dovecot installation.
Assuming there are multiple recipients in the TO field of an email.
Is there a SIEVE rule to match an email if the TO field contains an email address with a specific domain name and at the same time contains an email address with a domain name different to that specific domain name?
For example, let the specific domain be "example.com".
TO: a#example.com, b#abc.com -> MATCH
TO: a#xyz.com, b#abc.com -> NO MATCH (since no address with example.com)
TO: a#example.com -> NO MATCH (since no address different to example.com)
TO: a#example.com, b#example.com -> NO MATCH (since no address different to example.com)
TO: a#abc.com -> NO MATCH

What turned out to working for me is the following:
require "regex";
if allof ( address :domain :is "To" "example.com",
header :regex "to" "#[^(example.com)]+"
) { ... } else { ... }
Thus, you can match "some domain different to example.com" with the statement header :regex "to" "#[^(example.com)]+"
SIDENOTE
Some thoughts about Kaspar's suggestion (which did not work for me).
It turned out that
if address :domain :is "To" "example.com" {
matches if any of the emails in the To-field contains example.com. The not-statement just negates this result. I.e.
if not address :domain :is "To" "example.com" {
matches if none of the emails in the To-field contains example.com.
As a consequence, combining both statements within allof does never match.

[Edit: The following rule does not work, see the other answer for the reason.]
I'm not an expert on the Sieve mail filtering language, but have you tried something like the following, using address, not, and allof?
if allof (address :domain :is "To" "example.com", not address :domain :is "To" "example.com") {
…
}

You can use relational extension to ensure the existence of an email address with a domain name different to the specific one. See Extended Example section of RFC5231.
require "relational";
if allof (
address :domain :is "To" "example.com",
address :value "ne" :domain "To" "example.com"
) {
# match
} else {
# no match
}

Related

Certificate issue in Kestrel ssl JSON configuration

Referencing to Kestrel documentation is it possible to configure https using appsettings.json file:
"HttpsInlineCertStore": {
"Url": "https://+:5002",
"Certificate": {
"Subject": "<coma separated multi-line subject name>",
"Store": "Root",
"Location": "LocalMachine"
}
This certificate exist for sure and next code returns finds it:
using (var certStore = new X509Store(StoreName.Root, StoreLocation.LocalMachine))
{
certStore.Open(OpenFlags.ReadOnly);
var certificates = certStore.Certificates.Find(
X509FindType.FindBySubjectDistinguishedName, "<coma separated multi-line subject name>", true);
return certificates .Count > 0 ? certificates [0] : null;;
}
At the same time if to search certificate by X509FindType.FindBySubjectName it founds nothing and I believe this is the issue even though microsoft says that FindBySubjectDistinguishedName is more specific search.
Finally I was able to fix this issue:
is something like "CN=name, C=UK, ..." but if you want to FindBySubjectName you must remove "CN=" from search string and leave only the name so it is looks not like "CN=name" but like "name".

Is JWT claim name case-sensitive?

Simple question:
Is following payload:
{
"aud": ["aud1", "aud2"]
}
equivalent to:?
{
"AUD": ["aud1", "aud2"]
}
According to the specification in RFC7519 claim names are case-sensitive:
Claim Name:
The name requested (e.g., "iss"). ... This name is
case sensitive. Names may not match other registered names in a
case-insensitive manner unless the Designated Experts state that
there is a compelling reason to allow an exception.

jsonPath and email address

I am using jsonpath.com to try to use an email address as the KEY.
so my data might look like this:
"phoneNumbers": [
{
"type" : "iPhone",
"bob#gmail.com": 123456,
"number": "0123-4567-8888"
},
however, i am unable to reference the email address:
$.phoneNumbers[0]['type'] // iPhone
$.phoneNumbers[0]['number'] // 0123-4567-8888
$.phoneNumbers[0]['bob#gmail.com'] // no match
$.phoneNumbers[0]['bob\#gmail.com'] // no match
$.phoneNumbers[0]['bob\#gmail\.com'] // no match
how may i specify a jsonPath key using an email address?
The dot in .com is the problem. See this SO answer. It would seem that it should be possible to do $.phoneNumbers[0]['bob#gmail.com'], but not on jsonpath.com
The key statement in that answer:
jsonpath.com is based on an outdated version of JSONPath and is not
reliable for previewing what current libraries would provide you with.

Stop GA reporting from appending the domain to the path when previewing

I'm using Google Analytics to track data across multiple domains in a single profile.
By default, reporting only shows the path, not the full URL. This makes it quite confusing where multiple pages on our different domains have the same paths (e.g. '/index' or '/about').
To get round this, I've implemented the filter advised by Google to display the full URL in reporting:
Filter Type: Custom filter > Advanced
Field A: Hostname Extract A: (.*)
Field B: Request URI Extract: (.*)
Output To: Request URI Constructor: $A1$B1
This works just fine ; the only downside is that using the 'preview link' button in the reporting always appends the domain, resulting in a 404 error.
....clicking the 'link preview' icon results in......
Does anyone know a way around this ; either by preventing GA from appending the domain or a better way of displaying the full URLs in reporting?
Thanks Eike - I took your advice and wrote a small browser extension for Chrome. Obviously this isn't an essential, but I wanted to address it as our marketing team use the feature so frequently.
The manifest json :
{
"manifest_version": 2,
"name": "Analytics cross-domain link shortcut",
"version": "1.0",
"description": "Makes the links shortcuts in analytics work when using a 'full url' filter!",
"content_scripts":
[
{
"matches": ["*://*/*"],
"js": ["myscript.js"],
"run_at": "document_start"
}
]
}
And the script:
if (window.opener && document.referrer == "") {
var currentLocation = window.location.href;
if(currentLocation.indexOf("www.appendedurl.com") > -1) {
var newLocation = currentLocation.substr(30); // where '30' is the length of the appended URL
window.location.href = "http://"+newLocation;
}
}
So it's essentially just snipping off the appended URL (if present) on freshly opened popup windows.

Drupal Rules + one-time-login redirect issue

Problem is as follows:
I have a rule which redirects users to a landing page after login. It works fine.
However, if a user forgets their password, they are sent a link to the one-time-login page. They click the button and (because of my rule) are sent to their landing page.
The problem of course is that they cannot then change their password because the normal password change (in the user profile) requires you know your password to change it.
So how would I modify my redirect rule to say:
"Redirect to landing page, unless the logging-in user is coming from the one-time-login screen" or "Redirect to the landing page, unless the target URL starts with /user/reset/* (can you wildcard??)"
Thanks in advance for any tips
You can do that with a rule like that:
{ "rules_after_login_redirect_to_news" : {
"LABEL" : "After login redirect to news.",
"PLUGIN" : "reaction rule",
"WEIGHT" : "0",
"REQUIRES" : [ "rules" ],
"ON" : [ "user_login" ],
"IF" : [
{ "NOT text_matches" : {
"text" : [ "site:current-page:path" ],
"match" : "^user\/reset\/",
"operation" : "regex"
}
}
],
"DO" : [ { "redirect" : { "url" : "news" } } ]
}
}
I fixed this problem just using rules, as outlined in another answer here but i had to modify it to work, i had to set the Text comparison condition to negative, and the page redirect to Force redirect, and the page i wanted was called 'getting-started'. Works Perfect
So the rule i added:
EVENTS
User has logged in
CONDITIONS
NOT Text comparison
Parameter: Text: [site:current-page:path], Matching text: user, Comparison operation: starts with
ACTIONS
Page redirect
Parameter: URL: getting-started
In the project I'm currently working on I encountered the same problem.
We solved it by using the Context module (http://drupal.org/project/context).
Install and enable the Context module.
Create a context with the condition :
path = ~user/reset/*
(Leave reactions empty)
Use this context as an condition in the login redirect rule
(Context rules / is a context set)
You can also fix this problem just using the module rules, no coding.
In my case I wanted to redirect people to their workbench after they login.
But people that forgot their password would also get redirected to their workbench and wouldn't be able to change their password. They had to navigate to their own profile page but they had to reenter their password again: the onetime logging didn't work anymore.
So this is the rule I added:
Events
Event: User logged in.
Conditions
Elements: Text comparison.
Parameter: Tekst: [site:current-page:path], Matching text: user, Comparison operation: ends with
Actions
Elements: Page redirect
Parameter: URL: admin/workbench, Force redirect: false
There is a Path Rules module and Rules Bonus Pack module that could do this nicely in Drupal 6. But unfortunately it looks like this feature/module is not coming for Drupal 7. See http://drupal.org/node/1506298 and http://drupal.org/node/1045964#comment-6016904
However, you still can use PHP condition to check the path.
Try this (add a new condition and use php to add this. You will need php module enabled).
In the Rules that redirects users after logging in,
<?php
if (arg(0) == 'user' && arg(1) == 'reset'){
return FALSE;
}
else{
return TRUE;
}
?>
This will prevent the Rule from continuing if the path us user/reset/*.
Also, probably you will need the same condition with TRUE False exchanged in another Rule that redirects password-change users.

Resources