Owin.Security.CAS is an OWIN authentication provider for CAS
Too much on your plate to read through documentation? Need to get CAS authentication added to your MVC solution now? Here's what you need to do.
-
Install the NuGet package
PM> install-package Owin.Security.CAS
-
Open App_Start/Startup.Auth.cs
-
Add
using Owin.Security.CAS;
to the end of theusing
statements -
Paste the following code below the
// Uncomment the following lines to enable logging in with third party login providers
lineCasAuthenticationOptions casOptions = new CasAuthenticationOptions() { CasServerUrlBase = "https://your.cas.server.com/cas" }; app.UseCasAuthentication(casOptions);
-
DONE!
PM> install-package Owin.Security.CAS
Using zip file
- Download the zip file by clicking on the Download Zip File button on the project home page on GitHub
- Extract the zipped files. An Owin.Security.CAS-master folder will be created.
- In Visual Studio, right click on your solution and select Add > Existing Project. The Add Existing Project window will appear
- Navigate to Owin.Security.CAS > Owin.Security.CAS.csproj and click Open. The project will now be in your solution.
- Make your project dependenent on Owin.Security.CAS so that any updates you download and unzip in the Owin.Security.CAS-master folder will cause the dll to be recompiled
- Selecting Project > Project Dependencies from the Visual Studio menu. The Project Dependencies window will appear.
- Select the Dependencies tab
- Select your project from the Projects dropdown
- Check Owin.Security.CAS in the Depends on area
- Click OK
- Add a reference to the Owin.Security.CAS project so that it can be used in your code
- In the References section of your solution, right-click and select Add Reference.... The Reference Manager window willl appear.
- Select Solution > Projects
- Check the box for Owin.Security.CAS
- Select OK
- You should now see Owin.Security.CAS under References
CAS authentication is enabled by calling app.UseCasAuthentication();
in the ConfigureAuth()
method in App_Start/Startup.Auth.cs. UseCasAuthentication()
takes a CasAuthenticationOptions
object that contains configuration options needed for connecting to your CAS server. At a minmum, the CasAuthenticationOptions
object needs to have the CasServerUrlBase
property set to the URL to your CAS server.
See the Examples section for some sample imlementations
AuthenticationMode
AuthenticationType
- String that appears in the button, and that is used for dbo.AspNetUserLogins.LoginProvider in the DB. Default:CAS
BackchannelHttpHandler
BackchannelTimeout
CallbackPath
Caption
- String that will replace "CAS" in the tool tip of the button. Default:CAS
CasServerUrlBase
- String containing the URL to your CAS serverDescription
NameClaimType
NameIdentifierAttribute
Provider
SignInAsAuthenticationType
StateDataFormat
TicketValidator
Equals()
GetHashCode()
GetType()
ToString()
This example is based on the default ASP.NET Web Application - MVC template, using Individual User Accounts Authentication.
Open App_Start/Startu.Auth.cs and make the following modifications
- Add
using Owin.Security.CAS;
- Add the following code below the
// Uncomment the following lines to enable logging in with third party login providers
section
CasAuthenticationOptions casOptions = new CasAuthenticationOptions()
{
AuthenticationType = "Net ID", // change "CAS" to "Net ID" on the button and in DB
Caption = "Net ID", // change "CAS" to "Net ID" in tool tip
CasServerUrlBase = "https://cas-dev.tamu.edu/cas"
};
app.UseCasAuthentication(casOptions);