How do you configure the FROM field in a jetty email configuration? - email

I'm configuring version 1.4-M3 of Archiva running standalone with Jetty.
The configuration works (I get the emails). However, they're being reported from "root#localhost". As you can see in the configuration below I have mail.from defined, but somehow it is not being picked up. No mail header contains the address archiva#mymailserver.com.
What is the correct configuration so emails are shown as being sent from archiva#mymailserver.com?
<New id="validation_mail" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg>mail/Session</Arg>
<Arg>
<New class="org.eclipse.jetty.jndi.factories.MailSessionReference">
<Set name="user">myuser</Set>
<Set name="password">OBF:1yxf1vnw1v1p1vu51vv51v2p1vn61ym5</Set>
<Set name="properties">
<New class="java.util.Properties">
<Put name="mail.smtp.host">mail.server</Put>
<Put name="mail.smtp.auth">true</Put>
<Put name="mail.port">25</Put>
<Put name="mail.from">archiva#mymailserver.com</Put>
<Put name="mail.mime.address.strict">false</Put>
<Put name="mail.debug">false</Put>
<Put name="mail.transport.protocol">smtp</Put>
</New>
</Set>
</New>
</Arg>

According to Archiva's documentation, the email address is configured using the following property:
email.from.address=$user.name#localhost
Blockquote
All emails sent by the system will be from the following address
As of Archiva 2.1.x and 2.2.x, I don't see that property listed within the Properties tab of the Users Runtime Configuration section. That means that you'll need to manually set this property in archiva.xml. In case you're using a servlet container, such as Tomcat, I don't mean the archiva.xml that's located within conf/Catalina/localhost. I'm referring to the archiva.xml that's located immediately within the conf directory.
Source - Archiva's Email Configuration page

Related

Where does ${authAdminUrl} come from and how do I manipulate it?

I'm trying to setup a (dockerized) keycloak instance but, after successful login, its' Security-admin-console keeps redirecting me to an internal URL instead of the URL I have setup in dns. Looking into the settings, its Root URL is set to ${authAdminUrl}. I could override this value with an actual URL but I'd much rather change the value of the variable. So where does ${authAdminUrl} come from, and more importantly, how do I manipulate it?
Actually the whole admin base URL (including scheme and port) can be configured in the standalone.xml file,
section <spi name="hostname">.
There you can add a property "adminUrl".
It's briefly mentioned in the Installation Guide, Hostname/Default provider.
Example:
<spi name="hostname">
<default-provider>default</default-provider>
<provider name="default" enabled="true">
<properties>
<property name="frontendUrl" value="${keycloak.frontendUrl:}"/>
<property name="forceBackendUrlToFrontendUrl" value="false"/>
<property name="adminUrl" value="https://myhost:10443/auth"/>
</properties>
</provider>
</spi>
TLDR: environment variable KEYCLOAK_HOSTNAME
A little more nuanced:
The value for the placeholder ${authAdminUrl} is a complete URL, whereas the environment variable KEYCLOAK_HOSTNAME is only the hostname; so without protocol, port number, or path. In my case, this doesn't matter because I'm not doing anything special with these so the default url formed with the custom hostname is good for me.

UseOpenIdConnectAuthentication kills postback

I am trying to include SSO with office 365 for one of our web applications.
the problem is that as soon as SSO is working all my postbacks are getting ignored.
what I did was the following,
I installed those Nuget Packages
- Microsoft.Owin
- Microsoft.Owin.Host.SystemWeb
- Microsoft.Owin.Security
- Microsoft.Owin.Security.Cookies
- Microsoft.Owin.Security.OpenIdConnect
- Owin
I created an app in my AAD
then I've added some settings to my web.config
<add key="ida:PostRedirectUri" value="http://localhost:4439" />
<add key="ida:ClientId" value="XXXXXXX" />
<add key="ida:AADInstance" value="https://login.microsoftonline.com/" />
<add key="ida:Tenant" value="XXXX.onmicrosoft.com" />
<add key="ida:PostLogoutRedirectUri" value="http://localhost:4439" />
and I added Startup.vb to my solution with the following content
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType)
app.UseCookieAuthentication(New CookieAuthenticationOptions())
app.UseOpenIdConnectAuthentication(New OpenIdConnectAuthenticationOptions() With {
.ClientId = clientId,
.Authority = authority
})
app.UseStageMarker(PipelineStage.Authenticate)
and after this the SSO works however al postbacks on buttons fail
if I click a button the page just gets reloaded.
also the IsPostBack parameter is alwayst false.
What I found was that when I remove the "app.UseOpenIdConnectAuthentication" part, postbacks are working again, but SSO is not.
how can I make sure my postbacks are working and I can also use UseOpenIdConnectAuthentication ?
thank you.
I found the issue,
in my web.config I had
<modules runAllManagedModulesForAllRequests="true">
in system.web
removing the key "runAllManagedModulesForAllRequests" solved the problem
<modules>

