Today we are very excited to announce the availability of the final release of WebSharper Professional (version 2.2.x), the premiere web development framework for F# developers, combining the strengths of functional programming with robust and composable web programming abstractions such as formlets and sitelets that unrival the capabilities of any other web framework. This release follows many long months of hard work and sleepless nights and overall signifies a major new addition to the WebSharper family.
WebSharper Professional delivers a new generation of WebSharper Sitelets functionality that now includes support for authentication, enabling you to compose sitelets with protected content that to be accessed requires users to be authenticated. Defining the authentication process is short and straightforward, and consist of checking the validity of user credentials, and specifying a filter for each "role" of the application. These filters then can be used to protect smaller sitelets that are then combined with other, unprotected counterparts, as shown in the following snippet:
/// The sitelet that corresponds to the entire site.
let EntireSite =
// A simple sitelet for the home page, available at the root of the application.
let home =
Sitelet.Content "/" Action.Home Pages.HomePage
// An automatically inferred sitelet for the basic parts of the application.
let basic =
Sitelet.Infer <| fun action ->
...
// A sitelet for the protected content that requires users to log in first.
let authenticated =
let filter : Sitelet.Filter<Action> =
{
VerifyUser = fun _ -> true
LoginRedirect = Some >> Action.Login
}
Sitelet.Protect filter <|
Sitelet.Content "/protected" Action.Protected Pages.ProtectedPage
// Compose the above sitelets into a larger one.
[
home
authenticated
basic
]
|> Sitelet.Sum
You can find the full change log here.
You can grab the latest binaries from this link. Be sure to uninstall any previous version of WebSharper 2.x. If you have any earlier extensions installed for 2.1, you should remove them and get their new matching versions for 2.2 from the WebSharper Extensions Gallery. If you have any trouble installing or using these new extension releases, let us know on the Community page. Happy coding!
Can’t find what you were looking for? Drop us a line.
20221229 · 30 min read
20211230 · 20 min read