Juniper SA 4500, Radiator and two-factor authentication using OTP

December 31st, 2011

The past two weeks I’ve been looking into getting a juniper SA 4500 to work with Radiator to do two-factor authentication by using One-Time Passwords (OTP). Basicly, after user authentication is done against a Directory Server (DS), I want Radiator to lookup the user’s mobile number in the DS, create an One-Time Password and SMS this password to the user’s mobile phone.

Although Radiator can handle OTP, the AuthOTP.pm module that comes with Radiator isn’t sufficient to work directly with the Juniper. This is why I had to make a few changes to the original AuthOTP.pm module. Download the patch here.

In the configuration file below, you see an example on how to use the module.

 
# radius.cfg - Niels van Sluis, <niels@van-sluis.nl>
#
# Example Radiator configuration file.
#
# * retrieve mobile number from Directory Server.
# * generate and send One-Time Password to mobile number.
# * authenticate One-Time Password.
 
LogDir          /var/log/radius
DbDir           /etc/radiator
# User a lower trace level in production systems:
Trace           7
 
AuthPort        1812
AcctPort        1813
 
<Client juni-sslvpn.example.com>
        Secret mysecret
        Identifier juni-sslvpn
</Client>
 
<AuthBy LDAP2>
        # Radiator talks to Microsoft AD.
        # Try to find mobile number only.
        Identifier SSLVPN_LDAP
        Host            ldap.example.com
        BaseDN          OU=employees,DC=example,DC=com
        AuthDN          CN=srv_juniper,OU=Service Accounts,DC=example,DC=com
        AuthPassword    *****
        HoldServerConnection
        Timeout         2
        UsernameAttr    sAMAccountName
 
        # Get attribute that contains the mobile number.
        AuthAttrDef     MobileNumber
 
        # We don't do authentication. Authentication is done by OTP.
        NoCheckPassword
 
        # Some code to put the mobile number into memory, so it can be used
        # by OTP.
        PostSearchHook sub {\
            use Radius::Context;\
 
            my $user = $_[1];\
            my $attr = ($_[4]->get('MobileNumber'))[0];\
 
            my $context = &Radius::Context::get("otp:$user", 120);\
            $context->{mobile_number} = $attr;\
        }
</AuthBy>
 
<AuthBy OTP>
        # Authenticate based on One-Time Password sent to user by SMS.
        Identifier SSLVPN_OTP
        EAPType One-Time-Password,Generic-Token
        ChallengeHook sub {my ($self, $user, $p, $context) = @_;\
                $context->{otp_password} = $self->generate_password();\
                system('/etc/radiator/otp/sendsms.php', $user, $context->{mobile_number}, $context->{otp_password});\
                return "Enter One-Time Password"; \
            }
</AuthBy>
 
<AuthBy GROUP>
        Identifier Check-LDAP-and-OTP
        AuthByPolicy ContinueWhileAccept
        AuthBy SSLVPN_LDAP
        AuthBy SSLVPN_OTP
</AuthBY>
 
<Handler Client-Identifier = juni-sslvpn>
        RejectHasReason
        AuthBy Check-LDAP-and-OTP
</Handler>

Click here to download radius.cfg

Configure the Juniper SA 4500

Configuring two-factor authentication on the Juniper is really easy. When creating an user realm, you can choose to use an additional authentication server. So I configured two authentication servers. The first one authenticates against the Directory Server. The second authentication server uses radius to authenticate against Radiator. It will prompt the user to enter the One-Time Password.

Configure the additional Authentication Server

Create a new authentication server that uses RADIUS. Most important here are the ‘Custom Radius Rules’.
auth_server

Custom Radius Rules

The custom radius rules define how the Juniper talks with Radiator.

Rule 1

Here we define that the Juniper expects a challenge from Radiator and makes sure the user will be prompted with a page where he can enter the password that was send to the user’s mobile phone.
radius_rule_1

Rule 2

This rule defines what to do if the password entered by the user is rejected by Radiator. It will show the reason why the password was rejected.
radius_rule_2

Configure an User-Realm

The screen below shows how easy it is to create an user realm that uses an additional authentication server. Make sure the session is ended when authentication to the additional authentication server fails.
user_realm

Well, I hope this document will save you some time and money in setting up two-factor authentication on the Juniper SA 4500. Enjoy ;-)

Your Photos on a Diet!

August 27th, 2011