Azure upgrade from 1.3 to 1.7 issue

I have recently upgraded our Azure solution to use the new 1.7 SDK. CSPack warned that it was running on a legacy syntax and required a definition in the service definition to run under full IIS. Here's what I added.
<Sites>
<Site name="Web" physicalDirectory="..\Portal\MyApp.Portal">
<Bindings>
<Binding name="HttpIn" endpointName="HttpIn" />
</Bindings>
</Site>
</Sites>
The web role is an MVC3 application with the following mail settings defined in web.config.
<system.net>
<mailSettings>
<smtp deliveryMethod="Network">
<network host="smtp.gmail.com" userName="support#myapp.com" enableSsl="true" port="587" password="mypassword"/>
</smtp>
</mailSettings>
These settings are pulled fine from web.config for sending emails from code by just declaring a SMTP client and using it to send emails,
SmtpClient client = new SmtpClient();
But when I add the section to the service definition the setting are not used and I get a SMTP host was not specified every time an email is attempted. The new SmtpClient() has none of the settings from config. I can not figure out how to fix this nor can I find any info elsewhere.
Try changing the name of your site to anything other than "Web".
There's a poorly documented feature of this syntax that a site with the name of "Web" will have all of it's settings like physicalDirectory ignored. If this works it might pay to think about whether or not you actually need the physicalDirectory specified.

Archiva SMTP Real domain name required for sender address Error

I installed the stand alone Apache Archiva 1.3 Maven repository and I am having trouble configuring the SMTP settings for the e-mail validation. I configured the SMTP address by changing the mail.smtp.host property in jetty.xml. I was not able to find any documentation on Archiva's site for configuring this.
<New id="validation_mail" class="org.mortbay.jetty.plus.naming.Resource">
<Arg>mail/Session</Arg>
<Arg>
<New class="org.mortbay.naming.factories.MailSessionReference">
<Set name="user"></Set>
<Set name="password"></Set>
<Set name="properties">
<New class="java.util.Properties">
<Put name="mail.smtp.host">mail.xyz.com</Put>
</New>
</Set>
</New>
</Arg>
</New>
Here is the error that I am getting when I try to register a user
Failed messages: com.sun.mail.smtp.SMTPSendFailedException: 553 5.5.4 <testuser#localhost>... Real domain name required for sender address
caused by
org.springframework.mail.MailSendException; nested exception details (1) are:
Failed message 1:
com.sun.mail.smtp.SMTPSendFailedException: 553 5.5.4 <testuser#localhost>... Real domain name required for sender address
I added the security.properties file to the conf directory as mentioned here. I then added the properties listed below to the file. The email.from.address property is the answer. These properties can be found in the Redback config-defaults.properties.
email.validation.required=true
email.from.name=Archiva Admin
email.from.address=archivaadmin#xyz.com
email.validation.subject=Archiva Maven Repository

How do I set up Jetty 6 & Jboss 4.0.5 virtual hosting?

I have 2 webapps deployed in the same JBoss/Jetty server. In Jetty 5.1.14 I had the following jetty-web.xml which configured one of the apps to run as a virtual host (on the same port):
<Configure class="org.jboss.jetty.JBossWebApplicationContext">
<Call name="addVirtualHost"><Arg>app2.localhost.com</Arg></Call>
</Configure>
This worked perfectly fine. Unfortunately, it doesn't work with Jetty 6.1.17 at all. First of all, "JBossWebApplicationContext" seems to now be called "JBossWebAppContext", and secondly the documentation I could find suggests that I should be using a jetty-web.xml that looks like this:
<Configure class="org.jboss.jetty.JBossWebAppContext">
<Set name="VirtualHosts">
<Array type="java.lang.String">
<Item>app2.localhost.com</Item>
</Array>
</Set>
</Configure>
But this doesn't work either. The two webapps deploy without error, but when I try to access the 2nd app under the virtual hostname, it just accesses the first app instead. Both applications are in the root context (this is not negotiable).
How can I make virtual hosts work?
(BTW, I had a friend post this on serverfault a few days ago, but nobody answered.)
This syntax works if you include it in the jetty6-web.xml for each web-app.
<Configure class="org.jboss.jetty.JBossWebAppContext">
<Set name="VirtualHosts">
<Array type="java.lang.String">
<Item>host1.domain.com</Item>
<Item>host2.domain.com</Item>
</Array>
</Set>
</Configure>
ALL webapps need the virtual hosts defined if they are running in the same container. For some reason deploying one WAR with virtual hosts and one without doesn't work.