{"id":22712260,"url":"https://github.com/rasheedaboud/elmishaadb2c","last_synced_at":"2026-04-30T00:04:00.472Z","repository":{"id":130698143,"uuid":"432892221","full_name":"rasheedaboud/ElmishAADB2C","owner":"rasheedaboud","description":"F# SAFE Template using Azure B2C Auth ","archived":false,"fork":false,"pushed_at":"2021-12-02T03:19:43.000Z","size":218,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-29T22:24:39.346Z","etag":null,"topics":["adb2c","authentication","elmish","fsharp","safe"],"latest_commit_sha":null,"homepage":"","language":"CSS","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rasheedaboud.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-11-29T03:24:18.000Z","updated_at":"2021-12-02T03:19:47.000Z","dependencies_parsed_at":"2023-04-23T17:55:14.072Z","dependency_job_id":null,"html_url":"https://github.com/rasheedaboud/ElmishAADB2C","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rasheedaboud/ElmishAADB2C","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rasheedaboud%2FElmishAADB2C","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rasheedaboud%2FElmishAADB2C/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rasheedaboud%2FElmishAADB2C/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rasheedaboud%2FElmishAADB2C/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rasheedaboud","download_url":"https://codeload.github.com/rasheedaboud/ElmishAADB2C/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rasheedaboud%2FElmishAADB2C/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32448883,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T22:27:22.272Z","status":"ssl_error","status_checked_at":"2026-04-29T22:10:49.234Z","response_time":110,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["adb2c","authentication","elmish","fsharp","safe"],"created_at":"2024-12-10T13:09:48.154Z","updated_at":"2026-04-30T00:04:00.458Z","avatar_url":"https://github.com/rasheedaboud.png","language":"CSS","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SAFE Template\n\nThis template can be used to generate a full-stack web application using the [SAFE Stack](https://safe-stack.github.io/). It was created using the dotnet [SAFE Template](https://safe-stack.github.io/docs/template-overview/). If you want to learn more about the template why not start with the [quick start](https://safe-stack.github.io/docs/quickstart/) guide?\n\n## Install pre-requisites\n\nYou'll need to install the following pre-requisites in order to build SAFE applications\n\n* [.NET Core SDK](https://www.microsoft.com/net/download) 5.0 or higher\n* [Node LTS](https://nodejs.org/en/download/)\n\n## Starting the application\n\nBefore you run the project **for the first time only** you must install dotnet \"local tools\" with this command:\n\n```bash\ndotnet tool restore\n```\n\nTo concurrently run the server and the client components in watch mode use the following command:\n\n```bash\ndotnet run\n```\n\nThen open `http://localhost:8080` in your browser.\n\nThe build project in root directory contains a couple of different build targets. You can specify them after `--` (target name is case-insensitive).\n\nTo run concurrently server and client tests in watch mode (you can run this command in parallel to the previous one in new terminal):\n\n```bash\ndotnet run -- RunTests\n```\n\nClient tests are available under `http://localhost:8081` in your browser and server tests are running in watch mode in console.\n\nFinally, there are `Bundle` and `Azure` targets that you can use to package your app and deploy to Azure, respectively:\n\n```bash\ndotnet run -- Bundle\ndotnet run -- Azure\n```\n\n## SAFE Stack Documentation\n\nIf you want to know more about the full Azure Stack and all of it's components (including Azure) visit the official [SAFE documentation](https://safe-stack.github.io/docs/).\n\nYou will find more documentation about the used F# components at the following places:\n\n* [Saturn](https://saturnframework.org/)\n* [Fable](https://fable.io/docs/)\n* [Elmish](https://elmish.github.io/elmish/)\n\n## Updating Sample\nFollow these steps to setup B2C tennant etc. [Docs](https://docs.microsoft.com/en-us/azure/active-directory-b2c/tutorial-create-tenant).  \n\nNavigate to Auth.fs in CLient Project and update AADB2C configuration  \n\n```\nlet msalConfig ={|\n    auth={|\n          clientId=\"\"\n          authority=\"\"\n          knownAuthorities=[|\"\"|]\n          redirectUri= \"https://localhost:8080/\"\n          postLogoutRedirectUri = \"https://localhost:8080/\"|};\n    cache={|cacheLocation=\"sessionStorage\"; storeAuthStateInCookie=false|}\n  |}\n```\n\nNavigate to Server project and update `appsettings.json` \n```\n{\n    //Reanme the AzureAD if you're using AAD\n    \"AzureAdB2C\": {\n        \"Instance\": \"https://\u003cDOMAIN\u003e.b2clogin.com\",\n        \"ClientId\": \"\u003cAPI CLIENT ID\u003e\",\n        \"Domain\": \"\u003cDOMAIN\u003e.onmicrosoft.com\",\n        \"SignUpSignInPolicyId\": \"\", //OMIT IF USING AAD\n        \"ResetPasswordPolicyId\": \"\", //OMIT IF USING AAD\n        \"EditProfilePolicyId\": \"\", //OMIT IF USING AAD\n        \"B2CAppExtentionClientId\": \"\", // If you're using B2C with claims. Leave this out if using AAD\n        \"TenantId\": \"\",\n        \"ClientSecret\": \"\" //USE ONLY IF NEEDED\n    }\n}\n```\n\nFollow instrunctions above to start safe app.\n\nTry logging in.\n\n## Supported Actions\n\nFor this sample only following methods are available on PublicClientApplication\n\n```\n[\u003cImport(\"PublicClientApplication\", from=\"@azure/msal-browser\")\u003e]\ntype PublicClientApplication (config:obj) =\n    abstract member loginRedirect: request:obj -\u003e Promise\u003cunit\u003e;\n    abstract member loginPopup: request:obj -\u003e Promise\u003cAuthenticationResult option\u003e\n    abstract member logout: unit-\u003e unit\n    abstract member getAllAccounts: unit-\u003e account[] \n    abstract member acquireTokenSilent: request:obj -\u003e Promise\u003cAuthenticationResult\u003e;\n    abstract member getAccountByUsername:userName: string -\u003e AccountInfo option\n```\nExtend this as required.\n\nTo show or hide UI when user in authenticated or not use either of the following\n```\nAuthenticatedTemplate.create[\n    AuthenticatedTemplate.children[\n\n    ]\n]\n\nUnauthenticatedTemplate.create[\n    UnauthenticatedTemplate.children[\n\n    ]\n] \n```\n## Claims\n\nIn Auth.fs use type IdTokenClaims to retrive information about response from auth request. Initial model only has minimal claims faimily_name and given_name. Extend this as you see fit.\n```\ntype IdTokenClaims =\n  {\n    aud: string\n    auth_time: string\n    emails: string[]\n    exp: int\n    family_name: string\n    given_name: string\n    iat: int\n    iss: string\n    nbf: int\n    nonce: string\n    sub: string\n    tfp: string\n    ver: string }\n```\n\n## Token\nuse `aquireTokenSilent(request:TokenRequest)` to try and get JWT Token from B2C. This can be used to make authenticated request to server.\n\nuse TokenRequest type to request specific scopes\n```\ntype TokenRequest ={\n  account:AccountInfo\n  scopes:string[]\n  forceRefresh:bool\n}\n```\nAccountInfo can be aquired by calling `getAccountByUsername()` on PublicClientApplication instance.\n\n\n## Hooks\n\nthe following react hook from msal react are supported;  \n\n1. useAccount\n2. useIsAuthenticated\n3. useMsal\n4. useMsalAuthentication\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frasheedaboud%2Felmishaadb2c","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frasheedaboud%2Felmishaadb2c","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frasheedaboud%2Felmishaadb2c/lists"}