Hi all,
I'm trying to create a Oauth type of authentication application. I have a simple SQL database with a table with columns like uID, uName, uPassword(encrypted) etc. I have a basic interface which contains a text box for username and password and a submit button(I will paste code below).
I so far have the user able to authericate from the database using the interface and this can redirect them to a page. I want to be able to once the user has been authenticated create a token of some sort which I can store to pass round the application to allow them access to other applications.
The purpose of this is I would like to use this token basically like Oauth works and allow access to other applications which I may have linked to this application to save users having to sign in multiple times. The main purpose of this is that we have multiple applications but would like to create a custom home page with applications which will hold icons of applications the users have access too but only need to sign on once(I started looking at single sign on today to no knowledge of that too). Any help would be appreciated.
Public Class _Default Inherits System.Web.UI.Page Public tools As New toolkit Public _js As New mcgCore.clsJavascript Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load End Sub Private Sub cmdLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdLogin.Click Dim t As String = tools.userLogin(Me.txtID.Text, Me.txtPwd.Text) Select Case t Case "Login failed!" _js.AlertPostRender(Me, t, "strKey1") Me.lbForgot.Visible = True If tools.checkEmailAddress(CType(tools.userSelect(Me.txtID.Text), DataTable).Rows(0).Item("uEMAIL")) = True Then Me.lbForgot.Text = Me.GetLocalResourceObject("ForgotPass") Else Me.lbForgot.Text = Me.GetLocalResourceObject("EmailAdmin") End If Case "Login successful!" Session("userID") = Me.txtID.Text Session("termsfile") = tools.userSelect(Me.txtID.Text.Trim).Rows(0).Item("oTERMSFILE") Response.Redirect("launcher.aspx") Case Else _js.AlertPostRender(Me, t, "strKey1") Me.lbForgot.Visible = False End Select End Sub End Class
<%@ Page Title="Home Page" Language="vb" MasterPageFile="~/Site.Master" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="Test_Login._Default" %><asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"></asp:Content><asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"><br /><br /><div align="center"><table border="0" cellpadding="5" bgcolor="WhiteSmoke" style="width: 320px" ><tr><td id="tdlblUserId" runat="server" style="width:42%; " ><asp:Label ID="lblUserId" runat="server" meta:resourcekey="lblUserId" CssClass="TEXTBOX"></asp:Label></td><td id="tdtxtId" runat="server" width="58%"><asp:TextBox ID="txtID" runat="server" CssClass="TEXTBOX"></asp:TextBox></td></tr><tr><td id="tdlblPwd" runat="server"><asp:Label ID="lblPwd" runat="server" meta:resourcekey="lblPwd" CssClass="TEXTBOX"></asp:Label></td><td id="tdtxtPwd" runat="server"><asp:TextBox ID="txtPwd" runat="server" CssClass="TEXTBOX" TextMode="Password"></asp:TextBox></td></tr><tr><td align="right"></td><td id="tdcmdLogin" runat="server"><asp:Button ID="cmdLogin" runat="server" Text="Login" CssClass="BTN" meta:resourcekey="cmdLogin" Width="90px" /></td></tr><tr><td align="right"></td><td align="left"><asp:LinkButton ID="lbForgot" runat="server" Visible="False" CssClass="TEXTBOX"></asp:LinkButton></td></tr><tr align="right"><td id="tdlblTC" runat="server" colspan="2"><p style="font-size:11px"><br /><asp:Label ID="lblTC" runat="server" meta:resourcekey="lblTC"></asp:Label><br /><strong><asp:label ID="lblSupport" runat="server" meta:resourcekey="lblSupport"></asp:label></strong><br /><asp:Label ID="lblContact" runat="server" meta:resourcekey="lblContact"></asp:Label></p></td></tr></table></div><div runat="server" id="footerright" contenteditable="true" align="right"><asp:Label ID="lblCopyright" runat="server" Font-Names="Arial" Font-Size="7pt" ForeColor="#000000"></asp:Label></div></asp:Content>