Basic authentication

Introduction

This example shows how shows how to implement basic authentication with an Iguana channel.

We  authenticate users against the Iguana user database, but you could modify this to use a different authentication method.

If you have any questions please contact us at support@interfaceware.com.

Using the Code [top]

  • Import the Basic authentication channel from the Builtin: Iguana Webservices repository
  • Experiment with the code to find out how it works
  • Then add the module to your Translator project
  • Copy the require statement from the channel and add it at the top of your script
    Note: This module uses require to return a table
  • Adapt the code to your own requirements
  • Interactive scripting help is included for this module

This is the github code for the main module:

How it works [top]

  • We use net.http.parseRequest{} to parse the incoming HTTP get request
  • We use net.http.isAuthorized{} to check authorization for the incoming request
  • If authorization fails we use basicauth.requireAuthorization() to ask the user to re-enter their login credentials
  • We use net.http.getCredentials() to  extract credentials from the incoming request
  • And finally we use net.http.respond to tell the user they have been successfully authenticated

More information [top]

Leave A Comment?

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.