Bob's Notepad

Notes on projects I have done and things I have learned saved for my reference and for the world to share

Monday, January 07, 2008

Doing your own OpenID authentication

OpenID is an open standard for authentication on various, unrelated, websites. There are many providers that will provide you with an OpenID idenity but, in some ways, this defeates the purpose of OpenID since your ID is controlled by a person other than you. Just last night I ran into a situation where I was not able to do something with my ID that I wanted since I was using MyOpenID.com because I am not in control of my idenity page. Thanks to a fit of insomnia I did some research and implemented my own OpenID idenity -- and it was actually a lot easier than I expected.

In order to implemt this you need a website with PHP support. This can be done on any web server whether you are in control of it or not but it is recommended that it be a server you are in control of for obvious security reasons. We will use phpMyID since it is simple and serves the purpose well.

This works well if it has its own domain or subdomain but it really isn't a required thing. The OpenID that I created is http://id.bobkmertz.com. My instructions assume you've created a domain or sub-domain for your OpenID but you can adapt as needed.

First thing, you need to register a domain and point that domain's DNS to your webserver and, of course, configure your webserver. I'm not going to touch on that because if you're doing this you probably should already know how and if not there are plenty of web pages out there that can help you with that.

Now you want to grab phpMyID. The latest version is 0.7 BETA and can be found here.

For me, I have my own server with shell access so I downloaded this directly to my server. This is, by far, the easiest method of implementing this but not everyone has this access so you can download it to your local machine, do the edits and then upload the files to your webserver. If you are uploading keep in mind that when I say editing a file you need to edit it and upload it if your not on the server.

There are 2 files that make up phpMyID. Really, that's it. Your OpenID set up is going to use only 2 php files. Let's get started:

  1. Put both files from the archive into your public_html or www directory
  2. Rename MyID.config.php to index.php
  3. Edit index.php and change "auth_username", "auth_password", and "auth_realm"
    • auth_realm doesn't need to be changed but can be anything you want it to be
    • auth_username is the username you want to authenticate as - this is for your use only
    • auth_password is an encrypted password which you can use OpenSSL to create (echo -n 'username:realm:password' | openssl md5).
      • Make sure you replace username and realm in the command with the same as used in auth_realm and auth_username
      • Windows User? Check here

  4. To use SREG, remove hash (#) marks from the values under the sreg array and replace the values with appropriate information. This allows these fields to be automagically filled in when logging into a site
  5. Save the file
You now have a working OpenID service. But if your OpenID is pointing to your OpenID then it would make sense to have some information about yourself on that page, wouldnt it? The PHP script doesnt allow any easy way of editing your page but it's something that may well be desired. You may ever want to use other Web 2.0 features like a pavatar. Let's make an easy way of doing this.
  1. First, create a file to contain your HTML code. We'll use "id.html" in this example.
  2. In this file you'll want to create your HTML page as you wish. Do not include body or html tags as we're going to leave the headers and such to the PHP script and then just inject this file in the middle.
  3. Open MyID.php in your favorite editor and go to line 1392
  4. Following the function call and the header information you will see some HTML code. Under the body tag we want to add the following:

    ';
    readfile("id.html");
    echo '
    

  5. Now look for the title tags above that. You can change the title to whatever you'd like the name of your OpenID page to be.


You should be all set and have an easier way to edit the information on your OpenID page.

Optionally, you may want to give credit to the author of phpMyID. You can place an HTML link before the close body tag in MyID.php.

Labels: ,

Reference Link


Thursday, January 03, 2008

Pinouts for CAT5 to DTE RS232

If anyone has ever worked with a router or switch from Foundry Networks, then you know how difficult it is to get into the RS232 console port using the standard cables that you usually have available. This is because Foundry is one of the few companies that use a straight through cable rather than the crossed cable that almost everything else uses. Tonight I was working on installing an avocent cyclades CS4016 to connect to the serial consoles on all of our routers. Using the ADB0039 dongles for our Cisco routers worked just fine but the ADB0036 dongles didn't work for our foundry routers and the reason for this is those dongles expect a Yost "flat" RJ45 cable which connects pin 1 to 8, 2 to 7, etc. This is similar to a CAT5 cable except that CAT5 connects pin 1 to 1, 2 to 2, etc. I had access to RS232 DB9 modules so I worked out the pinouts that I needed to use to make an RJ45 to RS232-DTE adaptor using a CAT5 cable rather than the yost flat cable. It's not rocket science but it took a little bit of thought especially when your mind got the interference of too many options for blue, green, etc :)

Anyway, I know that I will need this again so I'm putting it here so I can find it and maybe I'll help someone else out too. These colors are assuming that your DB9 blank modules have the standard Yost coloring.

Standard Yost module on the RJ45 side:

PINColor

1

2

3

4

5

6

7

8


Blue

Orange

Black

Red

Green

Yellow

Brown

White


Essentially all that we are doing is flipping that around. Ultimately we will end up with the following colored cable going into these pins:

DB9 PinRJ45 Color

1

2

3

4

5

6

7

8

9


Brown

Yellow

Black

Orange

Green

-UNUSED-

Blue

White

-UNUSED-

Labels: , , , , , ,

Reference Link