├── .github ├── CODEOWNERS ├── ISSUE_TEMPLATE │ ├── Bug Report.yml │ ├── Feature Request.yml │ └── config.yml ├── PULL_REQUEST_TEMPLATE.md ├── actions │ ├── get-prerelease │ │ └── action.yml │ ├── get-release-notes │ │ └── action.yml │ ├── get-version │ │ └── action.yml │ ├── nuget-publish │ │ └── action.yml │ ├── nuget-release │ │ └── action.yml │ ├── release-create │ │ └── action.yml │ ├── rl-scanner │ │ └── action.yml │ └── tag-exists │ │ └── action.yml ├── stale.yml └── workflows │ ├── build.yml │ ├── nuget-release.yml │ ├── release.yml │ ├── rl-secure.yml │ ├── semgrep.yml │ └── snyk.yml ├── .gitignore ├── .semgrepignore ├── .snyk ├── Auth0.OidcClient.All.sln ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── build ├── Auth0Icon.png └── Auth0OidcClientStrongName.snk ├── docs-source ├── .gitignore ├── .vscode │ └── settings.json ├── api │ ├── .gitignore │ ├── .manifest │ └── index.md ├── custom-template │ └── public │ │ └── main.css ├── docfx.json ├── documentation │ ├── advanced-scenarios │ │ ├── api-authorization.md │ │ ├── browsers.md │ │ ├── refresh-tokens.md │ │ └── scopes.md │ ├── getting-started │ │ ├── authentication.md │ │ ├── callbacks.md │ │ └── installation.md │ ├── intro.md │ ├── migration │ │ ├── v2.md │ │ └── v3.md │ ├── samples.md │ └── toc.yml ├── filter.yml ├── images │ ├── dashboard-domain.png │ └── logo.png ├── index.md └── toc.yml ├── global.json ├── nuget ├── Auth0.OidcClient.Android.nuspec ├── Auth0.OidcClient.AndroidX.nuspec ├── Auth0.OidcClient.Core.nuspec ├── Auth0.OidcClient.MAUI.nuspec ├── Auth0.OidcClient.UWP.nuspec ├── Auth0.OidcClient.WPF.nuspec ├── Auth0.OidcClient.WinForms.nuspec └── Auth0.OidcClient.iOS.nuspec ├── opslevel.yml ├── src ├── Auth0.OidcClient.Android │ ├── .shiprc │ ├── .version │ ├── ActivityMediator.cs │ ├── AndroidBrowserBase.cs │ ├── Auth0.OidcClient.Android.csproj │ ├── Auth0Client.cs │ ├── Auth0ClientActivity.cs │ ├── AutoSelectBrowser.cs │ ├── ChromeCustomTabsBrowser.cs │ ├── Resources │ │ └── Resource.Designer.cs │ ├── SystemBrowser.cs │ └── docs-source │ │ ├── docfx.json │ │ ├── docfx.local.json │ │ ├── filter.yml │ │ ├── images │ │ └── logo.png │ │ └── toc.yml ├── Auth0.OidcClient.AndroidX │ ├── .shiprc │ ├── .version │ ├── Auth0.OidcClient.AndroidX.csproj │ └── Resources │ │ └── Resource.Designer.cs ├── Auth0.OidcClient.Core │ ├── .shiprc │ ├── .version │ ├── AssemblyInfo.cs │ ├── Auth0.OidcClient.Core.csproj │ ├── Auth0ClientBase.cs │ ├── Auth0ClientOptions.cs │ ├── IAuth0Client.cs │ └── Tokens │ │ ├── AsymmetricSignatureVerifier.cs │ │ ├── Auth0ClaimNames.cs │ │ ├── ISignatureVerifier.cs │ │ ├── IdTokenRequirements.cs │ │ ├── IdTokenValidationException.cs │ │ ├── IdTokenValidator.cs │ │ └── JsonWebKeys.cs ├── Auth0.OidcClient.MAUI.Platforms.Windows │ ├── Activator.cs │ ├── AppActivationArguments.cs │ ├── AppInstanceProxy.cs │ ├── Auth0.OidcClient.MAUI.Platforms.Windows.csproj │ ├── Helpers.cs │ ├── RedirectionContext.cs │ ├── RedirectionContextManager.cs │ ├── StateModifier.cs │ ├── TasksManager.cs │ ├── WebAuthenticator.cs │ └── WebAuthenticatorResult.cs ├── Auth0.OidcClient.MAUI │ ├── .shiprc │ ├── .version │ ├── Auth0.OidcClient.MAUI.csproj │ ├── Auth0Client.cs │ ├── README.md │ ├── WebAuthenticatorBrowser.cs │ └── docs-source │ │ ├── docfx.json │ │ ├── docfx.local.json │ │ ├── filter.yml │ │ ├── images │ │ └── logo.png │ │ └── toc.yml ├── Auth0.OidcClient.UWP │ ├── .shiprc │ ├── .version │ ├── Auth0.OidcClient.UWP.csproj │ ├── Auth0Client.cs │ ├── Properties │ │ └── Auth0.OidcClient.UWP.rd.xml │ ├── WebAuthenticationBrokerBrowser.cs │ ├── WebViewBrowser.cs │ └── docs-source │ │ ├── docfx.json │ │ ├── docfx.local.json │ │ ├── images │ │ └── logo.png │ │ └── toc.yml ├── Auth0.OidcClient.WPF │ ├── .shiprc │ ├── .version │ ├── Auth0.OidcClient.WPF.csproj │ ├── Auth0Client.cs │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ ├── Resources.resx │ │ ├── Settings.Designer.cs │ │ └── Settings.settings │ ├── Themes │ │ └── Generic.xaml │ ├── WebBrowserBrowser.cs │ ├── WebViewBrowser.cs │ └── docs-source │ │ ├── docfx.json │ │ ├── docfx.local.json │ │ ├── images │ │ └── logo.png │ │ └── toc.yml ├── Auth0.OidcClient.WinForms │ ├── .shiprc │ ├── .version │ ├── Auth0.OidcClient.WinForms.csproj │ ├── Auth0Client.cs │ ├── ExtendedWebBrowser.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── WebBrowserBrowser.cs │ ├── WebViewBrowser.cs │ ├── app.manifest │ └── docs-source │ │ ├── docfx.json │ │ ├── docfx.local.json │ │ ├── images │ │ └── logo.png │ │ └── toc.yml └── Auth0.OidcClient.iOS │ ├── .shiprc │ ├── .version │ ├── ASWebAuthenticationSessionBrowser.cs │ ├── ASWebAuthenticationSessionOptions.cs │ ├── ActivityMediator.cs │ ├── Auth0.OidcClient.iOS.csproj │ ├── Auth0Client.cs │ ├── AutoSelectBrowser.cs │ ├── SFAuthenticationSessionBrowser.cs │ ├── SFSafariViewControllerBrowser.cs │ ├── docs-source │ ├── docfx.json │ ├── docfx.local.json │ ├── images │ │ └── logo.png │ └── toc.yml │ └── iOSBrowserBase.cs ├── test ├── Android │ ├── Android.csproj │ ├── MainActivity.cs │ ├── Properties │ │ ├── AndroidManifest.xml │ │ └── AssemblyInfo.cs │ ├── Resources │ │ ├── Resource.Designer.cs │ │ ├── drawable │ │ │ └── Icon.png │ │ ├── layout │ │ │ └── Main.axml │ │ └── values │ │ │ └── Strings.xml │ └── app.config ├── Auth0.OidcClient.Core.UnitTests │ ├── Auth0.OidcClient.Core.UnitTests.csproj │ └── Tokens │ │ ├── IdTokenValidatorTests.cs │ │ ├── JwtTokenFactory.cs │ │ └── NoSignatureVerifier.cs ├── Auth0.OidcClient.MAUI.Platforms.Windows.UnitTests │ ├── Auth0.OidcClient.MAUI.Platforms.Windows.UnitTests.csproj │ ├── GlobalUsings.cs │ ├── RedirectionContextManagerTests.cs │ ├── StateModifiedTests.cs │ ├── TasksManagerTests.cs │ └── WebAuthenticatorTests.cs ├── UWP │ ├── App.xaml │ ├── App.xaml.cs │ ├── Assets │ │ ├── LockScreenLogo.scale-200.png │ │ ├── SplashScreen.scale-200.png │ │ ├── Square150x150Logo.scale-200.png │ │ ├── Square44x44Logo.scale-200.png │ │ ├── Square44x44Logo.targetsize-24_altform-unplated.png │ │ ├── StoreLogo.png │ │ └── Wide310x150Logo.scale-200.png │ ├── MainPage.xaml │ ├── MainPage.xaml.cs │ ├── Package.appxmanifest │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ └── Default.rd.xml │ ├── UWP.csproj │ ├── UWP_TemporaryKey.pfx │ └── project.json ├── WPF │ ├── App.config │ ├── App.xaml │ ├── App.xaml.cs │ ├── MainWindow.xaml │ ├── MainWindow.xaml.cs │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ ├── Resources.resx │ │ ├── Settings.Designer.cs │ │ └── Settings.settings │ └── WPF.csproj ├── WinForms │ ├── App.config │ ├── MainForm.Designer.cs │ ├── MainForm.cs │ ├── MainForm.resx │ ├── Program.cs │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ ├── Resources.resx │ │ ├── Settings.Designer.cs │ │ └── Settings.settings │ └── WinForms.csproj └── iOS │ ├── AppDelegate.cs │ ├── Entitlements.plist │ ├── Info.plist │ ├── Main.cs │ ├── Main.storyboard │ ├── Media.xcassets │ ├── AppIcons.appiconset │ │ └── Contents.json │ └── LaunchImages.launchimage │ │ └── Contents.json │ ├── MyViewController.cs │ ├── MyViewController.designer.cs │ ├── MyViewController.storyboard │ ├── Properties │ └── AssemblyInfo.cs │ ├── Resources │ └── LaunchScreen.xib │ └── iOS.csproj └── tools ├── build-docs-local.sh └── build-docs.sh /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @auth0/project-dx-sdks-engineer-codeowner 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/Bug Report.yml: -------------------------------------------------------------------------------- 1 | name: 🐞 Report a bug 2 | description: Have you found a bug or issue? Create a bug report for this library 3 | labels: ["bug"] 4 | 5 | body: 6 | - type: markdown 7 | attributes: 8 | value: | 9 | **Please do not report security vulnerabilities here**. The [Responsible Disclosure Program](https://auth0.com/responsible-disclosure-policy) details the procedure for disclosing security issues. 10 | 11 | - type: checkboxes 12 | id: checklist 13 | attributes: 14 | label: Checklist 15 | options: 16 | - label: I have looked into the [Readme](https://github.com/auth0/auth0-oidc-client-net#readme) and the [documentation](https://auth0.github.io/auth0-oidc-client-net/documentation/intro.html), and have not found a suitable solution or answer. 17 | required: true 18 | - label: I have looked into the [API documentation](https://auth0.github.io/auth0-oidc-client-net/api/Auth0.OidcClient.html) and have not found a suitable solution or answer. 19 | required: true 20 | - label: I have searched the [issues](https://github.com/auth0/auth0-oidc-client-net/issues) and have not found a suitable solution or answer. 21 | required: true 22 | - label: I have searched the [Auth0 Community](https://community.auth0.com) forums and have not found a suitable solution or answer. 23 | required: true 24 | - label: I agree to the terms within the [Auth0 Code of Conduct](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md). 25 | required: true 26 | 27 | - type: textarea 28 | id: description 29 | attributes: 30 | label: Description 31 | description: Provide a clear and concise description of the issue, including what you expected to happen. 32 | validations: 33 | required: true 34 | 35 | - type: textarea 36 | id: reproduction 37 | attributes: 38 | label: Reproduction 39 | description: Detail the steps taken to reproduce this error, and whether this issue can be reproduced consistently or if it is intermittent. 40 | placeholder: | 41 | 1. Step 1... 42 | 2. Step 2... 43 | 3. ... 44 | validations: 45 | required: true 46 | 47 | - type: textarea 48 | id: additional-context 49 | attributes: 50 | label: Additional context 51 | description: Other libraries that might be involved, or any other relevant information you think would be useful. 52 | validations: 53 | required: false 54 | 55 | - type: input 56 | id: environment-version 57 | attributes: 58 | label: auth0-oidc-client-net version 59 | validations: 60 | required: true 61 | 62 | - type: input 63 | id: environment-dotnet-version 64 | attributes: 65 | label: .NET version 66 | validations: 67 | required: true 68 | 69 | - type: dropdown 70 | id: environment-platform 71 | attributes: 72 | label: Platform 73 | multiple: true 74 | options: 75 | - Android 76 | - iOS 77 | - Windows 78 | validations: 79 | required: true 80 | 81 | - type: input 82 | id: environment-platform-version 83 | attributes: 84 | label: Platform version(s) 85 | validations: 86 | required: true 87 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/Feature Request.yml: -------------------------------------------------------------------------------- 1 | name: 🧩 Feature request 2 | description: Suggest an idea or a feature for this library 3 | labels: ["feature request"] 4 | 5 | body: 6 | - type: checkboxes 7 | id: checklist 8 | attributes: 9 | label: Checklist 10 | options: 11 | - label: I have looked into the [Readme](https://github.com/auth0/auth0-oidc-client-net#readme) and the [documentation](https://auth0.github.io/auth0-oidc-client-net/documentation/intro.html), and have not found a suitable solution or answer. 12 | required: true 13 | - label: I have looked into the [API documentation](https://auth0.github.io/auth0-oidc-client-net/api/Auth0.OidcClient.html) and have not found a suitable solution or answer. 14 | required: true 15 | - label: I have searched the [issues](https://github.com/auth0/auth0-oidc-client-net/issues) and have not found a suitable solution or answer. 16 | required: true 17 | - label: I have searched the [Auth0 Community](https://community.auth0.com) forums and have not found a suitable solution or answer. 18 | required: true 19 | - label: I agree to the terms within the [Auth0 Code of Conduct](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md). 20 | required: true 21 | 22 | - type: textarea 23 | id: description 24 | attributes: 25 | label: Describe the problem you'd like to have solved 26 | description: A clear and concise description of what the problem is. 27 | placeholder: I'm always frustrated when... 28 | validations: 29 | required: true 30 | 31 | - type: textarea 32 | id: ideal-solution 33 | attributes: 34 | label: Describe the ideal solution 35 | description: A clear and concise description of what you want to happen. 36 | validations: 37 | required: true 38 | 39 | - type: textarea 40 | id: alternatives-and-workarounds 41 | attributes: 42 | label: Alternatives and current workarounds 43 | description: A clear and concise description of any alternatives you've considered or any workarounds that are currently in place. 44 | validations: 45 | required: false 46 | 47 | - type: textarea 48 | id: additional-context 49 | attributes: 50 | label: Additional context 51 | description: Add any other context or screenshots about the feature request here. 52 | validations: 53 | required: false 54 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Auth0 Community 4 | url: https://community.auth0.com 5 | about: Discuss this SDK in the Auth0 Community forums 6 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### Changes 2 | 3 | Please describe both what is changing and why this is important. Include: 4 | 5 | - Endpoints added, deleted, deprecated, or changed 6 | - Classes and methods added, deleted, deprecated, or changed 7 | - Screenshots of new or changed UI, if applicable 8 | - A summary of usage if this is a new feature or change to a public API (this should also be added to relevant documentation once released) 9 | - Any alternative designs or approaches considered 10 | 11 | ### References 12 | 13 | Please include relevant links supporting this change such as a: 14 | 15 | - support ticket 16 | - community post 17 | - StackOverflow post 18 | - support forum thread 19 | 20 | ### Testing 21 | 22 | Please describe how this can be tested by reviewers. Be specific about anything not tested and reasons why. If this library has unit and/or integration testing, tests should be added for new functionality and existing tests should complete without errors. 23 | 24 | - [ ] This change adds unit test coverage 25 | - [ ] This change adds integration test coverage 26 | - [ ] This change has been tested on the latest version of the platform/language or why not 27 | 28 | ### Checklist 29 | 30 | - [ ] I have read the [Auth0 general contribution guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md) 31 | - [ ] I have read the [Auth0 Code of Conduct](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md) 32 | - [ ] All existing and new tests complete without errors 33 | - [ ] All code guidelines in the [CONTRIBUTING documentation](../CONTRIBUTING.md) have been run/followed 34 | -------------------------------------------------------------------------------- /.github/actions/get-prerelease/action.yml: -------------------------------------------------------------------------------- 1 | name: Return a boolean indicating if the version contains prerelease identifiers 2 | 3 | # 4 | # Returns a simple true/false boolean indicating whether the version indicates it's a prerelease or not. 5 | # 6 | # TODO: Remove once the common repo is public. 7 | # 8 | 9 | inputs: 10 | version: 11 | required: true 12 | 13 | outputs: 14 | prerelease: 15 | value: ${{ steps.get_prerelease.outputs.PRERELEASE }} 16 | 17 | runs: 18 | using: composite 19 | 20 | steps: 21 | - id: get_prerelease 22 | shell: bash 23 | run: | 24 | if [[ "${VERSION}" == *"beta"* || "${VERSION}" == *"alpha"* ]]; then 25 | echo "PRERELEASE=true" >> $GITHUB_OUTPUT 26 | else 27 | echo "PRERELEASE=false" >> $GITHUB_OUTPUT 28 | fi 29 | env: 30 | VERSION: ${{ inputs.version }} 31 | -------------------------------------------------------------------------------- /.github/actions/get-release-notes/action.yml: -------------------------------------------------------------------------------- 1 | name: Return the release notes extracted from the PR body 2 | 3 | # 4 | # Returns the release notes from the content of a pull request linked to a release branch. It expects the branch name to be in the format release/vX.Y.Z, release/X.Y.Z, release/vX.Y.Z-beta.N. etc. 5 | # 6 | # TODO: Remove once the common repo is public. 7 | # 8 | inputs: 9 | version: 10 | required: true 11 | repo_name: 12 | required: false 13 | repo_owner: 14 | required: true 15 | token: 16 | required: true 17 | 18 | outputs: 19 | release-notes: 20 | value: ${{ steps.get_release_notes.outputs.RELEASE_NOTES }} 21 | 22 | runs: 23 | using: composite 24 | 25 | steps: 26 | - uses: actions/github-script@v7 27 | id: get_release_notes 28 | with: 29 | result-encoding: string 30 | script: | 31 | const { data: pulls } = await github.rest.pulls.list({ 32 | owner: process.env.REPO_OWNER, 33 | repo: process.env.REPO_NAME, 34 | state: 'all', 35 | head: `${process.env.REPO_OWNER}:release/${process.env.VERSION}`, 36 | }); 37 | core.setOutput('RELEASE_NOTES', pulls[0] ? pulls[0].body : ''); 38 | env: 39 | GITHUB_TOKEN: ${{ inputs.token }} 40 | REPO_OWNER: ${{ inputs.repo_owner }} 41 | REPO_NAME: ${{ inputs.repo_name }} 42 | VERSION: ${{ inputs.version }} 43 | -------------------------------------------------------------------------------- /.github/actions/get-version/action.yml: -------------------------------------------------------------------------------- 1 | name: Return the version extracted from the branch name 2 | 3 | # 4 | # Returns the version from the .version file. 5 | # 6 | # TODO: Remove once the common repo is public. 7 | # 8 | 9 | inputs: 10 | working-directory: 11 | default: './' 12 | 13 | outputs: 14 | version: 15 | value: ${{ steps.get_version.outputs.VERSION }} 16 | 17 | runs: 18 | using: composite 19 | 20 | steps: 21 | - id: get_version 22 | shell: bash 23 | working-directory: ${{ inputs.working-directory }} 24 | run: | 25 | VERSION=$(head -1 .version) 26 | echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT 27 | -------------------------------------------------------------------------------- /.github/actions/nuget-publish/action.yml: -------------------------------------------------------------------------------- 1 | name: Publish release to NuGet 2 | 3 | inputs: 4 | dotnet-version: 5 | required: true 6 | nuget-token: 7 | required: true 8 | project-path: 9 | required: true 10 | nuget-directory: 11 | required: true 12 | nuspec-file: 13 | required: true 14 | 15 | runs: 16 | using: composite 17 | steps: 18 | - name: Setup .NET 19 | uses: actions/setup-dotnet@v3 20 | with: 21 | dotnet-version: ${{ inputs.dotnet-version }} 22 | 23 | - name: Setup NuGet 24 | uses: nuget/setup-nuget@v1 25 | 26 | - name: Create NuGet packages 27 | shell: pwsh 28 | run: nuget pack ${{ inputs.nuspec-file }} -OutputDirectory ${{ inputs.nuget-directory }} 29 | 30 | - name: Publish NuGet packages 31 | shell: pwsh 32 | run: | 33 | foreach($file in (Get-ChildItem "${{ inputs.nuget-directory }}" -Recurse -Include *.nupkg)) { 34 | nuget push $file -ApiKey "${{ inputs.nuget-token }}" -Source https://api.nuget.org/v3/index.json -SkipDuplicate -NonInteractive 35 | } 36 | -------------------------------------------------------------------------------- /.github/actions/nuget-release/action.yml: -------------------------------------------------------------------------------- 1 | name: Create NuGet and GitHub Release 2 | 3 | 4 | ### TODO: Replace instances of './.github/actions/' w/ `auth0/dx-sdk-actions` and append `@latest` after the common `dx-sdk-actions` repo is made public. 5 | ### DO NOT replace nuget-publish, but keep the local version as it is slightly different as opposed to the one in auth0/dx-sdk-actions to support the mono repository structure. 6 | 7 | inputs: 8 | dotnet-version: 9 | required: true 10 | nuget-token: 11 | required: true 12 | github-token: 13 | required: true 14 | project-path: 15 | required: true 16 | nuget-directory: 17 | required: true 18 | nuspec-file: 19 | required: true 20 | tag-prefix: 21 | default: '' 22 | 23 | runs: 24 | using: composite 25 | steps: 26 | # Get the version from the branch name 27 | - id: get_version 28 | uses: ./.github/actions/get-version 29 | with: 30 | working-directory: ${{ inputs.project-path }} 31 | 32 | # Get the prerelease flag from the branch name 33 | - id: get_prerelease 34 | uses: ./.github/actions/get-prerelease 35 | with: 36 | version: ${{ steps.get_version.outputs.version }} 37 | 38 | # Get the release notes 39 | - id: get_release_notes 40 | uses: ./.github/actions/get-release-notes 41 | with: 42 | token: ${{ inputs.github-token }} 43 | version: ${{ inputs.tag-prefix }}${{ steps.get_version.outputs.version }} 44 | repo_owner: ${{ github.repository_owner }} 45 | repo_name: ${{ github.event.repository.name }} 46 | 47 | # Check if the tag already exists 48 | - id: tag_exists 49 | uses: ./.github/actions/tag-exists 50 | with: 51 | tag: ${{ inputs.tag-prefix }}${{ steps.get_version.outputs.version }} 52 | token: ${{ inputs.github-token }} 53 | 54 | # Publish the release to our package manager 55 | - uses: ./.github/actions/nuget-publish 56 | if: steps.tag_exists.outputs.exists == 'false' 57 | with: 58 | dotnet-version: ${{ inputs.dotnet-version }} 59 | project-path: ${{ inputs.project-path }} 60 | nuget-token: ${{ inputs.nuget-token }} 61 | nuget-directory: ${{ inputs.nuget-directory }} 62 | nuspec-file: ${{ inputs.nuspec-file }} 63 | 64 | # Create a release for the tag 65 | - uses: ./.github/actions/release-create 66 | if: steps.tag_exists.outputs.exists == 'false' 67 | with: 68 | token: ${{ inputs.github-token }} 69 | name: ${{ inputs.tag-prefix }}${{ steps.get_version.outputs.version }} 70 | body: ${{ steps.get_release_notes.outputs.release-notes }} 71 | tag: ${{ inputs.tag-prefix }}${{ steps.get_version.outputs.version }} 72 | commit: ${{ github.sha }} 73 | prerelease: ${{ steps.get_prerelease.outputs.prerelease }} -------------------------------------------------------------------------------- /.github/actions/release-create/action.yml: -------------------------------------------------------------------------------- 1 | name: Create a GitHub release 2 | 3 | # 4 | # Creates a GitHub release with the given version. 5 | # 6 | # TODO: Remove once the common repo is public. 7 | # 8 | 9 | inputs: 10 | token: 11 | required: true 12 | files: 13 | required: false 14 | name: 15 | required: true 16 | body: 17 | required: true 18 | tag: 19 | required: true 20 | commit: 21 | required: true 22 | draft: 23 | default: false 24 | required: false 25 | prerelease: 26 | default: false 27 | required: false 28 | fail_on_unmatched_files: 29 | default: true 30 | required: false 31 | 32 | runs: 33 | using: composite 34 | 35 | steps: 36 | - uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 37 | with: 38 | body: ${{ inputs.body }} 39 | name: ${{ inputs.name }} 40 | tag_name: ${{ inputs.tag }} 41 | target_commitish: ${{ inputs.commit }} 42 | draft: ${{ inputs.draft }} 43 | prerelease: ${{ inputs.prerelease }} 44 | fail_on_unmatched_files: ${{ inputs.fail_on_unmatched_files }} 45 | files: ${{ inputs.files }} 46 | env: 47 | GITHUB_TOKEN: ${{ inputs.token }} 48 | -------------------------------------------------------------------------------- /.github/actions/rl-scanner/action.yml: -------------------------------------------------------------------------------- 1 | name: 'Reversing Labs Scanner' 2 | description: 'Runs the Reversing Labs scanner on a specified artifact.' 3 | inputs: 4 | artifact-path: 5 | description: 'Path to the artifact to be scanned.' 6 | required: true 7 | version: 8 | description: 'Version of the artifact.' 9 | required: true 10 | 11 | runs: 12 | using: 'composite' 13 | steps: 14 | - name: Set up Python 15 | uses: actions/setup-python@v4 16 | with: 17 | python-version: '3.10' 18 | 19 | - name: Install Python dependencies 20 | shell: bash 21 | run: | 22 | pip install boto3 requests 23 | 24 | - name: Configure AWS credentials 25 | uses: aws-actions/configure-aws-credentials@v1 26 | with: 27 | role-to-assume: ${{ env.PRODSEC_TOOLS_ARN }} 28 | aws-region: us-east-1 29 | mask-aws-account-id: true 30 | 31 | - name: Install RL Wrapper 32 | shell: bash 33 | run: | 34 | pip install rl-wrapper>=1.0.0 --index-url "https://${{ env.PRODSEC_TOOLS_USER }}:${{ env.PRODSEC_TOOLS_TOKEN }}@a0us.jfrog.io/artifactory/api/pypi/python-local/simple" 35 | 36 | - name: Run RL Scanner 37 | shell: bash 38 | env: 39 | RLSECURE_LICENSE: ${{ env.RLSECURE_LICENSE }} 40 | RLSECURE_SITE_KEY: ${{ env.RLSECURE_SITE_KEY }} 41 | SIGNAL_HANDLER_TOKEN: ${{ env.SIGNAL_HANDLER_TOKEN }} 42 | PYTHONUNBUFFERED: 1 43 | run: | 44 | if [ ! -f "${{ inputs.artifact-path }}" ]; then 45 | echo "Artifact not found: ${{ inputs.artifact-path }}" 46 | exit 1 47 | fi 48 | 49 | rl-wrapper \ 50 | --artifact "${{ inputs.artifact-path }}" \ 51 | --name "${{ github.event.repository.name }}" \ 52 | --version "${{ inputs.version }}" \ 53 | --repository "${{ github.repository }}" \ 54 | --commit "${{ github.sha }}" \ 55 | --build-env "github_actions" \ 56 | --suppress_output 57 | 58 | # Check the outcome of the scanner 59 | if [ $? -ne 0 ]; then 60 | echo "RL Scanner failed." 61 | echo "scan-status=failed" >> $GITHUB_ENV 62 | exit 1 63 | else 64 | echo "RL Scanner passed." 65 | echo "scan-status=success" >> $GITHUB_ENV 66 | fi 67 | 68 | outputs: 69 | scan-status: 70 | description: 'The outcome of the scan process.' 71 | value: ${{ env.scan-status }} 72 | -------------------------------------------------------------------------------- /.github/actions/tag-exists/action.yml: -------------------------------------------------------------------------------- 1 | name: Return a boolean indicating if a tag already exists for the repository 2 | 3 | # 4 | # Returns a simple true/false boolean indicating whether the tag exists or not. 5 | # 6 | # TODO: Remove once the common repo is public. 7 | # 8 | 9 | inputs: 10 | token: 11 | required: true 12 | tag: 13 | required: true 14 | 15 | outputs: 16 | exists: 17 | description: 'Whether the tag exists or not' 18 | value: ${{ steps.tag-exists.outputs.EXISTS }} 19 | 20 | runs: 21 | using: composite 22 | 23 | steps: 24 | - id: tag-exists 25 | shell: bash 26 | run: | 27 | GET_API_URL="https://api.github.com/repos/${GITHUB_REPOSITORY}/git/ref/tags/${TAG_NAME}" 28 | http_status_code=$(curl -LI $GET_API_URL -o /dev/null -w '%{http_code}\n' -s -H "Authorization: token ${GITHUB_TOKEN}") 29 | if [ "$http_status_code" -ne "404" ] ; then 30 | echo "EXISTS=true" >> $GITHUB_OUTPUT 31 | else 32 | echo "EXISTS=false" >> $GITHUB_OUTPUT 33 | fi 34 | env: 35 | TAG_NAME: ${{ inputs.tag }} 36 | GITHUB_TOKEN: ${{ inputs.token }} 37 | -------------------------------------------------------------------------------- /.github/stale.yml: -------------------------------------------------------------------------------- 1 | # Configuration for probot-stale - https://github.com/probot/stale 2 | 3 | # Number of days of inactivity before an Issue or Pull Request becomes stale 4 | daysUntilStale: 90 5 | 6 | # Number of days of inactivity before an Issue or Pull Request with the stale label is closed. 7 | daysUntilClose: 7 8 | 9 | # Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable 10 | exemptLabels: [] 11 | 12 | # Set to true to ignore issues with an assignee (defaults to false) 13 | exemptAssignees: true 14 | 15 | # Label to use when marking as stale 16 | staleLabel: closed:stale 17 | 18 | # Comment to post when marking as stale. Set to `false` to disable 19 | markComment: > 20 | This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you have not received a response for our team (apologies for the delay) and this is still a blocker, please reply with additional information or just a ping. Thank you for your contribution! 🙇‍♂️ -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: 4 | pull_request: {} 5 | 6 | push: 7 | branches: ["master"] 8 | 9 | jobs: 10 | build: 11 | runs-on: windows-latest 12 | steps: 13 | - uses: actions/checkout@v4 14 | 15 | - name: Install Java 16 | uses: actions/setup-java@v3 17 | with: 18 | distribution: 'temurin' 19 | java-version: '11' 20 | 21 | - name: Install .NET 22 | uses: actions/setup-dotnet@v3 23 | with: 24 | dotnet-version: '9.0.200' 25 | 26 | - name: workload update version 27 | run: dotnet workload update --version 9.0.200 28 | 29 | - name: Install .NET Android and iOS workload 30 | run: dotnet workload install android ios maui --version 9.0.200 31 | 32 | - name: workload update version 33 | run: dotnet workload update --version 9.0.200 34 | 35 | - name: Dotnet framework and workload versions 36 | run: dotnet --info 37 | 38 | - name: Setup NuGet 39 | uses: nuget/setup-nuget@v1 40 | 41 | - name: Restore NuGet 42 | run: nuget restore Auth0.OidcClient.All.sln 43 | 44 | - name: Setup MSBuild 45 | uses: microsoft/setup-msbuild@v1.1 46 | 47 | - name: Build 48 | run: msbuild Auth0.OidcClient.All.sln -t:rebuild -verbosity:diag -property:Configuration=Release 49 | 50 | - name: Tests 51 | run: dotnet test **\bin\**\*UnitTests.dll 52 | -------------------------------------------------------------------------------- /.github/workflows/nuget-release.yml: -------------------------------------------------------------------------------- 1 | name: Create NuGet and GitHub Release 2 | 3 | on: 4 | workflow_call: 5 | inputs: 6 | dotnet-version: 7 | default: '8.0.x' 8 | type: string 9 | project-path: 10 | required: true 11 | type: string 12 | tag-prefix: 13 | default: '' 14 | type: string 15 | nuspec-file: 16 | type: string 17 | required: true 18 | secrets: 19 | github-token: 20 | required: true 21 | nuget-token: 22 | required: true 23 | 24 | jobs: 25 | release: 26 | if: github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && github.event.pull_request.merged && startsWith(github.event.pull_request.head.ref, 'release/')) 27 | runs-on: windows-latest 28 | environment: release 29 | 30 | steps: 31 | - name: Checkout code 32 | uses: actions/checkout@v4 33 | with: 34 | fetch-depth: 0 35 | 36 | - uses: actions/download-artifact@v4 37 | with: 38 | path: './src' 39 | name: build 40 | 41 | - id: release 42 | uses: ./.github/actions/nuget-release 43 | with: 44 | dotnet-version: ${{ inputs.dotnet-version }} 45 | project-path: ${{ inputs.project-path }} 46 | tag-prefix: ${{ inputs.tag-prefix }} 47 | nuget-directory: ${{ inputs.project-path }}/nuget 48 | nuget-token: ${{ secrets.nuget-token }} 49 | github-token: ${{ secrets.github-token }} 50 | nuspec-file: ${{ inputs.nuspec-file }} -------------------------------------------------------------------------------- /.github/workflows/rl-secure.yml: -------------------------------------------------------------------------------- 1 | name: RL-Secure Workflow 2 | run-name: rl-scanner 3 | 4 | on: 5 | workflow_call: 6 | inputs: 7 | nuspec-file: 8 | type: string 9 | required: true 10 | artifact-name: 11 | type: string 12 | required: true 13 | project-path: 14 | type: string 15 | required: true 16 | secrets: 17 | RLSECURE_LICENSE: 18 | required: true 19 | RLSECURE_SITE_KEY: 20 | required: true 21 | SIGNAL_HANDLER_TOKEN: 22 | required: true 23 | PRODSEC_TOOLS_USER: 24 | required: true 25 | PRODSEC_TOOLS_TOKEN: 26 | required: true 27 | PRODSEC_TOOLS_ARN: 28 | required: true 29 | 30 | jobs: 31 | rl-scanner: 32 | name: Run Reversing Labs scanner 33 | if: github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && github.event.pull_request.merged && startsWith(github.event.pull_request.head.ref, 'release/')) 34 | runs-on: ubuntu-latest 35 | outputs: 36 | scan-status: ${{ steps.rl-scan-conclusion.outcome }} 37 | 38 | steps: 39 | - name: Checkout code 40 | uses: actions/checkout@v4 41 | with: 42 | fetch-depth: 0 43 | 44 | - name: Setup .NET 45 | uses: actions/setup-dotnet@v3 46 | with: 47 | dotnet-version: '9.0.200' 48 | 49 | - name: Setup Mono 50 | run: | 51 | sudo apt-get update 52 | sudo apt-get install -y mono-complete 53 | 54 | - name: Setup NuGet 55 | uses: nuget/setup-nuget@v1 56 | 57 | - uses: actions/download-artifact@v4 58 | with: 59 | path: './src' 60 | name: build 61 | 62 | - name: Create NuGet packages 63 | shell: pwsh 64 | run: | 65 | nuget pack ${{ inputs.nuspec-file }} -OutputDirectory ${{ github.workspace }}/nuget 66 | 67 | - name: Create tgz build artifact 68 | run: | 69 | tar -czvf ${{ github.workspace }}/${{ inputs.artifact-name }} ${{ github.workspace }}/nuget 70 | 71 | - id: get_version 72 | uses: ./.github/actions/get-version 73 | with: 74 | working-directory: ${{ inputs.project-path }} 75 | 76 | - name: Run RL Scanner 77 | id: rl-scan-conclusion 78 | uses: ./.github/actions/rl-scanner 79 | with: 80 | artifact-path: ${{ github.workspace }}/${{ inputs.artifact-name }} 81 | version: "${{ steps.get_version.outputs.version }}" 82 | env: 83 | RLSECURE_LICENSE: ${{ secrets.RLSECURE_LICENSE }} 84 | RLSECURE_SITE_KEY: ${{ secrets.RLSECURE_SITE_KEY }} 85 | SIGNAL_HANDLER_TOKEN: ${{ secrets.SIGNAL_HANDLER_TOKEN }} 86 | PRODSEC_TOOLS_USER: ${{ secrets.PRODSEC_TOOLS_USER }} 87 | PRODSEC_TOOLS_TOKEN: ${{ secrets.PRODSEC_TOOLS_TOKEN }} 88 | PRODSEC_TOOLS_ARN: ${{ secrets.PRODSEC_TOOLS_ARN }} 89 | 90 | - name: Output scan result 91 | run: echo "scan-status=${{ steps.rl-scan-conclusion.outcome }}" >> $GITHUB_ENV -------------------------------------------------------------------------------- /.github/workflows/semgrep.yml: -------------------------------------------------------------------------------- 1 | name: Semgrep 2 | 3 | on: 4 | pull_request: {} 5 | 6 | push: 7 | branches: ["master", "main"] 8 | 9 | schedule: 10 | - cron: '30 0 1,15 * *' 11 | 12 | jobs: 13 | semgrep: 14 | name: Scan 15 | runs-on: ubuntu-latest 16 | container: 17 | image: returntocorp/semgrep 18 | if: (github.actor != 'dependabot[bot]') 19 | steps: 20 | - uses: actions/checkout@v3 21 | 22 | - run: semgrep ci 23 | env: 24 | SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }} 25 | -------------------------------------------------------------------------------- /.github/workflows/snyk.yml: -------------------------------------------------------------------------------- 1 | name: Snyk 2 | 3 | on: 4 | merge_group: 5 | pull_request: 6 | types: 7 | - opened 8 | - synchronize 9 | push: 10 | branches: 11 | - master 12 | schedule: 13 | - cron: "30 0 1,15 * *" 14 | 15 | permissions: 16 | contents: read 17 | 18 | concurrency: 19 | group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} 20 | cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} 21 | 22 | jobs: 23 | 24 | check: 25 | 26 | name: Check for Vulnerabilities 27 | runs-on: windows-2022 28 | 29 | steps: 30 | - if: github.actor == 'dependabot[bot]' || github.event_name == 'merge_group' 31 | run: exit 0 # Skip unnecessary test runs for dependabot and merge queues. Artifically flag as successful, as this is a required check for branch protection. 32 | 33 | - uses: actions/checkout@v4 34 | with: 35 | ref: ${{ github.event.pull_request.merge_commit_sha || github.ref }} 36 | 37 | - name: Install Java 38 | uses: actions/setup-java@v3 39 | with: 40 | distribution: 'temurin' 41 | java-version: '11' 42 | 43 | - name: Install .NET 44 | uses: actions/setup-dotnet@v3 45 | with: 46 | dotnet-version: '9.0.200' 47 | 48 | - name: workload update version 49 | run: dotnet workload update --version 9.0.200 50 | 51 | - name: Install .NET Android and iOS workload 52 | run: dotnet workload install android ios maui --version 9.0.200 53 | 54 | - name: Setup NuGet 55 | uses: nuget/setup-nuget@v1 56 | 57 | - name: Restore NuGet 58 | run: nuget restore Auth0.OidcClient.All.sln 59 | 60 | # Install Snyk 61 | - run: npm install snyk -g 62 | 63 | # Report vulnerabilities 64 | - run: snyk test --file=Auth0.OidcClient.All.sln --policy-path=.snyk --severity-threshold=medium 65 | env: 66 | SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} -------------------------------------------------------------------------------- /.semgrepignore: -------------------------------------------------------------------------------- 1 | docs/ 2 | docs-source/ 3 | test/ 4 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Contributing 2 | 3 | We provide and maintain SDKs for the benefit of our developer community. Feedback, detailed bug reports, and focused PRs are appreciated. Thank you in advance! 4 | 5 | When contributing to this SDK, please: 6 | 7 | - Maintain the existing minumum .NET framework/core support. 8 | - Keep PRs focused and change the minimum number of lines to achieve your goal. 9 | - Do not introduce breaking changes without prior discussion and approval. 10 | 11 | 12 | ### API documentation 13 | 14 | As the API documentation requires a windows environment, it is built and deployed automatically when running the release GitHub Actions workflow. 15 | -------------------------------------------------------------------------------- /build/Auth0Icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/auth0/auth0-oidc-client-net/066c4fa0b3ab747bfeeac4c8c8addaf7c6ceac59/build/Auth0Icon.png -------------------------------------------------------------------------------- /build/Auth0OidcClientStrongName.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/auth0/auth0-oidc-client-net/066c4fa0b3ab747bfeeac4c8c8addaf7c6ceac59/build/Auth0OidcClientStrongName.snk -------------------------------------------------------------------------------- /docs-source/.gitignore: -------------------------------------------------------------------------------- 1 | ############### 2 | # folder # 3 | ############### 4 | /**/DROP/ 5 | /**/TEMP/ 6 | /**/packages/ 7 | /**/bin/ 8 | /**/obj/ 9 | _site 10 | -------------------------------------------------------------------------------- /docs-source/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | // Place your settings in this file to overwrite default and user settings. 2 | { 3 | } -------------------------------------------------------------------------------- /docs-source/api/.gitignore: -------------------------------------------------------------------------------- 1 | ############### 2 | # temp file # 3 | ############### 4 | *.yml 5 | -------------------------------------------------------------------------------- /docs-source/api/index.md: -------------------------------------------------------------------------------- 1 | # PLACEHOLDER 2 | TODO: Add .NET projects to the *src* folder and run `docfx` to generate **REAL** *API Documentation*! 3 | -------------------------------------------------------------------------------- /docs-source/custom-template/public/main.css: -------------------------------------------------------------------------------- 1 | #logo { 2 | width: 42px; 3 | } -------------------------------------------------------------------------------- /docs-source/docfx.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "content": [ 4 | { 5 | "files": [ 6 | "documentation/**.md", 7 | "documentation/**/toc.yml", 8 | "toc.yml", 9 | "*.md" 10 | ], 11 | "exclude": [ 12 | "obj/**" 13 | ] 14 | } 15 | ], 16 | "resource": [ 17 | { 18 | "files": [ 19 | "images/**" 20 | ], 21 | "exclude": [ 22 | "obj/**" 23 | ] 24 | } 25 | ], 26 | "overwrite": [ 27 | { 28 | "files": [ 29 | "api/**.md" 30 | ], 31 | "exclude": [ 32 | "obj/**" 33 | ] 34 | } 35 | ], 36 | "dest": "../docs", 37 | "globalMetadataFiles": [], 38 | "globalMetadata": { 39 | "_appFooter": "Copyright 2017-2023, Auth0 Inc.", 40 | "_appLogoPath": "images/logo.png", 41 | "_gitContribute": { 42 | "branch": "master" 43 | } 44 | }, 45 | "fileMetadataFiles": [], 46 | "template": [ 47 | "default", 48 | "modern", 49 | "custom-template" 50 | ], 51 | "postProcessors": [], 52 | "noLangKeyword": false 53 | } 54 | } -------------------------------------------------------------------------------- /docs-source/documentation/advanced-scenarios/api-authorization.md: -------------------------------------------------------------------------------- 1 | # API Authorization 2 | 3 | Auth0's API authorization features allow you to manage the authorization requirements for server-to-server and client-to-server applications. 4 | 5 | For more information you can refer to the [Auth0 API Authorization documentation](https://auth0.com/docs/api-auth) 6 | 7 | Using the Auth0 OIDC Client, you can request an `access_token` for an API by passing the `audience` in the `extraParameters` parameter when calling @Auth0.OidcClient.Auth0Client.LoginAsync(System.Object) 8 | 9 | ```csharp 10 | var client = new Auth0Client(new Auth0ClientOptions { 11 | Domain = "YOUR_AUTH0_DOMAIN", 12 | ClientId = "YOUR_AUTH0_CLIENT_ID" 13 | }); 14 | 15 | var loginResult = await client.LoginAsync(new { audience = "https://your-api-identifier" }); 16 | ``` 17 | -------------------------------------------------------------------------------- /docs-source/documentation/advanced-scenarios/browsers.md: -------------------------------------------------------------------------------- 1 | # Browsers 2 | 3 | The SDK is configured to use a platform-specific browser implementation to handle the redirect to Auth0. Depending on the platform, one or more browser implementations might be available. 4 | An example is the `Auth0.OidcClient.iOS` SDK, which auto-selects the browser based on the version of iOS used. 5 | 6 | Even though the use-cases are limited, as our SDK is configured to auto-select the browser based on the verion of iOS being used, you could ensure all versions of iOS use the same browser by passing an explicit `Browser` instance to the `Browser` property of the `Auth0ClientOptions`: 7 | 8 | ``` 9 | var client = new Auth0Client(new Auth0ClientOptions { 10 | Domain = "YOUR_AUTH0_DOMAIN", 11 | ClientId = "YOUR_AUTH0_CLIENT_ID", 12 | Browser = new SFSafariViewControllerBrowser() 13 | }); 14 | ``` 15 | 16 | In case the default implementations that each SDK provides does not suit the needs for your application, each SDK allows you to specify your own custom browser implementation by implementing the `IBrowser` interface. 17 | 18 | ``` 19 | public class CustomBrowser : IBrowser 20 | { 21 | protected override Task Launch( 22 | BrowserOptions options, 23 | CancellationToken cancellationToken = default 24 | ) { 25 | var tcs = new TaskCompletionSource(); 26 | 27 | // Implement custom browser and navigate to options.StartUrl. 28 | // Set the BrowserResult with the callbackUrl that Auth0 redirects back to, 29 | // this URL is the URL that contains state and code query parameters. 30 | tcs.SetResult(new BrowserResult { 31 | ResultType = BrowserResultType.Success, 32 | Response = callbackUrl 33 | }); 34 | 35 | return tcs.Task; 36 | } 37 | } 38 | ``` 39 | 40 | With the `CustomBrowser` implementation in place, instantiate `Auth0Client` with the appropriate `Auth0ClientOptions`: 41 | 42 | ``` 43 | var client = new Auth0Client(new Auth0ClientOptions { 44 | Domain = "YOUR_AUTH0_DOMAIN", 45 | ClientId = "YOUR_AUTH0_CLIENT_ID", 46 | Browser = new CustomBrowser() 47 | }); 48 | ``` 49 | 50 | The SDK will automatically call `Browser.Launch()` and use the result that's being set as part of `tcs.SetResult()`. 51 | -------------------------------------------------------------------------------- /docs-source/documentation/advanced-scenarios/refresh-tokens.md: -------------------------------------------------------------------------------- 1 | ## Refresh Tokens 2 | 3 | You can request a refresh token by requesting the `offline_access` scope. The login result will contain the refresh token in the `RefreshToken` property: 4 | 5 | ```csharp 6 | var client = new Auth0Client(new Auth0ClientOptions { 7 | Domain = "YOUR_AUTH0_DOMAIN", 8 | ClientId = "YOUR_AUTH0_CLIENT_ID", 9 | Scope = "openid offline_access" 10 | }); 11 | 12 | var loginResult = await client.LoginAsync(); 13 | 14 | if (!loginResult.IsError) { 15 | Debug.WriteLine($"refresh_token: {loginResult.RefreshToken}"); 16 | } 17 | ``` 18 | 19 | ### Requesting a Refresh Token 20 | 21 | You can request a Refresh Token by calling @Auth0.OidcClient.Auth0Client.RefreshTokenAsync(System.String), passing along the refresh token which was previously returned in the login result as the 22 | 23 | ```csharp 24 | var client = new Auth0Client(new Auth0ClientOptions { 25 | Domain = "YOUR_AUTH0_DOMAIN", 26 | ClientId = "YOUR_AUTH0_CLIENT_ID", 27 | Scope = "openid offline_access" 28 | }); 29 | 30 | var loginResult = await client.LoginAsync(); 31 | 32 | if (!loginResult.IsError) { 33 | string refreshToken = loginResult.RefreshToken; 34 | // Save the refresh token somewhere... 35 | } 36 | 37 | 38 | // Later on elsewhere in your code you can retrieve the refresh token from where you have saved it, and call RefreshTokenAsync 39 | var refreshTokenResult = await client.RefreshTokenAsync(refreshToken); 40 | ``` 41 | 42 | > [!Note] 43 | > Please note that of your use Auth0 API Authorization, your API should allow offline access. This is configured via the **Allow Offline Access** switch on the [API Settings](https://manage.auth0.com/#/apis) 44 | -------------------------------------------------------------------------------- /docs-source/documentation/advanced-scenarios/scopes.md: -------------------------------------------------------------------------------- 1 | --- 2 | uid: scopes 3 | --- 4 | 5 | # Using Scopes 6 | 7 | By default the Auth0 OIDC Client will request the `openid`, `profile`, and `email` scopes. You can request different scopes by setting the @Auth0.OidcClient.Auth0ClientOptions.Scope property of the @Auth0.OidcClient.Auth0ClientOptions passed to the @Auth0.OidcClient constructor however `openid` is always included. 8 | 9 | Depending on the `scope` which was request the `id_token` will contain a different set of claims. 10 | 11 | By default `loadProfile` will be set to `true` which means the UserInfo endpoint will be called during the authorization flow. To ensure the User object contain only the claims requested in the `scope`, be sure to also set `LoadProfile` to `false`, e.g: 12 | 13 | ```csharp 14 | var client = new Auth0Client(new Auth0ClientOptions 15 | { 16 | Domain = "YOUR_AUTH0_DOMAIN", 17 | ClientId = "YOUR_AUTH0_CLIENT_ID", 18 | Scope = "openid name", 19 | LoadProfile = false 20 | }); 21 | ``` 22 | 23 | For more information you can read the [Auth0 Scopes documentation](https://auth0.com/docs/scopes) -------------------------------------------------------------------------------- /docs-source/documentation/getting-started/callbacks.md: -------------------------------------------------------------------------------- 1 | # Callback URLs 2 | 3 | Callback URLs are the URLs that Auth0 invokes after the authentication process. Auth0 redirects back to this URL and appends additional parameters to it, including an access code which will be exchanged for an `id_token`, `access_token` and `refresh_token`. 4 | 5 | Since callback URLs can be manipulated, you will need to add your application's URL to your client's *Allowed Callback URLs* for security. This will enable Auth0 to recognize these URLs as valid. If omitted, authentication will not be successful. 6 | 7 | The format of the URL will depend on the platform. In the sample callback URLs below, replace `YOUR_AUTH0_DOMAIN` with your actual Auth0 domain. You can find your domain on the Settings tab for your Client inside the [Auth0 dashboard](https://manage.auth0.com/#/): 8 | 9 | ![](/images/dashboard-domain.png) 10 | 11 | ## Universal Windows Platform (UWP) 12 | 13 | Use the following callback URL: 14 | 15 | ```text 16 | https://YOUR_AUTH0_DOMAIN/mobile 17 | ``` 18 | 19 | For example: 20 | 21 | ```text 22 | https://contoso.auth0.com/mobile 23 | ``` 24 | 25 | ## Windows Presentation Foundation (WPF) 26 | 27 | Use the following callback URL: 28 | 29 | ```text 30 | https://YOUR_AUTH0_DOMAIN/mobile 31 | ``` 32 | 33 | For example: 34 | 35 | ```text 36 | https://contoso.auth0.com/mobile 37 | ``` 38 | 39 | ## Windows Forms (WinForms) 40 | 41 | Use the following callback URL: 42 | 43 | ```text 44 | https://YOUR_AUTH0_DOMAIN/mobile 45 | ``` 46 | 47 | For example: 48 | 49 | ```text 50 | https://contoso.auth0.com/mobile 51 | ``` 52 | 53 | ## iOS (uses Xamarin) 54 | 55 | For iOS your Callback URL needs to be in the following format: 56 | 57 | ```text 58 | YOUR_BUNDLE_IDENTIFIER://YOUR_AUTH0_DOMAIN/ios/YOUR_BUNDLE_IDENTIFIER/callback 59 | ``` 60 | 61 | Where `YOUR_BUNDLE_IDENTIFIER` is the Bundle Identifier of your application. So given a Bundle Identifier of `com.contoso.myapp`, and an Auth0 Domain of `contoso.auth0.com`, your callback URL will be the following: 62 | 63 | ```text 64 | com.contoso.myapp://contoso.auth0.com/ios/com.contoso.myapp/callback 65 | ``` 66 | 67 | ## Android (uses Xamarin) 68 | 69 | For Android your Callback URL needs to be in the following format: 70 | 71 | ```text 72 | YOUR_ANDROID_PACKAGE_NAME://YOUR_AUTH0_DOMAIN/android/YOUR_ANDROID_PACKAGE_NAME/callback 73 | ``` 74 | 75 | Where `YOUR_ANDROID_PACKAGE_NAME` is the Package Name of your application. So given a Package Name of `com.contoso.myapp`, and an Auth0 Domain of `contoso.auth0.com`, your callback URL will be the following: 76 | 77 | ```text 78 | com.contoso.myapp://contoso.auth0.com/android/com.contoso.myapp/callback 79 | ``` -------------------------------------------------------------------------------- /docs-source/documentation/getting-started/installation.md: -------------------------------------------------------------------------------- 1 | # Installation 2 | 3 | The Auth0 OIDC Client Library can be installed from NuGet. The NuGet package to install depends on the platform for which you are developing. 4 | 5 | NuGet packages are available for the following platforms: 6 | 7 | * Universal Windows Platform 8 | * Windows Presentation Foundation 9 | * Windows Forms 10 | * iOS (uses Xamarin) 11 | * Android (uses Xamarin) 12 | 13 | ## Universal Windows Platform (UWP) 14 | 15 | ```text 16 | Install-Package Auth0.OidcClient.UWP 17 | ``` 18 | 19 | ## Windows Presentation Foundation (WPF) 20 | 21 | ```text 22 | Install-Package Auth0.OidcClient.WPF 23 | ``` 24 | 25 | ## Windows Forms 26 | 27 | ```text 28 | Install-Package Auth0.OidcClient.WinForms 29 | ``` 30 | 31 | ## iOS (uses Xamarin) 32 | 33 | ```text 34 | Install-Package Auth0.OidcClient.iOS 35 | ``` 36 | 37 | ## Android (uses Xamarin) 38 | 39 | ```text 40 | Install-Package Auth0.OidcClient.Android 41 | ``` -------------------------------------------------------------------------------- /docs-source/documentation/intro.md: -------------------------------------------------------------------------------- 1 | # Auth0 OIDC Client 2 | 3 | The Auth0 OIDC Client allows you to add authentication for your .NET Client applications. The Auth0 OIDC Client supports the following platforms: 4 | 5 | * Universal Windows Platform (UWP 10.0.16299) 6 | * Windows Presentation Foundation (.NET 4.6.2 and higher) 7 | * Windows Forms (.NET 4.6.2 and higher) 8 | * iOS (uses Xamarin) 9 | * Android (uses Xamarin) 10 | 11 | This library is based on the [IdentityModel OpenID Connect Client Library](https://github.com/IdentityModel/IdentityModel.OidcClient), and simply acts as a very thin wrapper around this library, ensuring that the correct configuration is passed to Auth0. 12 | 13 | -------------------------------------------------------------------------------- /docs-source/documentation/migration/v2.md: -------------------------------------------------------------------------------- 1 | # Migrating from Version 1.x to 2.0 2 | 3 | Version 2.0 of the Auth0 OIDC Client has introduced significant changes for iOS and Android applications to add support for Xamarin Forms. To achieve this, references platform-specific constructs, such as `UIViewController` (iOS) and `Activity` (Android), has been removed. This also means that the way you integrate the Auth0 OIDC Client into your application has changed. 4 | 5 | If you have previously used version 1.x of this library in your iOS and Android application, then please refer to the sections below for the changes you need to make to your applications. 6 | 7 | ## Migrating iOS applications 8 | 9 | For iOS applications, in Version 1.x, you had to pass an instance of `UIViewController` to `Auth0ClientOptions`: 10 | 11 | ```csharp 12 | _client = new Auth0Client(new Auth0ClientOptions 13 | { 14 | Domain = "YOUR DOMAIN", 15 | ClientId = "YOUR CLIENT ID", 16 | Controller = this 17 | }); 18 | ``` 19 | 20 | In Version 2.0, this is not required anymore as we automatically detect the controller initiating the authentication flow. Removing this dependency also allow developers to more easily use the Auth0 OIDC Client in Xamarin Forms applications. 21 | 22 | Update the instantiation of `Auth0ClientOptions` to remove the assignment of the `Controller` property, which has been removed: 23 | 24 | ```cs 25 | _client = new Auth0Client(new Auth0ClientOptions 26 | { 27 | Domain = "YOUR DOMAIN", 28 | ClientId = "YOUR CLIENT ID" 29 | }); 30 | ``` 31 | 32 | ## Migrating Android applications 33 | 34 | For Android applications, in Version 1.x, you had to pass an instance of the current `Activity` to `Auth0ClientOptions`: 35 | 36 | ```csharp 37 | _client = new Auth0Client(new Auth0ClientOptions 38 | { 39 | Domain = "YOUR DOMAIN", 40 | ClientId = "YOUR CLIENT ID", 41 | Activity = this 42 | }); 43 | ``` 44 | 45 | This was required because the Auth0 OIDC Client called [StartActivity](https://developer.xamarin.com/api/member/Android.Content.Context.StartActivity/p/Android.Content.Intent/) on the current `Activity` to launch the web browser. With Version 2.0, we are now using the static `Application.Context` property to launch the browser activity, so there is no requirement to pass this to `Auth0ClientOptions` anymore. Removing this dependency also allow developers to more easily use the Auth0 OIDC Client in Xamarin Forms applications. 46 | 47 | Update the instantiation of `Auth0ClientOptions` to remove the assignment of the `Activity` property, which has been removed: 48 | 49 | ```cs 50 | _client = new Auth0Client(new Auth0ClientOptions 51 | { 52 | Domain = "YOUR DOMAIN", 53 | ClientId = "YOUR CLIENT ID" 54 | }); 55 | ``` 56 | -------------------------------------------------------------------------------- /docs-source/documentation/samples.md: -------------------------------------------------------------------------------- 1 | # Sample Applications 2 | 3 | Please review the [Auth0 Quickstarts](https://auth0.com/docs/quickstart/native) for your platform for detailed information on how to implement the Auth0 OIDC Client. 4 | 5 | You can also find the following sample applications related to the Quickstarts mentioned above: 6 | 7 | * [UWP Sample Application](https://github.com/auth0-samples/auth0-uwp-oidc-samples/tree/master/Quickstart/00-Starter-Seed) 8 | * [Windows Presentation Foundation](https://github.com/auth0-samples/auth0-WinFormsWPF-oidc-samples/tree/master/Quickstart/00-Starter-Seed/WPF) 9 | * [Windows Forms](https://github.com/auth0-samples/auth0-WinFormsWPF-oidc-samples/tree/master/Quickstart/00-Starter-Seed/WinForms) 10 | * [iOS (uses Xamarin)](https://github.com/auth0-samples/auth0-xamarin-oidc-samples/tree/master/Quickstart/01-Login/iOS) 11 | * [Android (uses Xamarin)](https://github.com/auth0-samples/auth0-xamarin-oidc-samples/tree/master/Quickstart/01-Login/Android) 12 | -------------------------------------------------------------------------------- /docs-source/documentation/toc.yml: -------------------------------------------------------------------------------- 1 | - name: Home 2 | href: ../index.md 3 | - name: Introduction 4 | href: intro.md 5 | - name: Migration 6 | items: 7 | - name: Version 2.x to 3.0 8 | href: migration/v3.md 9 | - name: Version 1.x to 2.0 10 | href: migration/v2.md 11 | - name: Getting Started 12 | items: 13 | - name: Callback URLs 14 | href: getting-started/callbacks.md 15 | - name: Installation 16 | href: getting-started/installation.md 17 | - name: Authentication 18 | href: getting-started/authentication.md 19 | - name: Advanced Scenarios 20 | items: 21 | - name: Using Scopes 22 | href: advanced-scenarios/scopes.md 23 | - name: Refresh Tokens 24 | href: advanced-scenarios/refresh-tokens.md 25 | - name: API Authorization 26 | href: advanced-scenarios/api-authorization.md 27 | - name: Browsers 28 | href: advanced-scenarios/browsers.md 29 | - name: Samples 30 | href: samples.md -------------------------------------------------------------------------------- /docs-source/filter.yml: -------------------------------------------------------------------------------- 1 | apiRules: 2 | - exclude: 3 | uidRegex: "^Auth0.OidcClient.Resource" 4 | -------------------------------------------------------------------------------- /docs-source/images/dashboard-domain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/auth0/auth0-oidc-client-net/066c4fa0b3ab747bfeeac4c8c8addaf7c6ceac59/docs-source/images/dashboard-domain.png -------------------------------------------------------------------------------- /docs-source/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/auth0/auth0-oidc-client-net/066c4fa0b3ab747bfeeac4c8c8addaf7c6ceac59/docs-source/images/logo.png -------------------------------------------------------------------------------- /docs-source/toc.yml: -------------------------------------------------------------------------------- 1 | - name: Documentation 2 | href: documentation/ 3 | - name: Android 4 | href: android/api/Auth0.OidcClient.html 5 | - name: iOS 6 | href: ios/api/Auth0.OidcClient.html 7 | - name: WPF 8 | href: wpf/api/Auth0.OidcClient.html 9 | - name: WinForms 10 | href: winforms/api/Auth0.OidcClient.html 11 | - name: UWP 12 | href: uwp/api/Auth0.OidcClient.html 13 | - name: MAUI 14 | href: maui/api/Auth0.OidcClient.html -------------------------------------------------------------------------------- /global.json: -------------------------------------------------------------------------------- 1 | { 2 | "sdk": { 3 | "version": "9.0.200", 4 | "rollForward": "latestFeature" 5 | } 6 | } -------------------------------------------------------------------------------- /opslevel.yml: -------------------------------------------------------------------------------- 1 | --- 2 | version: 1 3 | repository: 4 | owner: dx_sdks 5 | tier: 6 | tags: 7 | -------------------------------------------------------------------------------- /src/Auth0.OidcClient.Android/.shiprc: -------------------------------------------------------------------------------- 1 | { 2 | "packageLabel": "android", 3 | "files": { 4 | ".version": [] 5 | }, 6 | "prFilters": [ 7 | { 8 | "type": "title", 9 | "args": [ 10 | "^android:" 11 | ], 12 | "invert": true 13 | } 14 | ] 15 | } -------------------------------------------------------------------------------- /src/Auth0.OidcClient.Android/.version: -------------------------------------------------------------------------------- 1 | 4.1.0 -------------------------------------------------------------------------------- /src/Auth0.OidcClient.Android/ActivityMediator.cs: -------------------------------------------------------------------------------- 1 | namespace Auth0.OidcClient 2 | { 3 | /// 4 | /// Facilitates communication between the app entry point and the callback function. 5 | /// 6 | public class ActivityMediator 7 | { 8 | private static ActivityMediator _instance; 9 | private ActivityMediator() { } 10 | 11 | /// 12 | /// Singleton instance of the class. 13 | /// 14 | public static ActivityMediator Instance 15 | { 16 | get { return _instance ?? (_instance = new ActivityMediator()); } 17 | } 18 | 19 | /// 20 | /// Method signature required for methods subscribing to the ActivityMessageReceived event. 21 | /// 22 | /// Message that has been received. 23 | public delegate void MessageReceivedEventHandler(string message); 24 | 25 | /// 26 | /// Event listener for subscribing to message received events. 27 | /// 28 | public event MessageReceivedEventHandler ActivityMessageReceived; 29 | 30 | /// 31 | /// Send a response message to all listeners. 32 | /// 33 | /// Response message to send to all listeners. 34 | public void Send(string response) 35 | { 36 | ActivityMessageReceived?.Invoke(response); 37 | } 38 | 39 | /// 40 | /// Send a cancellation response message "UserCancel" to all listeners. 41 | /// 42 | public void Cancel() 43 | { 44 | Send("UserCancel"); 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /src/Auth0.OidcClient.Android/AndroidBrowserBase.cs: -------------------------------------------------------------------------------- 1 | using Android.App; 2 | using Android.Content; 3 | using Duende.IdentityModel.OidcClient.Browser; 4 | using System; 5 | using System.Threading; 6 | using System.Threading.Tasks; 7 | 8 | namespace Auth0.OidcClient 9 | { 10 | /// 11 | /// Provides common IBrowser logic for Android. 12 | /// 13 | public abstract class AndroidBrowserBase : IBrowser 14 | { 15 | /// 16 | /// The associated with this browser. 17 | /// 18 | protected Context context; 19 | 20 | /// 21 | /// Whether this browser should launch a new Android Task. 22 | /// 23 | protected bool IsNewTask; 24 | 25 | /// 26 | /// Default constructor for that provides assignment 27 | /// of context and IsNewTask when called by subclasses. 28 | /// 29 | /// Optional to provide on subsequent callbacks. 30 | protected AndroidBrowserBase(Context context = null) 31 | { 32 | this.context = context; 33 | IsNewTask = context == null; 34 | } 35 | 36 | /// 37 | public Task InvokeAsync(BrowserOptions options, CancellationToken cancellationToken = default) 38 | { 39 | if (string.IsNullOrWhiteSpace(options.StartUrl)) 40 | throw new ArgumentException("Missing StartUrl", nameof(options)); 41 | 42 | if (string.IsNullOrWhiteSpace(options.EndUrl)) 43 | throw new ArgumentException("Missing EndUrl", nameof(options)); 44 | 45 | var tcs = new TaskCompletionSource(); 46 | 47 | void Callback(string response) 48 | { 49 | ActivityMediator.Instance.ActivityMessageReceived -= Callback; 50 | 51 | var cancelled = response == "UserCancel"; 52 | tcs.SetResult(new BrowserResult 53 | { 54 | ResultType = cancelled ? BrowserResultType.UserCancel : BrowserResultType.Success, 55 | Response = response 56 | }); 57 | } 58 | 59 | ActivityMediator.Instance.ActivityMessageReceived += Callback; 60 | 61 | OpenBrowser(Android.Net.Uri.Parse(options.StartUrl), context ?? Application.Context); 62 | 63 | return tcs.Task; 64 | } 65 | 66 | /// 67 | /// Open a web browser with the given uri. 68 | /// 69 | /// address to open in the browser. 70 | /// Optional associated with the browser. 71 | protected abstract void OpenBrowser(Android.Net.Uri uri, Context context = null); 72 | } 73 | } -------------------------------------------------------------------------------- /src/Auth0.OidcClient.Android/Auth0.OidcClient.Android.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | MonoAndroid12.0 4 | Auth0.OidcClient 5 | Auth0.OidcClient 6 | Auth0.OidcClient 7 | Auth0.OidcClient.Android 8 | 3.5.0 9 | 3.5.0 10 | 3.5.0 11 | en 12 | false 13 | $(DefineConstants); 14 | default 15 | v12.0 16 | 17 | 18 | portable 19 | true 20 | false 21 | 22 | 23 | portable 24 | true 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /src/Auth0.OidcClient.Android/Auth0ClientActivity.cs: -------------------------------------------------------------------------------- 1 | using Android.App; 2 | using Android.Content; 3 | using Duende.IdentityModel.OidcClient.Browser; 4 | 5 | namespace Auth0.OidcClient 6 | { 7 | /// 8 | /// Base class for automatically wiring up the necessary callback hooks required 9 | /// to facilitate communication with the Browser implementations. 10 | /// 11 | public class Auth0ClientActivity : Activity 12 | { 13 | /// 14 | /// Method executed when the Activity resumes that will cancel any pending 15 | /// implementation by way of the . 16 | /// 17 | protected override void OnResume() 18 | { 19 | base.OnResume(); 20 | ActivityMediator.Instance.Cancel(); 21 | } 22 | 23 | /// 24 | /// Method executed when the Activity receives a new intent that may continue a pending 25 | /// implementation by way of the . 26 | /// 27 | protected override void OnNewIntent(Intent intent) 28 | { 29 | base.OnNewIntent(intent); 30 | ActivityMediator.Instance.Send(intent.DataString); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /src/Auth0.OidcClient.Android/AutoSelectBrowser.cs: -------------------------------------------------------------------------------- 1 | using Android.Content; 2 | using Duende.IdentityModel.OidcClient.Browser; 3 | 4 | namespace Auth0.OidcClient 5 | { 6 | /// 7 | /// Implements the interface using the best available option for the current Android version. 8 | /// 9 | public class AutoSelectBrowser : ChromeCustomTabsBrowser 10 | { 11 | /// 12 | /// Create a new instance of for a given . 13 | /// 14 | /// provided to any subsequent callback. 15 | public AutoSelectBrowser(Context context) : base(context) 16 | { 17 | } 18 | 19 | /// 20 | /// Create a new instance of . 21 | /// 22 | internal AutoSelectBrowser() : base(null) 23 | { 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /src/Auth0.OidcClient.Android/ChromeCustomTabsBrowser.cs: -------------------------------------------------------------------------------- 1 | using Android.Content; 2 | #if ANDROIDX 3 | using AndroidX.Browser.CustomTabs; 4 | #else 5 | using Android.Support.CustomTabs; 6 | #endif 7 | 8 | namespace Auth0.OidcClient 9 | { 10 | /// 11 | /// Implements browser integration using Chrome Custom Tabs. 12 | /// 13 | public class ChromeCustomTabsBrowser : AndroidBrowserBase 14 | { 15 | /// 16 | /// Create a new instance of for a given . 17 | /// 18 | /// provided to any subsequent callback. 19 | public ChromeCustomTabsBrowser(Context context = null) 20 | : base(context) 21 | { 22 | } 23 | 24 | /// 25 | protected override void OpenBrowser(Android.Net.Uri uri, Context context = null) 26 | { 27 | using (var builder = new CustomTabsIntent.Builder()) 28 | using (var customTabsIntent = builder.Build()) 29 | { 30 | if (IsNewTask) 31 | customTabsIntent.Intent.AddFlags(ActivityFlags.NewTask | ActivityFlags.NoHistory); 32 | customTabsIntent.LaunchUrl(context, uri); 33 | } 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /src/Auth0.OidcClient.Android/SystemBrowser.cs: -------------------------------------------------------------------------------- 1 | using Android.Content; 2 | using Duende.IdentityModel.OidcClient.Browser; 3 | 4 | namespace Auth0.OidcClient 5 | { 6 | /// 7 | /// Implements the interface using the best available option for the current Android version. 8 | /// 9 | public class SystemBrowser : AndroidBrowserBase 10 | { 11 | /// 12 | /// Create a new instance of for a given . 13 | /// 14 | /// provided to any subsequent callback. 15 | public SystemBrowser(Context context = null) 16 | : base(context) 17 | { 18 | } 19 | 20 | /// 21 | protected override void OpenBrowser(Android.Net.Uri uri, Context context = null) 22 | { 23 | var intent = new Intent(Intent.ActionView, uri); 24 | 25 | if (IsNewTask) 26 | intent.AddFlags(ActivityFlags.NewTask); 27 | 28 | context.StartActivity(intent); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /src/Auth0.OidcClient.Android/docs-source/docfx.json: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": [ 3 | { 4 | "src": [ 5 | { 6 | "files": [ 7 | "bin/Release/**/Auth0.OidcClient.dll", 8 | "bin/Release/**/Auth0.OidcClient.Core.dll" 9 | ], 10 | "src": "../" 11 | } 12 | ], 13 | "dest": "api", 14 | "filter": "filter.yml", 15 | "includePrivateMembers": false, 16 | "disableGitFeatures": false, 17 | "disableDefaultFilter": false, 18 | "noRestore": false, 19 | "namespaceLayout": "flattened", 20 | "memberLayout": "samePage", 21 | "EnumSortOrder": "alphabetic", 22 | "allowCompilationErrors": false, 23 | "references": [ 24 | { 25 | "files": [ 26 | "bin/Release/**/mscorlib.dll", 27 | "bin/Release/**/System*.dll" 28 | ], 29 | "src": "../" 30 | } 31 | ] 32 | 33 | } 34 | ], 35 | "build": { 36 | "content": [ 37 | { 38 | "files": [ "**/*.{md,yml}" ], 39 | "exclude": [ "_site/**", "obj/**" ] 40 | } 41 | ], 42 | "resource": [ 43 | { 44 | "files": [ 45 | "images/**" 46 | ] 47 | } 48 | ], 49 | "output": "_site", 50 | "globalMetadata": { 51 | "_appLogoUrl": "/auth0-oidc-client-net", 52 | "_appLogoPath": "images/logo.png" 53 | }, 54 | "globalMetadataFiles": [], 55 | "fileMetadataFiles": [], 56 | "template": [ 57 | "default", 58 | "modern", 59 | "../../../docs-source/custom-template" 60 | ], 61 | "postProcessors": [], 62 | "keepFileLink": false, 63 | "disableGitFeatures": false 64 | } 65 | } -------------------------------------------------------------------------------- /src/Auth0.OidcClient.Android/docs-source/docfx.local.json: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": [ 3 | { 4 | "src": [ 5 | { 6 | "files": [ 7 | "bin/Release/**/Auth0.OidcClient.dll", 8 | "bin/Release/**/Auth0.OidcClient.Core.dll" 9 | ], 10 | "src": "../" 11 | } 12 | ], 13 | "dest": "api", 14 | "filter": "filter.yml", 15 | "includePrivateMembers": false, 16 | "disableGitFeatures": false, 17 | "disableDefaultFilter": false, 18 | "noRestore": false, 19 | "namespaceLayout": "flattened", 20 | "memberLayout": "samePage", 21 | "EnumSortOrder": "alphabetic", 22 | "allowCompilationErrors": false, 23 | "references": [ 24 | { 25 | "files": [ 26 | "bin/Release/**/mscorlib.dll", 27 | "bin/Release/**/System*.dll" 28 | ], 29 | "src": "../" 30 | } 31 | ] 32 | 33 | } 34 | ], 35 | "build": { 36 | "content": [ 37 | { 38 | "files": [ "**/*.{md,yml}" ], 39 | "exclude": [ "_site/**", "obj/**" ] 40 | } 41 | ], 42 | "resource": [ 43 | { 44 | "files": [ 45 | "images/**" 46 | ] 47 | } 48 | ], 49 | "output": "_site", 50 | "globalMetadata": { 51 | "_appLogoUrl": "/", 52 | "_appLogoPath": "images/logo.png" 53 | }, 54 | "globalMetadataFiles": [], 55 | "fileMetadataFiles": [], 56 | "template": [ 57 | "default", 58 | "modern", 59 | "../../../docs-source/custom-template" 60 | ], 61 | "postProcessors": [], 62 | "keepFileLink": false, 63 | "disableGitFeatures": false 64 | } 65 | } -------------------------------------------------------------------------------- /src/Auth0.OidcClient.Android/docs-source/filter.yml: -------------------------------------------------------------------------------- 1 | apiRules: 2 | - exclude: 3 | uidRegex: "^Auth0.OidcClient.Resource" 4 | -------------------------------------------------------------------------------- /src/Auth0.OidcClient.Android/docs-source/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/auth0/auth0-oidc-client-net/066c4fa0b3ab747bfeeac4c8c8addaf7c6ceac59/src/Auth0.OidcClient.Android/docs-source/images/logo.png -------------------------------------------------------------------------------- /src/Auth0.OidcClient.Android/docs-source/toc.yml: -------------------------------------------------------------------------------- 1 | - name: Documentation 2 | href: ../ 3 | - name: Android 4 | href: ../android/api/Auth0.OidcClient.html 5 | - name: iOS 6 | href: ../ios/api/Auth0.OidcClient.html 7 | - name: WPF 8 | href: ../wpf/api/Auth0.OidcClient.html 9 | - name: WinForms 10 | href: ../winforms/api/Auth0.OidcClient.html 11 | - name: UWP 12 | href: ../uwp/api/Auth0.OidcClient.html 13 | - name: MAUI 14 | href: ../maui/api/Auth0.OidcClient.html -------------------------------------------------------------------------------- /src/Auth0.OidcClient.AndroidX/.shiprc: -------------------------------------------------------------------------------- 1 | { 2 | "packageLabel": "androidx", 3 | "files": { 4 | ".version": [] 5 | }, 6 | "prFilters": [ 7 | { 8 | "type": "title", 9 | "args": [ 10 | "^androidx:" 11 | ], 12 | "invert": true 13 | } 14 | ] 15 | } -------------------------------------------------------------------------------- /src/Auth0.OidcClient.AndroidX/.version: -------------------------------------------------------------------------------- 1 | 4.3.0 -------------------------------------------------------------------------------- /src/Auth0.OidcClient.AndroidX/Auth0.OidcClient.AndroidX.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | MonoAndroid12.0;net8.0-android;net9.0-android 4 | Auth0.OidcClient 5 | Auth0.OidcClient 6 | Auth0.OidcClient 7 | Auth0.OidcClient.AndroidX 8 | 3.5.0 9 | 3.5.0 10 | 3.5.0 11 | en 12 | false 13 | $(DefineConstants); 14 | default 15 | 16 | 17 | portable 18 | true 19 | false 20 | TRACE;DEBUG;__ANDROID__;ANDROIDX 21 | 22 | 23 | portable 24 | true 25 | TRACE;ANDROIDX 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | {1f79db59-f3a8-45b7-972b-ecd15259d1c9} 38 | Auth0.OidcClient.Core 39 | 40 | 41 | 42 | 43 | 44 | 1.3.0.6 45 | 46 | 47 | -------------------------------------------------------------------------------- /src/Auth0.OidcClient.Core/.shiprc: -------------------------------------------------------------------------------- 1 | { 2 | "packageLabel": "core", 3 | "files": { 4 | ".version": [] 5 | }, 6 | "prFilters": [ 7 | { 8 | "type": "title", 9 | "args": [ 10 | "^core:" 11 | ], 12 | "invert": true 13 | } 14 | ] 15 | } -------------------------------------------------------------------------------- /src/Auth0.OidcClient.Core/.version: -------------------------------------------------------------------------------- 1 | 4.1.0 2 | -------------------------------------------------------------------------------- /src/Auth0.OidcClient.Core/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.CompilerServices; 2 | 3 | [assembly: InternalsVisibleTo("Auth0.OidcClient.Core.UnitTests, PublicKey=002400000480000094000000060200000024000052534131000400000100010029ea30e6e623928cd6fb2ef20ce681b505ba16a96022dff7fe72d6bd4f6c92ade261bae3e2cb016d93ad5b0df960e7c2765c4d60a655ff414eeb2129875558661982be916ccdc5b67c45fbfeab792f666187c3ce61b16f0a8ab16374556e82b1ace5ce0bf7c7722fcb58992154b584c56d3a0169fa9967347b64efc124e154c9")] 4 | -------------------------------------------------------------------------------- /src/Auth0.OidcClient.Core/Auth0.OidcClient.Core.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | netstandard2.0 4 | Auth0.OidcClient 5 | 4.0.1 6 | 4.0.1 7 | 4.0.1 8 | Release;Debug 9 | 10 | 11 | bin\Release\netstandard2.0\Auth0.OidcClient.Core.xml 12 | true 13 | ..\..\build\Auth0OidcClientStrongName.snk 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/Auth0.OidcClient.Core/Tokens/AsymmetricSignatureVerifier.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.IdentityModel.Tokens; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.IdentityModel.Tokens.Jwt; 5 | using System.Net.Http; 6 | using System.Threading.Tasks; 7 | 8 | namespace Auth0.OidcClient.Tokens 9 | { 10 | internal class AsymmetricSignatureVerifier : ISignatureVerifier 11 | { 12 | private readonly IList keys; 13 | private readonly JsonWebKeys jsonWebKeys; 14 | 15 | public AsymmetricSignatureVerifier(HttpMessageHandler backchannel = null) 16 | { 17 | jsonWebKeys = new JsonWebKeys(backchannel); 18 | } 19 | 20 | public async Task ForJwks(string issuer) 21 | { 22 | var jsonWebKeysSet = await jsonWebKeys.GetForIssuer(issuer); 23 | return new AsymmetricSignatureVerifier(jsonWebKeysSet.Keys); 24 | } 25 | 26 | public AsymmetricSignatureVerifier(IList keys) 27 | { 28 | this.keys = keys; 29 | } 30 | 31 | public JwtSecurityToken VerifySignature(string token) 32 | { 33 | var securityTokenHandler = new JwtSecurityTokenHandler(); 34 | 35 | JwtSecurityToken decoded; 36 | try 37 | { 38 | decoded = securityTokenHandler.ReadJwtToken(token); 39 | } 40 | catch (ArgumentException e) 41 | { 42 | throw new IdTokenValidationException("ID token could not be decoded.", e); 43 | } 44 | 45 | if (decoded.SignatureAlgorithm != "RS256") 46 | throw new IdTokenValidationException($"Signature algorithm of \"{decoded.Header.Alg }\" is not supported. Expected the ID token to be signed with \"RS256\"."); 47 | 48 | return (JwtSecurityToken)ValidateTokenSignature(token, securityTokenHandler, decoded.Header.Kid); 49 | } 50 | 51 | internal SecurityToken ValidateTokenSignature(string token, JwtSecurityTokenHandler securityTokenHandler, string kid) 52 | { 53 | try 54 | { 55 | var validationParameters = new TokenValidationParameters 56 | { 57 | ValidateAudience = false, 58 | ValidateIssuer = false, 59 | ValidateActor = false, 60 | ValidateLifetime = false, 61 | ValidateTokenReplay = false, 62 | 63 | RequireSignedTokens = true, 64 | ValidateIssuerSigningKey = true, 65 | IssuerSigningKeys = keys, 66 | }; 67 | 68 | securityTokenHandler.ValidateToken(token, validationParameters, out var verifiedToken); 69 | return verifiedToken; 70 | } 71 | catch (SecurityTokenSignatureKeyNotFoundException) 72 | { 73 | throw new IdTokenValidationException($"Could not find a public key for Key ID (kid) \"{kid}\"."); 74 | } 75 | catch (SecurityTokenException e) 76 | { 77 | throw new IdTokenValidationException("Invalid token signature.", e); 78 | } 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/Auth0.OidcClient.Core/Tokens/Auth0ClaimNames.cs: -------------------------------------------------------------------------------- 1 | namespace Auth0.OidcClient.Tokens 2 | { 3 | /// 4 | /// List of Auth0 specific claims 5 | /// 6 | internal static class Auth0ClaimNames 7 | { 8 | internal static string OrganizationId = "org_id"; 9 | internal static string OrganizationName = "org_name"; 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/Auth0.OidcClient.Core/Tokens/ISignatureVerifier.cs: -------------------------------------------------------------------------------- 1 | using System.IdentityModel.Tokens.Jwt; 2 | 3 | namespace Auth0.OidcClient.Tokens 4 | { 5 | internal interface ISignatureVerifier 6 | { 7 | JwtSecurityToken VerifySignature(string token); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/Auth0.OidcClient.Core/Tokens/IdTokenRequirements.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Security.Claims; 3 | 4 | namespace Auth0.OidcClient.Tokens 5 | { 6 | /// 7 | /// Identity token validation requirements for use with . 8 | /// 9 | internal class IdTokenRequirements 10 | { 11 | /// 12 | /// Required issuer (iss) the token must be from. 13 | /// 14 | public string Issuer; 15 | 16 | /// 17 | /// Required audience (aud) the token must be for. 18 | /// 19 | public string Audience; 20 | 21 | /// 22 | /// Optional one-time nonce the token must be issued in response to. 23 | /// 24 | public string Nonce; 25 | 26 | /// 27 | /// Optional maximum time since the user last authenticated. 28 | /// 29 | public TimeSpan? MaxAge = null; 30 | 31 | /// 32 | /// Amount of leeway to allow in validating date and time claims in order to allow some clock variance 33 | /// between the issuer and the application. 34 | /// 35 | public TimeSpan Leeway; 36 | 37 | /// 38 | /// Required organization the token must be for. 39 | /// 40 | /// 41 | /// - If you provide an Organization ID (a string with the prefix `org_`), it will be validated against the `org_id` claim of your user's ID Token. The validation is case-sensitive. 42 | /// - If you provide an Organization Name (a string *without* the prefix `org_`), it will be validated against the `org_name` claim of your user's ID Token. The validation is case-insensitive. 43 | /// 44 | public string Organization; 45 | 46 | /// 47 | /// Create a new instance of with specified parameters. 48 | /// 49 | /// Required issuer (iss) the token must be from. 50 | /// Required audience (aud) the token must be for. 51 | /// Amount of leeway in validating date and time claims to allow some clock variance 52 | /// between the issuer and the application. 53 | /// Optional maximum time since the user last authenticated. 54 | /// Optional organization the token must be for. 55 | public IdTokenRequirements(string issuer, string audience, TimeSpan leeway, TimeSpan ? maxAge = null, string organization = null) 56 | { 57 | Issuer = issuer; 58 | Audience = audience; 59 | Leeway = leeway; 60 | MaxAge = maxAge; 61 | Organization = organization; 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/Auth0.OidcClient.Core/Tokens/IdTokenValidationException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Auth0.OidcClient.Tokens 5 | { 6 | /// 7 | /// Exception used to convey ways in which an identity token has failed to be validated. 8 | /// 9 | public class IdTokenValidationException : Exception 10 | { 11 | /// Create a new with no error message. 12 | public IdTokenValidationException() 13 | { 14 | } 15 | 16 | /// 17 | /// Create a new with a given error message. 18 | /// 19 | /// Message that describes how the token fails to meet validation requirements. 20 | public IdTokenValidationException(string message) 21 | : base(message) 22 | { 23 | } 24 | 25 | /// 26 | /// Create a new that contains a further inner 27 | /// describing how this token could not be validated. 28 | /// 29 | /// Message that describes how the token fails to meet validation requirements. 30 | /// Inner exception that caused this validation exception. 31 | public IdTokenValidationException(string message, Exception innerException) 32 | : base(message, innerException) 33 | { 34 | } 35 | 36 | /// 37 | protected IdTokenValidationException(SerializationInfo info, StreamingContext context) 38 | : base(info, context) 39 | { 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /src/Auth0.OidcClient.Core/Tokens/JsonWebKeys.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.IdentityModel.Protocols; 2 | using Microsoft.IdentityModel.Protocols.OpenIdConnect; 3 | using Microsoft.IdentityModel.Tokens; 4 | using System; 5 | using System.Net.Http; 6 | using System.Threading.Tasks; 7 | 8 | namespace Auth0.OidcClient.Tokens 9 | { 10 | class JsonWebKeys 11 | { 12 | private readonly HttpMessageHandler backchannel; 13 | 14 | public JsonWebKeys(HttpMessageHandler backchannel = null) 15 | { 16 | this.backchannel = backchannel; 17 | } 18 | 19 | public async Task GetForIssuer(string issuer) 20 | { 21 | var metadataAddress = new UriBuilder(issuer) { Path = "/.well-known/openid-configuration" }.Uri.OriginalString; 22 | var openIdConfiguration = await GetOpenIdConfiguration(metadataAddress); 23 | return openIdConfiguration.JsonWebKeySet; 24 | } 25 | 26 | private Task GetOpenIdConfiguration(string metadataAddress) 27 | { 28 | try 29 | { 30 | var configurationManager = backchannel == null ? new ConfigurationManager(metadataAddress, new OpenIdConnectConfigurationRetriever()) : new ConfigurationManager(metadataAddress, new OpenIdConnectConfigurationRetriever(), new System.Net.Http.HttpClient(backchannel)); 31 | return configurationManager.GetConfigurationAsync(); 32 | } 33 | catch (Exception e) 34 | { 35 | throw new IdTokenValidationException($"Unable to retrieve public keys from \"${metadataAddress}\".", e); 36 | } 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /src/Auth0.OidcClient.MAUI.Platforms.Windows/Activator.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Windows.AppLifecycle; 2 | using Windows.ApplicationModel.Activation; 3 | 4 | namespace Auth0.OidcClient.Platforms.Windows 5 | { 6 | public interface IActivator 7 | { 8 | bool RedirectActivationChecked { get; } 9 | bool CheckRedirectionActivation(); 10 | } 11 | 12 | /// 13 | /// Activator class used to enable protocol activation check and redirects activation to the correct application instance 14 | /// 15 | public sealed class Activator : IActivator 16 | { 17 | private readonly IAppInstanceProxy _appInstanceProxy; 18 | 19 | public static readonly Activator Default = new Activator(new AppInstanceProxy()); 20 | 21 | internal Activator(IAppInstanceProxy appInstanceProxy) 22 | { 23 | _appInstanceProxy = appInstanceProxy; 24 | } 25 | 26 | /// 27 | /// Boolean indication the redirect activation was checked 28 | /// 29 | public bool RedirectActivationChecked { get; internal set; } 30 | 31 | /// 32 | /// Performs a protocol activation check and redirects activation to the correct application instance. 33 | /// 34 | public bool CheckRedirectionActivation() 35 | { 36 | var activatedEventArgs = _appInstanceProxy.GetCurrentActivatedEventArgs(); 37 | 38 | RedirectActivationChecked = true; 39 | 40 | if (activatedEventArgs is null || activatedEventArgs.Kind != ExtendedActivationKind.Protocol || activatedEventArgs.Data is not IProtocolActivatedEventArgs protocolArgs) 41 | { 42 | return false; 43 | } 44 | 45 | var ctx = RedirectionContextManager.GetRedirectionContext(protocolArgs); 46 | 47 | if (ctx is not null && ctx.AppInstanceKey is not null && ctx.TaskId is not null) 48 | { 49 | return _appInstanceProxy.RedirectActivationToAsync(ctx.AppInstanceKey, activatedEventArgs); 50 | } 51 | else 52 | { 53 | _appInstanceProxy.FindOrRegisterForKey(); 54 | } 55 | return false; 56 | } 57 | 58 | } 59 | } -------------------------------------------------------------------------------- /src/Auth0.OidcClient.MAUI.Platforms.Windows/AppActivationArguments.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Windows.AppLifecycle; 2 | 3 | namespace Auth0.OidcClient.Platforms.Windows; 4 | 5 | internal interface IAppActivationArguments 6 | { 7 | ExtendedActivationKind Kind { get; set; } 8 | object Data { get; set; } 9 | } 10 | 11 | internal class AppActivationArguments : IAppActivationArguments 12 | { 13 | public ExtendedActivationKind Kind { get; set; } 14 | public object Data { get; set; } 15 | } -------------------------------------------------------------------------------- /src/Auth0.OidcClient.MAUI.Platforms.Windows/Auth0.OidcClient.MAUI.Platforms.Windows.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0-windows10.0.19041.0;net9.0-windows10.0.19041.0 5 | true 6 | true 7 | enable 8 | 9 | 10.0.19041.0 10 | 10.0.17763.0 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/Auth0.OidcClient.MAUI.Platforms.Windows/RedirectionContext.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Specialized; 2 | using System.Text.Json.Nodes; 3 | 4 | namespace Auth0.OidcClient.Platforms.Windows 5 | { 6 | internal class RedirectionContext 7 | { 8 | /// 9 | /// The id of the task associated with the current redirect. 10 | /// 11 | internal string TaskId { get; set; } 12 | 13 | /// 14 | /// The key of the application associated with the current redirect. 15 | /// 16 | internal string AppInstanceKey { get; set; } 17 | 18 | /// 19 | /// Generate a new based on the application instance. 20 | /// 21 | /// The current application instance. 22 | /// The newly created 23 | internal static RedirectionContext New(IAppInstanceProxy appInstanceProxy) 24 | { 25 | return new RedirectionContext 26 | { 27 | TaskId = Guid.NewGuid().ToString(), 28 | AppInstanceKey = appInstanceProxy.GetCurrentAppKey() 29 | }; 30 | } 31 | 32 | /// 33 | /// Converts the to a for serialization. 34 | /// 35 | /// A holding an optional state property to incorporate in the . 36 | /// 37 | internal JsonObject ToJsonObject(NameValueCollection query) 38 | { 39 | var jsonObject = new JsonObject 40 | { 41 | { "appInstanceKey", AppInstanceKey }, 42 | { "taskId", TaskId } 43 | }; 44 | 45 | if (query["state"] is string oldState && !string.IsNullOrEmpty(oldState)) 46 | { 47 | jsonObject["state"] = oldState; 48 | } 49 | 50 | return jsonObject; 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /src/Auth0.OidcClient.MAUI.Platforms.Windows/RedirectionContextManager.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.CompilerServices; 2 | using System.Text.Json.Nodes; 3 | using Windows.ApplicationModel.Activation; 4 | 5 | [assembly: InternalsVisibleTo("Auth0.OidcClient.MAUI.Platforms.Windows.UnitTests")] 6 | namespace Auth0.OidcClient.Platforms.Windows 7 | { 8 | internal class RedirectionContextManager 9 | { 10 | /// 11 | /// Gets the from the provided 12 | /// 13 | /// The event arguments associated with the corresponding protocol activation. 14 | /// The newly created . 15 | internal static RedirectionContext? GetRedirectionContext(IProtocolActivatedEventArgs protocolArgs) 16 | { 17 | var query = System.Web.HttpUtility.ParseQueryString(protocolArgs.Uri.Query); 18 | var state = query["state"]; 19 | JsonObject jsonObject = null; 20 | 21 | if (!string.IsNullOrEmpty(state)) 22 | { 23 | jsonObject = JsonNode.Parse(Helpers.Decode(state)) as JsonObject; 24 | } 25 | 26 | if (jsonObject is not null) 27 | { 28 | return new RedirectionContext 29 | { 30 | AppInstanceKey = TryGetJsonValue(jsonObject, "appInstanceKey"), 31 | TaskId = TryGetJsonValue(jsonObject, "taskId") 32 | }; 33 | } 34 | 35 | return null; 36 | } 37 | 38 | 39 | /// 40 | /// Helper method to try and get a value from a . 41 | /// 42 | /// The corresponding . 43 | /// The key for the value to be retrieve from the 44 | /// The value from the provided key, or null if not found. 45 | private static string TryGetJsonValue(JsonObject jsonObject, string key) 46 | { 47 | if (jsonObject.ContainsKey(key) && jsonObject[key] is JsonValue jValue && jValue.TryGetValue(out string value)) 48 | { 49 | return value; 50 | } 51 | 52 | return null; 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /src/Auth0.OidcClient.MAUI.Platforms.Windows/TasksManager.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.CompilerServices; 2 | 3 | [assembly: InternalsVisibleTo("Auth0.OidcClient.MAUI.Platforms.Windows.UnitTests")] 4 | namespace Auth0.OidcClient.Platforms.Windows 5 | { 6 | interface ITasksManager 7 | { 8 | void Remove(string taskId); 9 | void Add(string taskId, TaskCompletionSource tcs); 10 | void ResumeTask(Uri callbackUri, string taskId); 11 | } 12 | 13 | internal sealed class TasksManager : ITasksManager 14 | { 15 | public static readonly TasksManager Default = new TasksManager(); 16 | 17 | private readonly Dictionary> _tasks = new Dictionary>(); 18 | private TasksManager() { } 19 | 20 | public void Remove(string taskId) 21 | { 22 | if (_tasks.ContainsKey(taskId)) 23 | { 24 | _tasks.Remove(taskId); 25 | } 26 | } 27 | 28 | public void Add(string taskId, TaskCompletionSource tcs) 29 | { 30 | _tasks.Add(taskId, tcs); 31 | } 32 | 33 | public void ResumeTask(Uri callbackUri, string taskId) 34 | { 35 | if (taskId != null && _tasks.ContainsKey(taskId)) 36 | { 37 | var task = _tasks[taskId]; 38 | _tasks.Remove(taskId); 39 | task.TrySetResult(callbackUri); 40 | } 41 | } 42 | 43 | } 44 | } -------------------------------------------------------------------------------- /src/Auth0.OidcClient.MAUI.Platforms.Windows/WebAuthenticatorResult.cs: -------------------------------------------------------------------------------- 1 | namespace Auth0.OidcClient.Platforms.Windows; 2 | 3 | /// 4 | /// Represents a Web Authenticator Result object parsed from the callback Url. 5 | /// 6 | /// 7 | /// All of the query string or url fragment properties are parsed into a dictionary and can be accessed by their key. 8 | /// 9 | public class WebAuthenticatorResult 10 | { 11 | /// 12 | /// Initializes a new instance of the class by parsing a URI's query string parameters. 13 | /// 14 | /// The callback uri that was used to end the authentication sequence. 15 | public WebAuthenticatorResult(Uri uri) 16 | { 17 | CallbackUri = uri; 18 | var properties = System.Web.HttpUtility.ParseQueryString(uri.Query); 19 | foreach (var key in properties.Keys) 20 | { 21 | Properties[(string) key] = properties[(string)key]; 22 | } 23 | } 24 | 25 | /// 26 | /// The uri that was used to call back. 27 | /// 28 | public Uri CallbackUri { get; } 29 | 30 | /// 31 | /// The dictionary of key/value pairs parsed form the callback URI's query string. 32 | /// 33 | public Dictionary Properties { get; } = new(StringComparer.Ordinal); 34 | } -------------------------------------------------------------------------------- /src/Auth0.OidcClient.MAUI/.shiprc: -------------------------------------------------------------------------------- 1 | { 2 | "packageLabel": "maui", 3 | "files": { 4 | ".version": [] 5 | }, 6 | "prFilters": [ 7 | { 8 | "type": "title", 9 | "args": [ 10 | "^maui:" 11 | ], 12 | "invert": true 13 | } 14 | ] 15 | } -------------------------------------------------------------------------------- /src/Auth0.OidcClient.MAUI/.version: -------------------------------------------------------------------------------- 1 | 1.3.0 2 | -------------------------------------------------------------------------------- /src/Auth0.OidcClient.MAUI/Auth0.OidcClient.MAUI.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0;net8.0-android;net8.0-ios;net8.0-maccatalyst;net9.0;net9.0-android;net9.0-ios;net9.0-maccatalyst 5 | $(TargetFrameworks);net8.0-windows10.0.19041.0;net9.0-windows10.0.19041.0 6 | true 7 | true 8 | enable 9 | 10 | 16.4.7142 11 | 16.4.7142 12 | 33.0.95 13 | 14 | 18.0 15 | 18.0 16 | 34 17 | 18 | 10.0.19041.0 19 | 10.0.17763.0 20 | 21 | Auth0.OidcClient 22 | Auth0.OidcClient 23 | 24 | 25 | 26 | false 27 | 28 | 29 | true 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | Auth0Icon.png 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /src/Auth0.OidcClient.MAUI/Auth0Client.cs: -------------------------------------------------------------------------------- 1 | namespace Auth0.OidcClient; 2 | 3 | /// 4 | /// Primary class for performing authentication and authorization operations with Auth0 using the 5 | /// underlying . 6 | /// 7 | public class Auth0Client : Auth0ClientBase 8 | { 9 | /// 10 | /// Creates a new instance of the Auth0 OIDC Client. 11 | /// 12 | /// The specifying the configuration for the Auth0 OIDC Client. 13 | public Auth0Client(Auth0ClientOptions options) 14 | : base(options, "maui") 15 | { 16 | options.Browser = options.Browser ?? new WebAuthenticatorBrowser(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/Auth0.OidcClient.MAUI/WebAuthenticatorBrowser.cs: -------------------------------------------------------------------------------- 1 | namespace Auth0.OidcClient; 2 | 3 | using Duende.IdentityModel.OidcClient.Browser; 4 | using Duende.IdentityModel.Client; 5 | 6 | /// 7 | /// Implements the Browser using for MAUI. 8 | /// 9 | public class WebAuthenticatorBrowser : IBrowser 10 | { 11 | /// 12 | public async Task InvokeAsync(BrowserOptions options, CancellationToken cancellationToken = default) 13 | { 14 | try 15 | { 16 | #if WINDOWS 17 | var result = await Auth0.OidcClient.Platforms.Windows.WebAuthenticator.Default.AuthenticateAsync(new Uri(options.StartUrl), new Uri(options.EndUrl)); 18 | #else 19 | var result = await WebAuthenticator.Default.AuthenticateAsync(new Uri(options.StartUrl), new Uri(options.EndUrl)); 20 | #endif 21 | 22 | var url = new RequestUrl(options.EndUrl) 23 | .Create(new Parameters(result.Properties)); 24 | 25 | return new BrowserResult 26 | { 27 | Response = url, 28 | ResultType = BrowserResultType.Success 29 | }; 30 | } 31 | catch (TaskCanceledException) 32 | { 33 | return new BrowserResult 34 | { 35 | ResultType = BrowserResultType.UserCancel, 36 | ErrorDescription = "Login canceled by the user." 37 | }; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/Auth0.OidcClient.MAUI/docs-source/docfx.json: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": [ 3 | { 4 | "src": [ 5 | { 6 | "files": [ 7 | "bin/Release/**/Auth0.OidcClient.dll", 8 | "bin/Release/**/Auth0.OidcClient.Core.dll" 9 | ], 10 | "src": "../" 11 | } 12 | ], 13 | "dest": "api", 14 | "filter": "filter.yml", 15 | "includePrivateMembers": false, 16 | "disableGitFeatures": false, 17 | "disableDefaultFilter": false, 18 | "noRestore": false, 19 | "namespaceLayout": "flattened", 20 | "memberLayout": "samePage", 21 | "EnumSortOrder": "alphabetic", 22 | "allowCompilationErrors": false, 23 | "references": [ 24 | { 25 | "files": [ 26 | "bin/Release/**/mscorlib.dll", 27 | "bin/Release/**/System*.dll" 28 | ], 29 | "src": "../" 30 | } 31 | ] 32 | 33 | } 34 | ], 35 | "build": { 36 | "content": [ 37 | { 38 | "files": [ "**/*.{md,yml}" ], 39 | "exclude": [ "_site/**", "obj/**" ] 40 | } 41 | ], 42 | "resource": [ 43 | { 44 | "files": [ 45 | "images/**" 46 | ] 47 | } 48 | ], 49 | "output": "_site", 50 | "globalMetadata": { 51 | "_appLogoUrl": "/auth0-oidc-client-net", 52 | "_appLogoPath": "images/logo.png" 53 | }, 54 | "globalMetadataFiles": [], 55 | "fileMetadataFiles": [], 56 | "template": [ 57 | "default", 58 | "modern", 59 | "../../../docs-source/custom-template" 60 | ], 61 | "postProcessors": [], 62 | "keepFileLink": false, 63 | "disableGitFeatures": false 64 | } 65 | } -------------------------------------------------------------------------------- /src/Auth0.OidcClient.MAUI/docs-source/docfx.local.json: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": [ 3 | { 4 | "src": [ 5 | { 6 | "files": [ 7 | "bin/Release/**/Auth0.OidcClient.dll", 8 | "bin/Release/**/Auth0.OidcClient.Core.dll" 9 | ], 10 | "src": "../" 11 | } 12 | ], 13 | "dest": "api", 14 | "filter": "filter.yml", 15 | "includePrivateMembers": false, 16 | "disableGitFeatures": false, 17 | "disableDefaultFilter": false, 18 | "noRestore": false, 19 | "namespaceLayout": "flattened", 20 | "memberLayout": "samePage", 21 | "EnumSortOrder": "alphabetic", 22 | "allowCompilationErrors": false, 23 | "references": [ 24 | { 25 | "files": [ 26 | "bin/Release/**/mscorlib.dll", 27 | "bin/Release/**/System*.dll" 28 | ], 29 | "src": "../" 30 | } 31 | ] 32 | 33 | } 34 | ], 35 | "build": { 36 | "content": [ 37 | { 38 | "files": [ "**/*.{md,yml}" ], 39 | "exclude": [ "_site/**", "obj/**" ] 40 | } 41 | ], 42 | "resource": [ 43 | { 44 | "files": [ 45 | "images/**" 46 | ] 47 | } 48 | ], 49 | "output": "_site", 50 | "globalMetadata": { 51 | "_appLogoUrl": "/", 52 | "_appLogoPath": "images/logo.png" 53 | }, 54 | "globalMetadataFiles": [], 55 | "fileMetadataFiles": [], 56 | "template": [ 57 | "default", 58 | "modern", 59 | "../../../docs-source/custom-template" 60 | ], 61 | "postProcessors": [], 62 | "keepFileLink": false, 63 | "disableGitFeatures": false 64 | } 65 | } -------------------------------------------------------------------------------- /src/Auth0.OidcClient.MAUI/docs-source/filter.yml: -------------------------------------------------------------------------------- 1 | apiRules: 2 | - exclude: 3 | uidRegex: "^Auth0.OidcClient.Resource" 4 | -------------------------------------------------------------------------------- /src/Auth0.OidcClient.MAUI/docs-source/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/auth0/auth0-oidc-client-net/066c4fa0b3ab747bfeeac4c8c8addaf7c6ceac59/src/Auth0.OidcClient.MAUI/docs-source/images/logo.png -------------------------------------------------------------------------------- /src/Auth0.OidcClient.MAUI/docs-source/toc.yml: -------------------------------------------------------------------------------- 1 | - name: Documentation 2 | href: ../ 3 | - name: Android 4 | href: ../android/api/Auth0.OidcClient.html 5 | - name: iOS 6 | href: ../ios/api/Auth0.OidcClient.html 7 | - name: WPF 8 | href: ../wpf/api/Auth0.OidcClient.html 9 | - name: WinForms 10 | href: ../winforms/api/Auth0.OidcClient.html 11 | - name: UWP 12 | href: ../uwp/api/Auth0.OidcClient.html 13 | - name: MAUI 14 | href: ../maui/api/Auth0.OidcClient.html -------------------------------------------------------------------------------- /src/Auth0.OidcClient.UWP/.shiprc: -------------------------------------------------------------------------------- 1 | { 2 | "packageLabel": "uwp", 3 | "files": { 4 | ".version": [] 5 | }, 6 | "prFilters": [ 7 | { 8 | "type": "title", 9 | "args": [ 10 | "^uwp:" 11 | ], 12 | "invert": true 13 | } 14 | ] 15 | } -------------------------------------------------------------------------------- /src/Auth0.OidcClient.UWP/.version: -------------------------------------------------------------------------------- 1 | 4.2.0 -------------------------------------------------------------------------------- /src/Auth0.OidcClient.UWP/Auth0.OidcClient.UWP.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | uap10.0.19041.0 5 | Auth0.OidcClient 6 | Auth0.OidcClient 7 | Auth0.OidcClient.UWP 8 | Auth0.OidcClient 9 | 3.4.1 10 | 3.4.1 11 | 3.4.1 12 | en-US 13 | AnyCPU 14 | UAP 15 | 10.0.19041.0 16 | 10.0.19041.0 17 | DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP 18 | prompt 19 | 4 20 | true 21 | ..\..\build\Auth0OidcClientStrongName.snk 22 | 23 | 24 | true 25 | full 26 | false 27 | prompt 28 | 4 29 | 30 | 31 | pdbonly 32 | true 33 | bin\Release\Auth0.OidcClient.XML 34 | 35 | 36 | 37 | {1F79DB59-F3A8-45B7-972B-ECD15259D1C9} 38 | Auth0.OidcClient.Core 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /src/Auth0.OidcClient.UWP/Auth0Client.cs: -------------------------------------------------------------------------------- 1 | using Windows.Security.Authentication.Web; 2 | using Windows.UI.Xaml; 3 | 4 | namespace Auth0.OidcClient 5 | { 6 | /// 7 | /// Primary class for performing authentication and authorization operations with Auth0 using the 8 | /// underlying . 9 | /// 10 | public class Auth0Client : Auth0ClientBase 11 | { 12 | /// 13 | /// Creates a new instance of the Auth0 OIDC Client. 14 | /// 15 | /// The specifying the configuration for the Auth0 OIDC Client. 16 | public Auth0Client(Auth0ClientOptions options) 17 | : base(options, "uwp") 18 | { 19 | options.Browser = options.Browser ?? new WebViewBrowser(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/Auth0.OidcClient.UWP/Properties/Auth0.OidcClient.UWP.rd.xml: -------------------------------------------------------------------------------- 1 | 2 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/Auth0.OidcClient.UWP/WebViewBrowser.cs: -------------------------------------------------------------------------------- 1 | using Duende.IdentityModel.OidcClient.Browser; 2 | using System; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Windows.ApplicationModel.Core; 6 | using Windows.UI.Core; 7 | using Windows.UI.ViewManagement; 8 | using Windows.UI.Xaml; 9 | using Windows.UI.Xaml.Controls; 10 | 11 | namespace Auth0.OidcClient 12 | { 13 | /// 14 | /// Implements the interface using the control. 15 | /// 16 | public class WebViewBrowser : IBrowser 17 | { 18 | /// 19 | public Task InvokeAsync(BrowserOptions options, CancellationToken cancellationToken = default) 20 | { 21 | var tcs = new TaskCompletionSource(); 22 | var currentAppView = ApplicationView.GetForCurrentView(); 23 | 24 | RunOnNewView(async () => { 25 | var newAppView = CreateApplicationView(); 26 | var webView = CreateWebView(Window.Current, options, tcs); 27 | webView.Navigate(new Uri(options.StartUrl)); 28 | await ApplicationViewSwitcher.TryShowAsStandaloneAsync(newAppView.Id, ViewSizePreference.UseMinimum, currentAppView.Id, ViewSizePreference.UseMinimum); 29 | }); 30 | 31 | return tcs.Task; 32 | } 33 | 34 | private async void RunOnNewView(DispatchedHandler function) 35 | { 36 | await CoreApplication.CreateNewView().Dispatcher.RunAsync(CoreDispatcherPriority.Normal, function); 37 | } 38 | 39 | private static ApplicationView CreateApplicationView() 40 | { 41 | var appView = ApplicationView.GetForCurrentView(); 42 | appView.Title = "Authentication..."; 43 | return appView; 44 | } 45 | 46 | private static WebView CreateWebView(Window window, BrowserOptions options, TaskCompletionSource tcs) 47 | { 48 | var webView = new WebView(); 49 | 50 | webView.NavigationStarting += (sender, e) => 51 | { 52 | if (e.Uri.AbsoluteUri.StartsWith(options.EndUrl)) 53 | { 54 | tcs.SetResult(new BrowserResult { ResultType = BrowserResultType.Success, Response = e.Uri.ToString() }); 55 | window.Close(); 56 | } 57 | }; 58 | 59 | // There is no closed event so the best we can do is detect visibility. This means we close when they minimize too. 60 | window.VisibilityChanged += (sender, e) => 61 | { 62 | if (!window.Visible && !tcs.Task.IsCompleted) 63 | { 64 | tcs.SetResult(new BrowserResult { ResultType = BrowserResultType.UserCancel }); 65 | window.Close(); 66 | } 67 | }; 68 | 69 | window.Content = webView; 70 | window.Activate(); 71 | 72 | return webView; 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/Auth0.OidcClient.UWP/docs-source/docfx.json: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": [ 3 | { 4 | "src": [ 5 | { 6 | "files": [ 7 | "bin/Release/**/Auth0.OidcClient.dll", 8 | "bin/Release/**/Auth0.OidcClient.Core.dll" 9 | ], 10 | "src": "../" 11 | } 12 | ], 13 | "dest": "api", 14 | "includePrivateMembers": false, 15 | "disableGitFeatures": false, 16 | "disableDefaultFilter": false, 17 | "noRestore": false, 18 | "namespaceLayout": "flattened", 19 | "memberLayout": "samePage", 20 | "EnumSortOrder": "alphabetic", 21 | "allowCompilationErrors": false 22 | } 23 | ], 24 | "build": { 25 | "content": [ 26 | { 27 | "files": [ "**/*.{md,yml}" ], 28 | "exclude": [ "_site/**", "obj/**" ] 29 | } 30 | ], 31 | "resource": [ 32 | { 33 | "files": [ 34 | "images/**" 35 | ] 36 | } 37 | ], 38 | "output": "_site", 39 | "globalMetadataFiles": [], 40 | "globalMetadata": { 41 | "_appLogoUrl": "/auth0-oidc-client-net", 42 | "_appLogoPath": "images/logo.png" 43 | }, 44 | "fileMetadataFiles": [], 45 | "template": [ 46 | "default", 47 | "modern", 48 | "../../../docs-source/custom-template" 49 | ], 50 | "postProcessors": [], 51 | "keepFileLink": false, 52 | "disableGitFeatures": false 53 | } 54 | } -------------------------------------------------------------------------------- /src/Auth0.OidcClient.UWP/docs-source/docfx.local.json: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": [ 3 | { 4 | "src": [ 5 | { 6 | "files": [ 7 | "bin/Release/**/Auth0.OidcClient.dll", 8 | "bin/Release/**/Auth0.OidcClient.Core.dll" 9 | ], 10 | "src": "../" 11 | } 12 | ], 13 | "dest": "api", 14 | "includePrivateMembers": false, 15 | "disableGitFeatures": false, 16 | "disableDefaultFilter": false, 17 | "noRestore": false, 18 | "namespaceLayout": "flattened", 19 | "memberLayout": "samePage", 20 | "EnumSortOrder": "alphabetic", 21 | "allowCompilationErrors": false 22 | } 23 | ], 24 | "build": { 25 | "content": [ 26 | { 27 | "files": [ "**/*.{md,yml}" ], 28 | "exclude": [ "_site/**", "obj/**" ] 29 | } 30 | ], 31 | "resource": [ 32 | { 33 | "files": [ 34 | "images/**" 35 | ] 36 | } 37 | ], 38 | "output": "_site", 39 | "globalMetadataFiles": [], 40 | "globalMetadata": { 41 | "_appLogoUrl": "/", 42 | "_appLogoPath": "images/logo.png" 43 | }, 44 | "fileMetadataFiles": [], 45 | "template": [ 46 | "default", 47 | "modern", 48 | "../../../docs-source/custom-template" 49 | ], 50 | "postProcessors": [], 51 | "keepFileLink": false, 52 | "disableGitFeatures": false 53 | } 54 | } -------------------------------------------------------------------------------- /src/Auth0.OidcClient.UWP/docs-source/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/auth0/auth0-oidc-client-net/066c4fa0b3ab747bfeeac4c8c8addaf7c6ceac59/src/Auth0.OidcClient.UWP/docs-source/images/logo.png -------------------------------------------------------------------------------- /src/Auth0.OidcClient.UWP/docs-source/toc.yml: -------------------------------------------------------------------------------- 1 | - name: Documentation 2 | href: ../ 3 | - name: Android 4 | href: ../android/api/Auth0.OidcClient.html 5 | - name: iOS 6 | href: ../ios/api/Auth0.OidcClient.html 7 | - name: WPF 8 | href: ../wpf/api/Auth0.OidcClient.html 9 | - name: WinForms 10 | href: ../winforms/api/Auth0.OidcClient.html 11 | - name: UWP 12 | href: ../uwp/api/Auth0.OidcClient.html 13 | - name: MAUI 14 | href: ../maui/api/Auth0.OidcClient.html 15 | -------------------------------------------------------------------------------- /src/Auth0.OidcClient.WPF/.shiprc: -------------------------------------------------------------------------------- 1 | { 2 | "packageLabel": "wpf", 3 | "files": { 4 | ".version": [] 5 | }, 6 | "prFilters": [ 7 | { 8 | "type": "title", 9 | "args": [ 10 | "^wpf:" 11 | ], 12 | "invert": true 13 | } 14 | ] 15 | } -------------------------------------------------------------------------------- /src/Auth0.OidcClient.WPF/.version: -------------------------------------------------------------------------------- 1 | 4.3.0 -------------------------------------------------------------------------------- /src/Auth0.OidcClient.WPF/Auth0.OidcClient.WPF.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | net462;netcoreapp3.1;net8.0-windows;net9.0-windows 4 | library 5 | Auth0.OidcClient 6 | Auth0.OidcClient 7 | false 8 | true 9 | 10 | 11 | TRACE;DEBUG;WPF 12 | 13 | 14 | TRACE;WPF 15 | bin\Release\Auth0.OidcClient.xml 16 | true 17 | ..\..\build\Auth0OidcClientStrongName.snk 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /src/Auth0.OidcClient.WPF/Auth0Client.cs: -------------------------------------------------------------------------------- 1 | namespace Auth0.OidcClient 2 | { 3 | /// 4 | /// Primary class for performing authentication and authorization operations with Auth0 using the 5 | /// underlying . 6 | /// 7 | public class Auth0Client : Auth0ClientBase 8 | { 9 | /// 10 | /// Creates a new instance of the Auth0 OIDC Client. 11 | /// 12 | /// The specifying the configuration for the Auth0 OIDC Client. 13 | public Auth0Client(Auth0ClientOptions options) 14 | : base(options, "wpf") 15 | { 16 | options.Browser = options.Browser ?? new WebViewBrowser(); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/Auth0.OidcClient.WPF/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | using System.Windows; 4 | 5 | [assembly: AssemblyTitle("Auth0.OidcClient.WPF")] 6 | [assembly: AssemblyProduct("Auth0.OidcClient")] 7 | [assembly: AssemblyVersion("3.2.3")] 8 | [assembly: AssemblyFileVersion("3.2.3")] 9 | [assembly: ComVisible(false)] 10 | 11 | [assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)] 12 | -------------------------------------------------------------------------------- /src/Auth0.OidcClient.WPF/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Auth0.OidcClient.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Auth0.OidcClient.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/Auth0.OidcClient.WPF/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Auth0.OidcClient.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.3.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Auth0.OidcClient.WPF/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/Auth0.OidcClient.WPF/Themes/Generic.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | -------------------------------------------------------------------------------- /src/Auth0.OidcClient.WPF/docs-source/docfx.json: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": [ 3 | { 4 | "src": [ 5 | { 6 | "files": [ 7 | "bin/Release/**/Auth0.OidcClient.dll", 8 | "bin/Release/**/Auth0.OidcClient.Core.dll" 9 | ], 10 | "src": "../" 11 | } 12 | ], 13 | "dest": "api", 14 | "includePrivateMembers": false, 15 | "disableGitFeatures": false, 16 | "disableDefaultFilter": false, 17 | "noRestore": false, 18 | "namespaceLayout": "flattened", 19 | "memberLayout": "samePage", 20 | "EnumSortOrder": "alphabetic", 21 | "allowCompilationErrors": false 22 | } 23 | ], 24 | "build": { 25 | "content": [ 26 | { 27 | "files": [ "**/*.{md,yml}" ], 28 | "exclude": [ "_site/**", "obj/**" ] 29 | } 30 | ], 31 | "resource": [ 32 | { 33 | "files": [ 34 | "images/**" 35 | ] 36 | } 37 | ], 38 | "output": "_site", 39 | "globalMetadataFiles": [], 40 | "globalMetadata": { 41 | "_appLogoUrl": "/auth0-oidc-client-net", 42 | "_appLogoPath": "images/logo.png" 43 | }, 44 | "fileMetadataFiles": [], 45 | "template": [ 46 | "default", 47 | "modern", 48 | "../../../docs-source/custom-template" 49 | ], 50 | "postProcessors": [], 51 | "keepFileLink": false, 52 | "disableGitFeatures": false 53 | } 54 | } -------------------------------------------------------------------------------- /src/Auth0.OidcClient.WPF/docs-source/docfx.local.json: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": [ 3 | { 4 | "src": [ 5 | { 6 | "files": [ 7 | "bin/Release/**/Auth0.OidcClient.dll", 8 | "bin/Release/**/Auth0.OidcClient.Core.dll" 9 | ], 10 | "src": "../" 11 | } 12 | ], 13 | "dest": "api", 14 | "includePrivateMembers": false, 15 | "disableGitFeatures": false, 16 | "disableDefaultFilter": false, 17 | "noRestore": false, 18 | "namespaceLayout": "flattened", 19 | "memberLayout": "samePage", 20 | "EnumSortOrder": "alphabetic", 21 | "allowCompilationErrors": false 22 | } 23 | ], 24 | "build": { 25 | "content": [ 26 | { 27 | "files": [ "**/*.{md,yml}" ], 28 | "exclude": [ "_site/**", "obj/**" ] 29 | } 30 | ], 31 | "resource": [ 32 | { 33 | "files": [ 34 | "images/**" 35 | ] 36 | } 37 | ], 38 | "output": "_site", 39 | "globalMetadataFiles": [], 40 | "globalMetadata": { 41 | "_appLogoUrl": "/", 42 | "_appLogoPath": "images/logo.png" 43 | }, 44 | "fileMetadataFiles": [], 45 | "template": [ 46 | "default", 47 | "modern", 48 | "../../../docs-source/custom-template" 49 | ], 50 | "postProcessors": [], 51 | "keepFileLink": false, 52 | "disableGitFeatures": false 53 | } 54 | } -------------------------------------------------------------------------------- /src/Auth0.OidcClient.WPF/docs-source/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/auth0/auth0-oidc-client-net/066c4fa0b3ab747bfeeac4c8c8addaf7c6ceac59/src/Auth0.OidcClient.WPF/docs-source/images/logo.png -------------------------------------------------------------------------------- /src/Auth0.OidcClient.WPF/docs-source/toc.yml: -------------------------------------------------------------------------------- 1 | - name: Documentation 2 | href: ../ 3 | - name: Android 4 | href: ../android/api/Auth0.OidcClient.html 5 | - name: iOS 6 | href: ../ios/api/Auth0.OidcClient.html 7 | - name: WPF 8 | href: ../wpf/api/Auth0.OidcClient.html 9 | - name: WinForms 10 | href: ../winforms/api/Auth0.OidcClient.html 11 | - name: UWP 12 | href: ../uwp/api/Auth0.OidcClient.html 13 | - name: MAUI 14 | href: ../maui/api/Auth0.OidcClient.html 15 | -------------------------------------------------------------------------------- /src/Auth0.OidcClient.WinForms/.shiprc: -------------------------------------------------------------------------------- 1 | { 2 | "packageLabel": "winforms", 3 | "files": { 4 | ".version": [] 5 | }, 6 | "prFilters": [ 7 | { 8 | "type": "title", 9 | "args": [ 10 | "^winforms:" 11 | ], 12 | "invert": true 13 | } 14 | ] 15 | } -------------------------------------------------------------------------------- /src/Auth0.OidcClient.WinForms/.version: -------------------------------------------------------------------------------- 1 | 4.3.0 -------------------------------------------------------------------------------- /src/Auth0.OidcClient.WinForms/Auth0.OidcClient.WinForms.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | net462;netcoreapp3.1;net8.0-windows;net9.0-windows 4 | Library 5 | Auth0.OidcClient 6 | Auth0.OidcClient 7 | false 8 | true 9 | 10 | 11 | TRACE;DEBUG;WINFORMS 12 | 13 | 14 | TRACE;WINFORMS 15 | bin\Release\Auth0.OidcClient.xml 16 | true 17 | ..\..\build\Auth0OidcClientStrongName.snk 18 | 19 | 20 | app.manifest 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /src/Auth0.OidcClient.WinForms/Auth0Client.cs: -------------------------------------------------------------------------------- 1 | namespace Auth0.OidcClient 2 | { 3 | /// 4 | /// Primary class for performing authentication and authorization operations with Auth0 using the 5 | /// underlying . 6 | /// 7 | public class Auth0Client : Auth0ClientBase 8 | { 9 | /// 10 | /// Creates a new instance of the Auth0 OIDC Client. 11 | /// 12 | /// The specifying the configuration for the Auth0 OIDC Client. 13 | public Auth0Client(Auth0ClientOptions options) 14 | : base(options, "winforms") 15 | { 16 | options.Browser = options.Browser ?? new WebViewBrowser(); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/Auth0.OidcClient.WinForms/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | [assembly: AssemblyTitle("Auth0.OidcClient.WinForms")] 5 | [assembly: AssemblyProduct("Auth0.OidcClient")] 6 | [assembly: AssemblyVersion("3.2.4")] 7 | [assembly: AssemblyFileVersion("3.2.4")] 8 | [assembly: ComVisible(false)] 9 | -------------------------------------------------------------------------------- /src/Auth0.OidcClient.WinForms/WebViewBrowser.cs: -------------------------------------------------------------------------------- 1 | using Duende.IdentityModel.OidcClient.Browser; 2 | using Microsoft.Web.WebView2.WinForms; 3 | using System; 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | using System.Windows.Forms; 7 | 8 | namespace Auth0.OidcClient 9 | { 10 | /// 11 | /// Implements the interface using the control. 12 | /// 13 | public class WebViewBrowser : IBrowser 14 | { 15 | private readonly Func
_formFactory; 16 | 17 | /// 18 | /// Creates a new instance of with a specified function to create the 19 | /// used to host the control. 20 | /// 21 | /// The function used to create the that will host the control. 22 | public WebViewBrowser(Func formFactory) 23 | { 24 | _formFactory = formFactory; 25 | } 26 | 27 | /// 28 | /// Creates a new instance of allowing parts of the container to be set. 29 | /// 30 | /// Optional title for the form - defaults to 'Authenticating...'. 31 | /// Optional width for the form in pixels. Defaults to 1024. 32 | /// Optional height for the form in pixels. Defaults to 768. 33 | public WebViewBrowser(string title = "Authenticating...", int width = 1024, int height = 768) 34 | : this(() => new Form 35 | { 36 | Name = "WebAuthentication", 37 | Text = title, 38 | Width = width, 39 | Height = height 40 | }) 41 | { 42 | } 43 | 44 | /// 45 | public async Task InvokeAsync(BrowserOptions options, CancellationToken cancellationToken = default) 46 | { 47 | var tcs = new TaskCompletionSource(); 48 | 49 | var window = _formFactory(); 50 | #pragma warning disable 618 51 | var webView = new WebView2 { Dock = DockStyle.Fill }; 52 | 53 | webView.NavigationStarting += (sender, e) => 54 | { 55 | if (e.Uri.StartsWith(options.EndUrl)) 56 | { 57 | tcs.SetResult(new BrowserResult { ResultType = BrowserResultType.Success, Response = e.Uri.ToString() }); 58 | window.Close(); 59 | } 60 | }; 61 | 62 | window.Closing += (sender, e) => 63 | { 64 | if (!tcs.Task.IsCompleted) 65 | tcs.SetResult(new BrowserResult { ResultType = BrowserResultType.UserCancel }); 66 | }; 67 | 68 | window.Controls.Add(webView); 69 | 70 | window.Show(); 71 | 72 | await webView.EnsureCoreWebView2Async(); 73 | webView.CoreWebView2.Navigate(options.StartUrl); 74 | 75 | return await tcs.Task; 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/Auth0.OidcClient.WinForms/docs-source/docfx.json: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": [ 3 | { 4 | "src": [ 5 | { 6 | "files": [ 7 | "bin/Release/**/Auth0.OidcClient.dll", 8 | "bin/Release/**/Auth0.OidcClient.Core.dll" 9 | ], 10 | "src": "../" 11 | } 12 | ], 13 | "dest": "api", 14 | "includePrivateMembers": false, 15 | "disableGitFeatures": false, 16 | "disableDefaultFilter": false, 17 | "noRestore": false, 18 | "namespaceLayout": "flattened", 19 | "memberLayout": "samePage", 20 | "EnumSortOrder": "alphabetic", 21 | "allowCompilationErrors": false 22 | } 23 | ], 24 | "build": { 25 | "content": [ 26 | { 27 | "files": [ "**/*.{md,yml}" ], 28 | "exclude": [ "_site/**", "obj/**" ] 29 | } 30 | ], 31 | "resource": [ 32 | { 33 | "files": [ 34 | "images/**" 35 | ] 36 | } 37 | ], 38 | "output": "_site", 39 | "globalMetadataFiles": [], 40 | "globalMetadata": { 41 | "_appLogoUrl": "/auth0-oidc-client-net", 42 | "_appLogoPath": "images/logo.png" 43 | }, 44 | "fileMetadataFiles": [], 45 | "template": [ 46 | "default", 47 | "modern", 48 | "../../../docs-source/custom-template" 49 | ], 50 | "postProcessors": [], 51 | "keepFileLink": false, 52 | "disableGitFeatures": false 53 | } 54 | } -------------------------------------------------------------------------------- /src/Auth0.OidcClient.WinForms/docs-source/docfx.local.json: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": [ 3 | { 4 | "src": [ 5 | { 6 | "files": [ 7 | "bin/Release/**/Auth0.OidcClient.dll", 8 | "bin/Release/**/Auth0.OidcClient.Core.dll" 9 | ], 10 | "src": "../" 11 | } 12 | ], 13 | "dest": "api", 14 | "includePrivateMembers": false, 15 | "disableGitFeatures": false, 16 | "disableDefaultFilter": false, 17 | "noRestore": false, 18 | "namespaceLayout": "flattened", 19 | "memberLayout": "samePage", 20 | "EnumSortOrder": "alphabetic", 21 | "allowCompilationErrors": false 22 | } 23 | ], 24 | "build": { 25 | "content": [ 26 | { 27 | "files": [ "**/*.{md,yml}" ], 28 | "exclude": [ "_site/**", "obj/**" ] 29 | } 30 | ], 31 | "resource": [ 32 | { 33 | "files": [ 34 | "images/**" 35 | ] 36 | } 37 | ], 38 | "output": "_site", 39 | "globalMetadataFiles": [], 40 | "globalMetadata": { 41 | "_appLogoUrl": "/", 42 | "_appLogoPath": "images/logo.png" 43 | }, 44 | "fileMetadataFiles": [], 45 | "template": [ 46 | "default", 47 | "modern", 48 | "../../../docs-source/custom-template" 49 | ], 50 | "postProcessors": [], 51 | "keepFileLink": false, 52 | "disableGitFeatures": false 53 | } 54 | } -------------------------------------------------------------------------------- /src/Auth0.OidcClient.WinForms/docs-source/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/auth0/auth0-oidc-client-net/066c4fa0b3ab747bfeeac4c8c8addaf7c6ceac59/src/Auth0.OidcClient.WinForms/docs-source/images/logo.png -------------------------------------------------------------------------------- /src/Auth0.OidcClient.WinForms/docs-source/toc.yml: -------------------------------------------------------------------------------- 1 | - name: Documentation 2 | href: ../ 3 | - name: Android 4 | href: ../android/api/Auth0.OidcClient.html 5 | - name: iOS 6 | href: ../ios/api/Auth0.OidcClient.html 7 | - name: WPF 8 | href: ../wpf/api/Auth0.OidcClient.html 9 | - name: WinForms 10 | href: ../winforms/api/Auth0.OidcClient.html 11 | - name: UWP 12 | href: ../uwp/api/Auth0.OidcClient.html 13 | - name: MAUI 14 | href: ../maui/api/Auth0.OidcClient.html 15 | -------------------------------------------------------------------------------- /src/Auth0.OidcClient.iOS/.shiprc: -------------------------------------------------------------------------------- 1 | { 2 | "packageLabel": "ios", 3 | "files": { 4 | ".version": [] 5 | }, 6 | "prFilters": [ 7 | { 8 | "type": "title", 9 | "args": [ 10 | "^ios:" 11 | ], 12 | "invert": true 13 | } 14 | ] 15 | } -------------------------------------------------------------------------------- /src/Auth0.OidcClient.iOS/.version: -------------------------------------------------------------------------------- 1 | 4.3.0 -------------------------------------------------------------------------------- /src/Auth0.OidcClient.iOS/ASWebAuthenticationSessionOptions.cs: -------------------------------------------------------------------------------- 1 | namespace Auth0.OidcClient 2 | { 3 | /// 4 | /// Specifies options that can be passed to implementations. 5 | /// 6 | public class ASWebAuthenticationSessionOptions 7 | { 8 | /// 9 | /// Specify whether or not EphemeralWebBrowserSessions should be preferred. Defaults to false. 10 | /// 11 | /// 12 | /// Setting to true will disable Single Sign On (SSO) on iOS 13+. 13 | /// As a consequence of that, it will also prevent from showing the popup that's being used to ask consent for using Auth0 to sign in. 14 | /// 15 | public bool PrefersEphemeralWebBrowserSession { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Auth0.OidcClient.iOS/ActivityMediator.cs: -------------------------------------------------------------------------------- 1 | namespace Auth0.OidcClient 2 | { 3 | /// 4 | /// Facilitates communication between the app entry point and the callback function. 5 | /// 6 | public class ActivityMediator 7 | { 8 | private static ActivityMediator _instance; 9 | private ActivityMediator() { } 10 | 11 | /// 12 | /// Singleton instance of the class. 13 | /// 14 | public static ActivityMediator Instance 15 | { 16 | get { return _instance ?? (_instance = new ActivityMediator()); } 17 | } 18 | 19 | /// 20 | /// Method signature required for methods subscribing to the ActivityMessageReceived event. 21 | /// 22 | /// Message that has been received. 23 | public delegate void MessageReceivedEventHandler(string message); 24 | 25 | /// 26 | /// Event listener for subscribing to message received events. 27 | /// 28 | public event MessageReceivedEventHandler ActivityMessageReceived; 29 | 30 | /// 31 | /// Send a response message to all listeners. 32 | /// 33 | /// Response message to send to all listeners. 34 | public void Send(string response) 35 | { 36 | ActivityMessageReceived?.Invoke(response); 37 | } 38 | 39 | /// 40 | /// Send a cancellation response message "UserCancel" to all listeners. 41 | /// 42 | public void Cancel() 43 | { 44 | Send("UserCancel"); 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /src/Auth0.OidcClient.iOS/Auth0.OidcClient.iOS.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | xamarin.ios10;net8.0-ios;net9.0-ios 4 | Auth0.OidcClient 5 | Auth0.OidcClient 6 | Auth0.OidcClient.iOS 7 | Auth0.OidcClient 8 | 3.6.0 9 | 3.6.0 10 | 3.6.0 11 | en 12 | false 13 | $(DefineConstants); 14 | default 15 | 16 | 17 | portable 18 | true 19 | false 20 | 21 | 22 | portable 23 | true 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | {1F79DB59-F3A8-45B7-972B-ECD15259D1C9} 38 | Auth0.OidcClient.Core 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /src/Auth0.OidcClient.iOS/Auth0Client.cs: -------------------------------------------------------------------------------- 1 | using static Foundation.NSBundle; 2 | 3 | namespace Auth0.OidcClient 4 | { 5 | /// 6 | /// Primary class for performing authentication and authorization operations with Auth0 using the 7 | /// underlying . 8 | /// 9 | public class Auth0Client : Auth0ClientBase 10 | { 11 | /// 12 | /// Creates a new instance of the Auth0 OIDC Client. 13 | /// 14 | /// The specifying the configuration for the Auth0 OIDC Client. 15 | public Auth0Client(Auth0ClientOptions options) 16 | : base(options, "xamarin-ios") 17 | { 18 | options.Browser = options.Browser ?? new AutoSelectBrowser(); 19 | var callbackUrl = $"{MainBundle.BundleIdentifier}://{options.Domain}/ios/{MainBundle.BundleIdentifier}/callback"; 20 | options.RedirectUri = options.RedirectUri ?? callbackUrl; 21 | options.PostLogoutRedirectUri = options.PostLogoutRedirectUri ?? callbackUrl; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Auth0.OidcClient.iOS/AutoSelectBrowser.cs: -------------------------------------------------------------------------------- 1 | using Duende.IdentityModel.OidcClient.Browser; 2 | using System.Threading; 3 | using System.Threading.Tasks; 4 | using UIKit; 5 | 6 | namespace Auth0.OidcClient 7 | { 8 | /// 9 | /// Implements the interface using the best available option for the current iOS version. 10 | /// 11 | public class AutoSelectBrowser : IOSBrowserBase 12 | { 13 | /// 14 | protected override Task Launch(BrowserOptions options, CancellationToken cancellationToken = default) 15 | { 16 | // For iOS 12+ use ASWebAuthenticationSession 17 | if (UIDevice.CurrentDevice.CheckSystemVersion(12, 0)) 18 | return ASWebAuthenticationSessionBrowser.Start(options); 19 | 20 | // For iOS 11 use SFAuthenticationSession 21 | if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0)) 22 | return SFAuthenticationSessionBrowser.Start(options); 23 | 24 | // For iOS 10 and earlier use SFSafariViewController 25 | return SFSafariViewControllerBrowser.Start(options); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Auth0.OidcClient.iOS/SFAuthenticationSessionBrowser.cs: -------------------------------------------------------------------------------- 1 | using Foundation; 2 | using Duende.IdentityModel.OidcClient.Browser; 3 | using SafariServices; 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | 7 | namespace Auth0.OidcClient 8 | { 9 | /// 10 | /// Implements the Browser using for support on iOS 11. 11 | /// 12 | public class SFAuthenticationSessionBrowser : IOSBrowserBase 13 | { 14 | /// 15 | protected override Task Launch(BrowserOptions options, CancellationToken cancellationToken = default) 16 | { 17 | return Start(options); 18 | } 19 | 20 | internal static Task Start(BrowserOptions options) 21 | { 22 | var tcs = new TaskCompletionSource(); 23 | 24 | SFAuthenticationSession sfWebAuthenticationSession = null; 25 | sfWebAuthenticationSession = new SFAuthenticationSession( 26 | new NSUrl(options.StartUrl), 27 | options.EndUrl, 28 | (callbackUrl, error) => 29 | { 30 | tcs.SetResult(CreateBrowserResult(callbackUrl, error)); 31 | sfWebAuthenticationSession.Dispose(); 32 | }); 33 | 34 | sfWebAuthenticationSession.Start(); 35 | 36 | return tcs.Task; 37 | } 38 | 39 | private static BrowserResult CreateBrowserResult(NSUrl callbackUrl, NSError error) 40 | { 41 | if (error == null) 42 | return Success(callbackUrl.AbsoluteString); 43 | 44 | if (error.Code == (long)SFAuthenticationError.CanceledLogin) 45 | return Canceled(); 46 | 47 | return UnknownError(error.ToString()); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/Auth0.OidcClient.iOS/SFSafariViewControllerBrowser.cs: -------------------------------------------------------------------------------- 1 | using Foundation; 2 | using Duende.IdentityModel.OidcClient.Browser; 3 | using SafariServices; 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | using UIKit; 7 | 8 | namespace Auth0.OidcClient 9 | { 10 | /// 11 | /// Implements the interface using for support on iOS 10 and earlier. 12 | /// 13 | public class SFSafariViewControllerBrowser : IOSBrowserBase 14 | { 15 | /// 16 | protected override Task Launch(BrowserOptions options, CancellationToken cancellationToken = default) 17 | { 18 | return Start(options); 19 | } 20 | 21 | internal static Task Start(BrowserOptions options) 22 | { 23 | var tcs = new TaskCompletionSource(); 24 | 25 | // Create Safari controller 26 | var safari = new SFSafariViewController(new NSUrl(options.StartUrl)) 27 | { 28 | Delegate = new SafariViewControllerDelegate() 29 | }; 30 | 31 | async void Callback(string response) 32 | { 33 | ActivityMediator.Instance.ActivityMessageReceived -= Callback; 34 | 35 | if (response == "UserCancel") 36 | { 37 | tcs.SetResult(Canceled()); 38 | } 39 | else 40 | { 41 | await safari.DismissViewControllerAsync(true); // Close Safari 42 | safari.Dispose(); 43 | tcs.SetResult(Success(response)); 44 | } 45 | } 46 | 47 | ActivityMediator.Instance.ActivityMessageReceived += Callback; 48 | 49 | // Launch Safari 50 | FindRootController().PresentViewController(safari, true, null); 51 | 52 | return tcs.Task; 53 | } 54 | 55 | private static UIViewController FindRootController() 56 | { 57 | var vc = UIApplication.SharedApplication.KeyWindow.RootViewController; 58 | while (vc.PresentedViewController != null) 59 | vc = vc.PresentedViewController; 60 | return vc; 61 | } 62 | 63 | class SafariViewControllerDelegate : SFSafariViewControllerDelegate 64 | { 65 | public override void DidFinish(SFSafariViewController controller) 66 | { 67 | ActivityMediator.Instance.Send("UserCancel"); 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/Auth0.OidcClient.iOS/docs-source/docfx.json: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": [ 3 | { 4 | "src": [ 5 | { 6 | "files": [ 7 | "bin/Release/**/Auth0.OidcClient.dll", 8 | "bin/Release/**/Auth0.OidcClient.Core.dll" 9 | ], 10 | "src": "../" 11 | } 12 | ], 13 | "dest": "api", 14 | "includePrivateMembers": false, 15 | "disableGitFeatures": false, 16 | "disableDefaultFilter": false, 17 | "noRestore": false, 18 | "namespaceLayout": "flattened", 19 | "memberLayout": "samePage", 20 | "EnumSortOrder": "alphabetic", 21 | "allowCompilationErrors": false 22 | } 23 | ], 24 | "build": { 25 | "content": [ 26 | { 27 | "files": [ "**/*.{md,yml}" ], 28 | "exclude": [ "_site/**", "obj/**" ] 29 | } 30 | ], 31 | "resource": [ 32 | { 33 | "files": [ 34 | "images/**" 35 | ] 36 | } 37 | ], 38 | "output": "_site", 39 | "globalMetadataFiles": [], 40 | "globalMetadata": { 41 | "_appLogoUrl": "/auth0-oidc-client-net", 42 | "_appLogoPath": "images/logo.png" 43 | }, 44 | "fileMetadataFiles": [], 45 | "template": [ 46 | "default", 47 | "modern", 48 | "../../../docs-source/custom-template" 49 | ], 50 | "postProcessors": [], 51 | "keepFileLink": false, 52 | "disableGitFeatures": false 53 | } 54 | } -------------------------------------------------------------------------------- /src/Auth0.OidcClient.iOS/docs-source/docfx.local.json: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": [ 3 | { 4 | "src": [ 5 | { 6 | "files": [ 7 | "bin/Release/**/Auth0.OidcClient.dll", 8 | "bin/Release/**/Auth0.OidcClient.Core.dll" 9 | ], 10 | "src": "../" 11 | } 12 | ], 13 | "dest": "api", 14 | "includePrivateMembers": false, 15 | "disableGitFeatures": false, 16 | "disableDefaultFilter": false, 17 | "noRestore": false, 18 | "namespaceLayout": "flattened", 19 | "memberLayout": "samePage", 20 | "EnumSortOrder": "alphabetic", 21 | "allowCompilationErrors": false 22 | } 23 | ], 24 | "build": { 25 | "content": [ 26 | { 27 | "files": [ "**/*.{md,yml}" ], 28 | "exclude": [ "_site/**", "obj/**" ] 29 | } 30 | ], 31 | "resource": [ 32 | { 33 | "files": [ 34 | "images/**" 35 | ] 36 | } 37 | ], 38 | "output": "_site", 39 | "globalMetadataFiles": [], 40 | "globalMetadata": { 41 | "_appLogoUrl": "/", 42 | "_appLogoPath": "images/logo.png" 43 | }, 44 | "fileMetadataFiles": [], 45 | "template": [ 46 | "default", 47 | "modern", 48 | "../../../docs-source/custom-template" 49 | ], 50 | "postProcessors": [], 51 | "keepFileLink": false, 52 | "disableGitFeatures": false 53 | } 54 | } -------------------------------------------------------------------------------- /src/Auth0.OidcClient.iOS/docs-source/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/auth0/auth0-oidc-client-net/066c4fa0b3ab747bfeeac4c8c8addaf7c6ceac59/src/Auth0.OidcClient.iOS/docs-source/images/logo.png -------------------------------------------------------------------------------- /src/Auth0.OidcClient.iOS/docs-source/toc.yml: -------------------------------------------------------------------------------- 1 | - name: Documentation 2 | href: ../ 3 | - name: Android 4 | href: ../android/api/Auth0.OidcClient.html 5 | - name: iOS 6 | href: ../ios/api/Auth0.OidcClient.html 7 | - name: WPF 8 | href: ../wpf/api/Auth0.OidcClient.html 9 | - name: WinForms 10 | href: ../winforms/api/Auth0.OidcClient.html 11 | - name: UWP 12 | href: ../uwp/api/Auth0.OidcClient.html 13 | - name: MAUI 14 | href: ../maui/api/Auth0.OidcClient.html 15 | -------------------------------------------------------------------------------- /src/Auth0.OidcClient.iOS/iOSBrowserBase.cs: -------------------------------------------------------------------------------- 1 | using Duende.IdentityModel.OidcClient.Browser; 2 | using System; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | 6 | namespace Auth0.OidcClient 7 | { 8 | /// 9 | /// Provides common logic for iOS platform. 10 | /// 11 | public abstract class IOSBrowserBase : IBrowser 12 | { 13 | /// 14 | public Task InvokeAsync(BrowserOptions options, CancellationToken cancellationToken = default) 15 | { 16 | if (string.IsNullOrWhiteSpace(options.StartUrl)) 17 | throw new ArgumentException("Missing StartUrl", nameof(options)); 18 | 19 | if (string.IsNullOrWhiteSpace(options.EndUrl)) 20 | throw new ArgumentException("Missing EndUrl", nameof(options)); 21 | 22 | return Launch(options, cancellationToken); 23 | } 24 | 25 | /// 26 | /// Launch a browser with the options and URL specified by the . 27 | /// 28 | /// specifying the parameters to be used in launching the browser. 29 | /// Optional that could be used to cancel the browser. 30 | /// A that will contain a with details of 31 | /// wether the launch process succeeded or not by way of a . 32 | protected abstract Task Launch(BrowserOptions options, CancellationToken cancellationToken = default); 33 | 34 | internal static BrowserResult Canceled() 35 | { 36 | return new BrowserResult 37 | { 38 | ResultType = BrowserResultType.UserCancel 39 | }; 40 | } 41 | 42 | internal static BrowserResult UnknownError(string error) 43 | { 44 | return new BrowserResult 45 | { 46 | ResultType = BrowserResultType.UnknownError, 47 | Error = error 48 | }; 49 | } 50 | 51 | internal static BrowserResult Success(string response) 52 | { 53 | return new BrowserResult 54 | { 55 | Response = response, 56 | ResultType = BrowserResultType.Success 57 | }; 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /test/Android/Properties/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /test/Android/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | [assembly: AssemblyTitle("AndroidTestApp")] 5 | [assembly: ComVisible(false)] 6 | [assembly: AssemblyVersion("1.0.0.0")] 7 | [assembly: AssemblyFileVersion("1.0.0.0")] 8 | -------------------------------------------------------------------------------- /test/Android/Resources/drawable/Icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/auth0/auth0-oidc-client-net/066c4fa0b3ab747bfeeac4c8c8addaf7c6ceac59/test/Android/Resources/drawable/Icon.png -------------------------------------------------------------------------------- /test/Android/Resources/layout/Main.axml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 14 |