A couple of days ago I read an interesting article about JPEGmini on PetaPixel. JPEGmini is a new image compression service that can magically reduce the file size of your JPEG photos by up to 5 times without any visible loss in quality. Today, before uploading a new photo to my photoblog I decided to give this new service a try.

After post-processing the image, I exported it into the highest quality JPEG format at a resolution of 1800×1200 pixels. The image that came out was about 916kb. After uploading it to JPEGmini the size of this image was reduced to only 134kb. So, it has been reduced 6.8 times. And yes, without any visible loss in quality. Amazing huh? :-)

JPEGmini

The file size of the final image has always been something I took notice off, because the template I use on my photoblog requires much higher resolution images than most other templates do. Normaly I would try to keep the image size under 350kb in order to keep image loading quickly. But with use of JPEGmini it seems that I’m now able to deliver higher quality images that are loaded even faster. Cool! 8)

Piepende multiriem Peugeot 307 SW 1.6

August 23rd, 2011

Twee weken geleden schreef ik hier over het vervangen van de multiriem van mijn Peugeot 307 SW 1.6. Ik was in de verwachting dat ik alle problemen had opgelost en weer zorgeloos flink wat kilometers kon rijden. Helaas was dit niet het geval. Telkens tijdens een koude start, kwam er kortstondig een zeer hard piepend geluid onder de moterkap vandaan. Mijn eerste ingeving was dat dit te wijten was aan een slippende multiriem. Wat valt hier aan te doen?

Op diverse internet fora wordt geschreven dat je WD 40 of zelfs kaarsvet kunt gebruiken om van het piepen af te komen. Dit leek mij een eenvoudige oplossing. Dus ik naar de Brezan en zo’n busje WD 40 gekocht en hier en daar wat op de poelies en snaar gespoten. Echter zonder resultaat.

Later heb ik hier een monteur naar laten kijken en zijn eerste vraag was: “Waarom heb je er WD 40 op gespoten?”. Volgens hem was dit niet zo’n slim idee. Als je wilt dat de multiriem een betere grip heeft op de poelies, dan kan je deze beter ontvetten. Je kan er remreiniger op spuiten. En dat deed hij. Nu maar wachten of het probleem opgelost is.

De volgende ochtend tijdens de koude start – jawel – wederom piepende geluiden die de buren wakker maken. Misschien was er niet voldoende ontvet? Dus ik bij de Halfords zelf een bus remreiniger gehaald om vervolgens de multiriem te demonteren en alle poelies eens goed te reinigen. Zelfs krukaspoelie er afgehaald en met behulp van een oude tandenborstel en remreiniger flinkt ontvet.

Helaas mocht dit niet baten. Wat zou het dan kunnen zijn? Verkeerde maat multiriem? De automatische spanner die niet voldoende aanspant? Na weer flink wat googlen kwam ik erachter dat de krukaspoelie van mijn auto bestaat uit twee delen: Een binnen- en buitenzijde met daar tussen een rubbere ring. Als de poelie kapot is, dan kunnen deze twee delen onafhankelijk van elkaar gaan bewegen en ontstaat er ook een piepend geluid. Om te controleren of de krukaspoelie kapot is, kun je heel eenvoudig met wat krijt streepjes zetten op de krukaspoelie. Vervolgens ga je een eindje rijden. Als daarna blijkt dat de streepjes geen rechte lijn meer vormen, is de krukaspoelie stuk.

Krukaspoelie controleren

Op de foto kun je zien hoe ik zorgvuldig de krijt lijntjes heb aangebracht. Dus ik de motor gestart en gewacht tot het piepende geluid niet meer hoorbaar was. Echter, ik zag niet direct een verschil. Je moet echt wel een stukje rijden om er zeker van te zijn dat deze kapot is. En ja hoor, dat was ie. Zie de foto hieronder. :-(

Krukaspoelie blijkt defect

Vervolgens was de oplossing simpel. Oude krukaspoelie vervangen door een hagel nieuwe. Deze heb ik bij Imbema gehaald voor 65 euro.

krukaspoelie_nieuw

Al met al zijn het een paar leerzame weken geweest. Eigenlijk is het ook wel logisch dat juist de krukaspoelie kapot is gegaan. Zeker als je bedenkt dat deze uit twee delen bestaat en dat deze krukaspoelie vier weken eerder door een monteur verkeerd om is teruggezet. Dan komen de krachten die er op spelen van de tegengestelde richting.


 
Mmmzoo even een linux kernel compileren. Dat is lang geleden...