Skip to content

mjarosie/FableBrowserClientOpenIdConnect

Repository files navigation

Fable App with OpenId Connect authentication

This repository reproduces the exact effect achieved by following the "Adding a JavaScript client" tutorial of IdentityServer4, but in F#. It also shows how to use the Fable.OidcClient package. Here's a post explaining the client configuration and code step by step.

Requirements

Building and running the app

You might need to accept the risk of invalid local certificate in your browser.

Project structure

F#

The solution consists of 4 projects:

  • Api: Saturn framework web server that returns the user identity when called under /identity, works exactly the same as the API defined in "Protecting an API using Client Credentials tutorial of IdentityServer4.
  • IdentityServer: Identity Provider service, works exactly the same as the Identity Provider defined in "Protecting an API using Client Credentials tutorial of IdentityServer4.
  • Client directory contains these two projects:
    • App: Main logic of the SPA (single page application)
    • Auth: Small bit of code needed for handling the OpenId Protocol redirection.

npm

JS dependencies are declared in package.json, while package-lock.json is a lock file automatically generated.

Webpack

Webpack is a JS bundler with extensions, like a static dev server that enables hot reloading on code changes. Fable interacts with Webpack through the fable-loader. Configuration for Webpack is defined in the webpack.config.js file. Note this sample only includes basic Webpack configuration for development mode, if you want to see a more comprehensive configuration check the Fable webpack-config-template.

This configuration produces two separate outputs:

  • app - main code of the SPA (single page application)
  • auth - small bit of code needed for handling the OpenId Protocol redirection.

Web assets

Assets like html pages or an icon can be found in the public folder. The index.html file wraps the application (uses the code from src/Client/App), callback.html is used for handling the OpenId Protocol redirection (uses the code from src/Client/Auth).

About

Demo app using the Fable.OidcClient library and reproducing the IdentityServer4 JavaScript tutorial.

Resources

Stars

Watchers

Forks