├── .gitattributes ├── .gitignore ├── .travis.yml ├── AspNet.Security.OpenIdConnect.Samples.sln ├── NuGet.config ├── README.md ├── build.cmd ├── build.ps1 ├── build.sh ├── build └── dependencies.props ├── makefile.shade └── samples ├── Cordova ├── Backend │ ├── Backend.csproj │ ├── Certificate.pfx │ ├── Controllers │ │ ├── AuthenticationController.cs │ │ ├── AuthorizationController.cs │ │ └── ResourceController.cs │ ├── Extensions │ │ ├── AppBuilderExtensions.cs │ │ └── HttpContextExtensions.cs │ ├── Helpers │ │ └── FormValueRequiredAttribute.cs │ ├── Models │ │ ├── Application.cs │ │ └── ApplicationContext.cs │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── Providers │ │ └── AuthorizationProvider.cs │ ├── Startup.cs │ ├── Views │ │ ├── Shared │ │ │ ├── Authorize.cshtml │ │ │ ├── Error.cshtml │ │ │ ├── Logout.cshtml │ │ │ ├── SignIn.cshtml │ │ │ └── _Layout.cshtml │ │ └── _ViewStart.cshtml │ ├── web.config │ └── wwwroot │ │ ├── fonts │ │ ├── glyphicons-halflings-regular.eot │ │ ├── glyphicons-halflings-regular.svg │ │ ├── glyphicons-halflings-regular.ttf │ │ └── glyphicons-halflings-regular.woff │ │ ├── scripts │ │ ├── bootstrap.js │ │ ├── bootstrap.min.js │ │ ├── jquery-1.9.0.intellisense.js │ │ ├── jquery-1.9.0.js │ │ ├── jquery-1.9.0.min.js │ │ └── jquery-1.9.0.min.map │ │ └── stylesheets │ │ ├── bootstrap-theme.css │ │ ├── bootstrap-theme.css.map │ │ ├── bootstrap-theme.min.css │ │ ├── bootstrap.css │ │ ├── bootstrap.css.map │ │ ├── bootstrap.min.css │ │ └── jumbotron-narrow.css └── MobileApp │ ├── .gitignore │ ├── MobileApp.jsproj │ ├── bower.json │ ├── build.json │ ├── config.xml │ ├── gruntfile.js │ ├── merges │ ├── android │ │ └── scripts │ │ │ ├── android2.3-jscompat.js │ │ │ └── platformOverrides.js │ └── windows │ │ └── scripts │ │ ├── platformOverrides.js │ │ └── winstore-jscompat.js │ ├── package.json │ ├── plugins │ ├── cordova-plugin-inappbrowser │ │ ├── CONTRIBUTING.md │ │ ├── LICENSE │ │ ├── NOTICE │ │ ├── README.md │ │ ├── RELEASENOTES.md │ │ ├── doc │ │ │ ├── de │ │ │ │ ├── README.md │ │ │ │ └── index.md │ │ │ ├── es │ │ │ │ ├── README.md │ │ │ │ └── index.md │ │ │ ├── fr │ │ │ │ ├── README.md │ │ │ │ └── index.md │ │ │ ├── it │ │ │ │ ├── README.md │ │ │ │ └── index.md │ │ │ ├── ja │ │ │ │ ├── README.md │ │ │ │ └── index.md │ │ │ ├── ko │ │ │ │ ├── README.md │ │ │ │ └── index.md │ │ │ ├── pl │ │ │ │ ├── README.md │ │ │ │ └── index.md │ │ │ ├── ru │ │ │ │ └── index.md │ │ │ └── zh │ │ │ │ ├── README.md │ │ │ │ └── index.md │ │ ├── package.json │ │ ├── plugin.xml │ │ ├── src │ │ │ ├── amazon │ │ │ │ ├── InAppBrowser.java │ │ │ │ └── InAppChromeClient.java │ │ │ ├── android │ │ │ │ ├── InAppBrowser.java │ │ │ │ ├── InAppBrowserDialog.java │ │ │ │ ├── InAppChromeClient.java │ │ │ │ └── res │ │ │ │ │ ├── drawable-hdpi │ │ │ │ │ ├── ic_action_next_item.png │ │ │ │ │ ├── ic_action_previous_item.png │ │ │ │ │ └── ic_action_remove.png │ │ │ │ │ ├── drawable-mdpi │ │ │ │ │ ├── ic_action_next_item.png │ │ │ │ │ ├── ic_action_previous_item.png │ │ │ │ │ └── ic_action_remove.png │ │ │ │ │ ├── drawable-xhdpi │ │ │ │ │ ├── ic_action_next_item.png │ │ │ │ │ ├── ic_action_previous_item.png │ │ │ │ │ └── ic_action_remove.png │ │ │ │ │ └── drawable-xxhdpi │ │ │ │ │ ├── ic_action_next_item.png │ │ │ │ │ ├── ic_action_previous_item.png │ │ │ │ │ └── ic_action_remove.png │ │ │ ├── blackberry10 │ │ │ │ ├── README.md │ │ │ │ └── doc │ │ │ │ │ ├── de │ │ │ │ │ └── README.md │ │ │ │ │ ├── es │ │ │ │ │ └── README.md │ │ │ │ │ ├── fr │ │ │ │ │ └── README.md │ │ │ │ │ ├── it │ │ │ │ │ └── README.md │ │ │ │ │ ├── ja │ │ │ │ │ └── README.md │ │ │ │ │ ├── ko │ │ │ │ │ └── README.md │ │ │ │ │ ├── pl │ │ │ │ │ └── README.md │ │ │ │ │ └── zh │ │ │ │ │ └── README.md │ │ │ ├── browser │ │ │ │ └── InAppBrowserProxy.js │ │ │ ├── firefoxos │ │ │ │ └── InAppBrowserProxy.js │ │ │ ├── ios │ │ │ │ ├── CDVInAppBrowser.h │ │ │ │ └── CDVInAppBrowser.m │ │ │ ├── ubuntu │ │ │ │ ├── InAppBrowser.qml │ │ │ │ ├── InAppBrowser_escapeScript.js │ │ │ │ ├── close.png │ │ │ │ ├── inappbrowser.cpp │ │ │ │ └── inappbrowser.h │ │ │ ├── windows │ │ │ │ └── InAppBrowserProxy.js │ │ │ └── wp │ │ │ │ └── InAppBrowser.cs │ │ ├── tests │ │ │ ├── plugin.xml │ │ │ ├── resources │ │ │ │ ├── inject.css │ │ │ │ ├── inject.html │ │ │ │ ├── inject.js │ │ │ │ ├── local.html │ │ │ │ ├── local.pdf │ │ │ │ └── video.html │ │ │ └── tests.js │ │ └── www │ │ │ ├── inappbrowser.css │ │ │ ├── inappbrowser.js │ │ │ └── windows8 │ │ │ └── InAppBrowserProxy.js │ ├── cordova-plugin-whitelist │ │ ├── CONTRIBUTING.md │ │ ├── LICENSE │ │ ├── NOTICE │ │ ├── README.md │ │ ├── RELEASENOTES.md │ │ ├── doc │ │ │ ├── de │ │ │ │ └── README.md │ │ │ ├── es │ │ │ │ └── README.md │ │ │ ├── fr │ │ │ │ └── README.md │ │ │ ├── it │ │ │ │ └── README.md │ │ │ ├── ja │ │ │ │ └── README.md │ │ │ ├── ko │ │ │ │ └── README.md │ │ │ ├── pl │ │ │ │ └── README.md │ │ │ └── zh │ │ │ │ └── README.md │ │ ├── package.json │ │ ├── plugin.xml │ │ ├── src │ │ │ └── android │ │ │ │ └── WhitelistPlugin.java │ │ └── whitelist.js │ └── fetch.json │ ├── res │ ├── icons │ │ ├── android │ │ │ ├── icon-36-ldpi.png │ │ │ ├── icon-48-mdpi.png │ │ │ ├── icon-72-hdpi.png │ │ │ └── icon-96-xhdpi.png │ │ ├── ios │ │ │ ├── icon-40-2x.png │ │ │ ├── icon-40.png │ │ │ ├── icon-50-2x.png │ │ │ ├── icon-50.png │ │ │ ├── icon-57-2x.png │ │ │ ├── icon-57.png │ │ │ ├── icon-60-2x.png │ │ │ ├── icon-60-3x.png │ │ │ ├── icon-60.png │ │ │ ├── icon-72-2x.png │ │ │ ├── icon-72.png │ │ │ ├── icon-76-2x.png │ │ │ ├── icon-76.png │ │ │ ├── icon-small-2x.png │ │ │ └── icon-small.png │ │ ├── windows │ │ │ ├── Square150x150Logo.scale-100.png │ │ │ ├── Square150x150Logo.scale-240.png │ │ │ ├── Square30x30Logo.scale-100.png │ │ │ ├── Square310x310Logo.scale-100.png │ │ │ ├── Square44x44Logo.scale-240.png │ │ │ ├── Square70x70Logo.scale-100.png │ │ │ ├── Square71x71Logo.scale-240.png │ │ │ ├── StoreLogo.scale-100.png │ │ │ ├── StoreLogo.scale-240.png │ │ │ ├── Wide310x150Logo.scale-100.png │ │ │ └── Wide310x150Logo.scale-240.png │ │ └── wp8 │ │ │ ├── ApplicationIcon.png │ │ │ └── Background.png │ ├── native │ │ └── android │ │ │ └── ant.properties │ └── screens │ │ ├── android │ │ ├── screen-hdpi-landscape.png │ │ ├── screen-hdpi-portrait.png │ │ ├── screen-ldpi-landscape.png │ │ ├── screen-ldpi-portrait.png │ │ ├── screen-mdpi-landscape.png │ │ ├── screen-mdpi-portrait.png │ │ ├── screen-xhdpi-landscape.png │ │ └── screen-xhdpi-portrait.png │ │ ├── ios │ │ ├── screen-ipad-landscape-2x.png │ │ ├── screen-ipad-landscape.png │ │ ├── screen-ipad-portrait-2x.png │ │ ├── screen-ipad-portrait.png │ │ ├── screen-iphone-568h-2x.png │ │ ├── screen-iphone-landscape-736h.png │ │ ├── screen-iphone-portrait-2x.png │ │ ├── screen-iphone-portrait-667h.png │ │ ├── screen-iphone-portrait-736h.png │ │ └── screen-iphone-portrait.png │ │ ├── windows │ │ ├── SplashScreen.scale-100.png │ │ ├── SplashScreen.scale-240.png │ │ └── SplashScreenPhone.scale-240.png │ │ └── wp8 │ │ └── SplashScreenImage.jpg │ ├── taco.json │ └── www │ ├── css │ └── ionic.min.css │ ├── fonts │ ├── ionicons.eot │ ├── ionicons.svg │ ├── ionicons.ttf │ └── ionicons.woff │ ├── index.html │ └── scripts │ ├── controllers │ └── authController.js │ ├── init.js │ ├── libraries │ ├── angular-jwt.min.js │ ├── angular-local-storage.min.js │ ├── angular.min.js │ ├── angular.min.js.map │ └── ionic.bundle.min.js │ └── services │ ├── authInterceptorService.js │ ├── authService.js │ └── utilitiesService.js ├── Mvc ├── Mvc.Client │ ├── Controllers │ │ ├── AuthenticationController.cs │ │ └── HomeController.cs │ ├── Mvc.Client.csproj │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── Startup.cs │ ├── Views │ │ ├── Shared │ │ │ ├── Home.cshtml │ │ │ └── _Layout.cshtml │ │ └── _ViewStart.cshtml │ ├── web.config │ └── wwwroot │ │ ├── fonts │ │ ├── glyphicons-halflings-regular.eot │ │ ├── glyphicons-halflings-regular.svg │ │ ├── glyphicons-halflings-regular.ttf │ │ └── glyphicons-halflings-regular.woff │ │ ├── scripts │ │ ├── bootstrap.js │ │ ├── bootstrap.min.js │ │ ├── jquery-1.9.0.intellisense.js │ │ ├── jquery-1.9.0.js │ │ ├── jquery-1.9.0.min.js │ │ └── jquery-1.9.0.min.map │ │ └── stylesheets │ │ ├── bootstrap-theme.css │ │ ├── bootstrap-theme.css.map │ │ ├── bootstrap-theme.min.css │ │ ├── bootstrap.css │ │ ├── bootstrap.css.map │ │ ├── bootstrap.min.css │ │ └── jumbotron-narrow.css └── Mvc.Server │ ├── Certificate.pfx │ ├── Controllers │ ├── AuthenticationController.cs │ ├── AuthorizationController.cs │ └── ResourceController.cs │ ├── Extensions │ ├── AppBuilderExtensions.cs │ └── HttpContextExtensions.cs │ ├── Helpers │ └── FormValueRequiredAttribute.cs │ ├── Models │ ├── Application.cs │ └── ApplicationContext.cs │ ├── Mvc.Server.csproj │ ├── Program.cs │ ├── Properties │ └── launchSettings.json │ ├── Providers │ └── AuthorizationProvider.cs │ ├── Startup.cs │ ├── Views │ ├── Shared │ │ ├── Authorize.cshtml │ │ ├── Error.cshtml │ │ ├── Logout.cshtml │ │ ├── SignIn.cshtml │ │ └── _Layout.cshtml │ └── _ViewStart.cshtml │ ├── web.config │ └── wwwroot │ ├── fonts │ ├── glyphicons-halflings-regular.eot │ ├── glyphicons-halflings-regular.svg │ ├── glyphicons-halflings-regular.ttf │ └── glyphicons-halflings-regular.woff │ ├── scripts │ ├── bootstrap.js │ ├── bootstrap.min.js │ ├── jquery-1.9.0.intellisense.js │ ├── jquery-1.9.0.js │ ├── jquery-1.9.0.min.js │ └── jquery-1.9.0.min.map │ └── stylesheets │ ├── bootstrap-theme.css │ ├── bootstrap-theme.css.map │ ├── bootstrap-theme.min.css │ ├── bootstrap.css │ ├── bootstrap.css.map │ ├── bootstrap.min.css │ └── jumbotron-narrow.css ├── Postman ├── Controllers │ ├── AuthorizationController.cs │ └── ResourceController.cs ├── Helpers │ └── FormValueRequiredAttribute.cs ├── Postman.csproj ├── Program.cs ├── Properties │ └── launchSettings.json ├── Providers │ └── AuthorizationProvider.cs ├── Startup.cs ├── Views │ ├── Shared │ │ ├── Authorize.cshtml │ │ └── _Layout.cshtml │ └── _ViewStart.cshtml ├── web.config └── wwwroot │ ├── fonts │ ├── glyphicons-halflings-regular.eot │ ├── glyphicons-halflings-regular.svg │ ├── glyphicons-halflings-regular.ttf │ └── glyphicons-halflings-regular.woff │ ├── scripts │ ├── bootstrap.js │ ├── bootstrap.min.js │ ├── jquery-1.9.0.intellisense.js │ ├── jquery-1.9.0.js │ ├── jquery-1.9.0.min.js │ └── jquery-1.9.0.min.map │ └── stylesheets │ ├── bootstrap-theme.css │ ├── bootstrap-theme.css.map │ ├── bootstrap-theme.min.css │ ├── bootstrap.css │ ├── bootstrap.css.map │ ├── bootstrap.min.css │ └── jumbotron-narrow.css └── SignalR └── HelloSignalR ├── Connections └── SimpleConnection.cs ├── HelloSignalR.csproj ├── Program.cs ├── Properties └── launchSettings.json ├── Providers └── AuthorizationProvider.cs ├── Startup.cs ├── web.config └── wwwroot ├── index.html └── styles ├── reset.css └── sample.css /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # VS 14 temporary folder 5 | *.sln.ide/ 6 | target/ 7 | .nuget/ 8 | .vs/ 9 | .build/ 10 | 11 | # User-specific files 12 | *.suo 13 | *.user 14 | *.sln.docstates 15 | project.lock.json 16 | 17 | # Build results 18 | 19 | [Dd]ebug/ 20 | [Rr]elease/ 21 | x64/ 22 | [Bb]in/ 23 | [Oo]bj/ 24 | 25 | # Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets 26 | !packages/*/build/ 27 | 28 | # MSTest test Results 29 | [Tt]est[Rr]esult*/ 30 | [Bb]uild[Ll]og.* 31 | 32 | *_i.c 33 | *_p.c 34 | *.ilk 35 | *.meta 36 | *.obj 37 | *.pch 38 | *.pdb 39 | *.pgc 40 | *.pgd 41 | *.rsp 42 | *.sbr 43 | *.tlb 44 | *.tli 45 | *.tlh 46 | *.tmp 47 | *.tmp_proj 48 | *.log 49 | *.vspscc 50 | *.vssscc 51 | .builds 52 | *.pidb 53 | *.log 54 | *.scc 55 | 56 | # Visual C++ cache files 57 | ipch/ 58 | *.aps 59 | *.ncb 60 | *.opensdf 61 | *.sdf 62 | *.cachefile 63 | 64 | # Visual Studio profiler 65 | *.psess 66 | *.vsp 67 | *.vspx 68 | 69 | # Guidance Automation Toolkit 70 | *.gpState 71 | 72 | # ReSharper is a .NET coding add-in 73 | _ReSharper*/ 74 | *.[Rr]e[Ss]harper 75 | 76 | # TeamCity is a build add-in 77 | _TeamCity* 78 | 79 | # DotCover is a Code Coverage Tool 80 | *.dotCover 81 | 82 | # NCrunch 83 | *.ncrunch* 84 | .*crunch*.local.xml 85 | 86 | # Installshield output folder 87 | [Ee]xpress/ 88 | 89 | # DocProject is a documentation generator add-in 90 | DocProject/buildhelp/ 91 | DocProject/Help/*.HxT 92 | DocProject/Help/*.HxC 93 | DocProject/Help/*.hhc 94 | DocProject/Help/*.hhk 95 | DocProject/Help/*.hhp 96 | DocProject/Help/Html2 97 | DocProject/Help/html 98 | 99 | # Click-Once directory 100 | publish/ 101 | 102 | # Publish Web Output 103 | *.Publish.xml 104 | 105 | # NuGet Packages Directory 106 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line 107 | packages/ 108 | 109 | # Windows Azure Build Output 110 | csx 111 | *.build.csdef 112 | 113 | # Windows Store app package directory 114 | AppPackages/ 115 | 116 | # Others 117 | sql/ 118 | *.Cache 119 | ClientBin/ 120 | [Ss]tyle[Cc]op.* 121 | ~$* 122 | *~ 123 | *.dbmdl 124 | *.[Pp]ublish.xml 125 | *.publishsettings 126 | 127 | # RIA/Silverlight projects 128 | Generated_Code/ 129 | 130 | # Backup & report files from converting an old project file to a newer 131 | # Visual Studio version. Backup files are not needed, because we have git ;-) 132 | _UpgradeReport_Files/ 133 | Backup*/ 134 | UpgradeLog*.XML 135 | UpgradeLog*.htm 136 | 137 | # SQL Server files 138 | *.mdf 139 | *.ldf 140 | 141 | 142 | #LightSwitch generated files 143 | GeneratedArtifacts/ 144 | _Pvt_Extensions/ 145 | ModelManifest.xml 146 | 147 | # ========================= 148 | # Windows detritus 149 | # ========================= 150 | 151 | # Windows image file caches 152 | Thumbs.db 153 | ehthumbs.db 154 | 155 | # Folder config file 156 | Desktop.ini 157 | 158 | # Recycle Bin used on file shares 159 | $RECYCLE.BIN/ 160 | 161 | # Mac desktop service store files 162 | .DS_Store 163 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: csharp 2 | sudo: false 3 | dist: trusty 4 | addons: 5 | apt: 6 | packages: 7 | - gettext 8 | - libcurl4-openssl-dev 9 | - libicu-dev 10 | - libssl-dev 11 | - libunwind8 12 | - zlib1g 13 | env: 14 | global: 15 | - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true 16 | - DOTNET_CLI_TELEMETRY_OPTOUT: 1 17 | - KOREBUILD_DOTNET_VERSION: 2.0.0-preview1-005418 18 | - KOREBUILD_DOTNET_SHARED_RUNTIME_VERSION: 2.0.0-preview1-001919-00 19 | mono: none 20 | os: 21 | - linux 22 | - osx 23 | osx_image: xcode8.2 24 | before_install: 25 | - if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install openssl; ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/; ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/; fi 26 | script: 27 | - ./build.sh -------------------------------------------------------------------------------- /NuGet.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | AspNet.Security.OpenIdConnect.Samples 2 | ===================================== 3 | 4 | ASP.NET Core samples demonstrating how to use the [ASP.NET OpenID Connect server](https://github.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Server) with MVC or JS apps. 5 | 6 | Note: the samples hosted on this repository target ASP.NET Core 1.0 RTM ; see [AspNet.Security.OpenIdConnect.Server/samples](https://github.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Server/tree/dev/samples) for samples targeting the latest pre-release versions. 7 | 8 | ## [MVC](./samples/Mvc) 9 | 10 | This sample shows two separate web applications, potentially running on separate servers, playing the roles of a client and a server with regard to authentication. 11 | 12 | #### [Mvc.Client](./samples/Mvc/Mvc.Client) 13 | 14 | To the user, `Mvc.Client` is the main web application, offering for example a login page and a home page (see `HomeController`). 15 | It plays as the *client* from the point of view of authentication, as it does not implement authentication services on its own and asks the `Mvc.Server` project for those through interactive OpenID Connect requests. 16 | 17 | #### [Mvc.Server](./samples/Mvc/Mvc.Server) 18 | 19 | To the user, `Mvc.Server` is almost invisible. 20 | It offers authentication services to client web application by means of its REST API endpoints, playing as the *authorization server* mentioned in OpenID Connect scenarios. 21 | In this role, it's also responsible of rendering the authorization consent form (see `AuthorizationController`). 22 | 23 | Besides from APIs to request and refresh tokens, `Mvc.Server` also offers an API to access a protected resource, whose data are only accessible to authenticated users (see `ResourceController`). 24 | Thus, it also plays as the *resource server* of an OpenID Connect scenario. 25 | 26 | Note that, generally speaking, authorization server and resource server could also be split in two separate web applications. 27 | 28 | ## [SignalR](./samples/SignalR) 29 | 30 | ## [Cordova](./samples/Cordova) 31 | 32 | ## Support 33 | 34 | **Need help or wanna share your thoughts?** Don't hesitate to join us on Gitter or ask your question on StackOverflow: 35 | 36 | - **Gitter: [https://gitter.im/aspnet-contrib/AspNet.Security.OpenIdConnect.Server](https://gitter.im/aspnet-contrib/AspNet.Security.OpenIdConnect.Server)** 37 | - **StackOverflow: [https://stackoverflow.com/questions/tagged/aspnet-contrib](https://stackoverflow.com/questions/tagged/aspnet-contrib)** 38 | 39 | ## Contributors 40 | 41 | **AspNet.Security.OpenIdConnect.Samples** is actively maintained by **[Kévin Chalet](https://github.com/PinpointTownes)**. Contributions are welcome and can be submitted using pull requests. 42 | 43 | ## License 44 | 45 | This project is licensed under the **Apache License**. This means that you can use, modify and distribute it freely. See [http://www.apache.org/licenses/LICENSE-2.0.html](http://www.apache.org/licenses/LICENSE-2.0.html) for more details. 46 | -------------------------------------------------------------------------------- /build.cmd: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0build.ps1' %*; exit $LASTEXITCODE" -------------------------------------------------------------------------------- /build.ps1: -------------------------------------------------------------------------------- 1 | $ErrorActionPreference = "Stop" 2 | 3 | function DownloadWithRetry([string] $url, [string] $downloadLocation, [int] $retries) 4 | { 5 | while($true) 6 | { 7 | try 8 | { 9 | Invoke-WebRequest $url -OutFile $downloadLocation 10 | break 11 | } 12 | catch 13 | { 14 | $exceptionMessage = $_.Exception.Message 15 | Write-Host "Failed to download '$url': $exceptionMessage" 16 | if ($retries -gt 0) { 17 | $retries-- 18 | Write-Host "Waiting 10 seconds before retrying. Retries left: $retries" 19 | Start-Sleep -Seconds 10 20 | 21 | } 22 | else 23 | { 24 | $exception = $_.Exception 25 | throw $exception 26 | } 27 | } 28 | } 29 | } 30 | 31 | cd $PSScriptRoot 32 | 33 | $repoFolder = $PSScriptRoot 34 | $env:REPO_FOLDER = $repoFolder 35 | 36 | $koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" 37 | if ($env:KOREBUILD_ZIP) 38 | { 39 | $koreBuildZip=$env:KOREBUILD_ZIP 40 | } 41 | 42 | $buildFolder = ".build" 43 | $buildFile="$buildFolder\KoreBuild.ps1" 44 | 45 | if (!(Test-Path $buildFolder)) { 46 | Write-Host "Downloading KoreBuild from $koreBuildZip" 47 | 48 | $tempFolder=$env:TEMP + "\KoreBuild-" + [guid]::NewGuid() 49 | New-Item -Path "$tempFolder" -Type directory | Out-Null 50 | 51 | $localZipFile="$tempFolder\korebuild.zip" 52 | 53 | DownloadWithRetry -url $koreBuildZip -downloadLocation $localZipFile -retries 6 54 | 55 | Add-Type -AssemblyName System.IO.Compression.FileSystem 56 | [System.IO.Compression.ZipFile]::ExtractToDirectory($localZipFile, $tempFolder) 57 | 58 | New-Item -Path "$buildFolder" -Type directory | Out-Null 59 | copy-item "$tempFolder\**\build\*" $buildFolder -Recurse 60 | 61 | # Cleanup 62 | if (Test-Path $tempFolder) { 63 | Remove-Item -Recurse -Force $tempFolder 64 | } 65 | } 66 | 67 | &"$buildFile" @args 68 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 3 | cd $repoFolder 4 | 5 | koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" 6 | if [ ! -z $KOREBUILD_ZIP ]; then 7 | koreBuildZip=$KOREBUILD_ZIP 8 | fi 9 | 10 | buildFolder=".build" 11 | buildFile="$buildFolder/KoreBuild.sh" 12 | 13 | if test ! -d $buildFolder; then 14 | echo "Downloading KoreBuild from $koreBuildZip" 15 | 16 | tempFolder="/tmp/KoreBuild-$(uuidgen)" 17 | mkdir $tempFolder 18 | 19 | localZipFile="$tempFolder/korebuild.zip" 20 | 21 | retries=6 22 | until (wget -O $localZipFile $koreBuildZip 2>/dev/null || curl -o $localZipFile --location $koreBuildZip 2>/dev/null) 23 | do 24 | echo "Failed to download '$koreBuildZip'" 25 | if [ "$retries" -le 0 ]; then 26 | exit 1 27 | fi 28 | retries=$((retries - 1)) 29 | echo "Waiting 10 seconds before retrying. Retries left: $retries" 30 | sleep 10s 31 | done 32 | 33 | unzip -q -d $tempFolder $localZipFile 34 | 35 | mkdir $buildFolder 36 | cp -r $tempFolder/**/build/** $buildFolder 37 | 38 | chmod +x $buildFile 39 | 40 | # Cleanup 41 | if test -d $tempFolder; then 42 | rm -rf $tempFolder 43 | fi 44 | fi 45 | 46 | $buildFile -r $repoFolder "$@" 47 | -------------------------------------------------------------------------------- /build/dependencies.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1.0.0 5 | 1.0.0 6 | 1.0.0 7 | 1.6.0 8 | 1.0.0 9 | 0.1.0-* 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /makefile.shade: -------------------------------------------------------------------------------- 1 | var VERSION='1.0.0' 2 | var FULL_VERSION='1.0.0' 3 | var AUTHORS='aspnet-contrib' 4 | 5 | use-standard-lifecycle 6 | k-standard-goals -------------------------------------------------------------------------------- /samples/Cordova/Backend/Backend.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | net451;netcoreapp1.0 7 | true 8 | Exe 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /samples/Cordova/Backend/Certificate.pfx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/Backend/Certificate.pfx -------------------------------------------------------------------------------- /samples/Cordova/Backend/Controllers/AuthenticationController.cs: -------------------------------------------------------------------------------- 1 | using Backend.Extensions; 2 | using Microsoft.AspNetCore.Http.Authentication; 3 | using Microsoft.AspNetCore.Mvc; 4 | 5 | namespace Backend.Controllers 6 | { 7 | public class AuthenticationController : Controller 8 | { 9 | [HttpGet("~/signin")] 10 | public ActionResult SignIn(string returnUrl = null) 11 | { 12 | // Note: the "returnUrl" parameter corresponds to the endpoint the user agent 13 | // will be redirected to after a successful authentication and not 14 | // the redirect_uri of the requesting client application. 15 | ViewBag.ReturnUrl = returnUrl; 16 | 17 | // Note: in a real world application, you'd probably prefer creating a specific view model. 18 | return View("SignIn", HttpContext.GetExternalProviders()); 19 | } 20 | 21 | [HttpPost("~/signin")] 22 | public ActionResult SignIn(string provider, string returnUrl) 23 | { 24 | // Note: the "provider" parameter corresponds to the external 25 | // authentication provider choosen by the user agent. 26 | if (string.IsNullOrEmpty(provider)) 27 | { 28 | return BadRequest(); 29 | } 30 | 31 | if (!HttpContext.IsProviderSupported(provider)) 32 | { 33 | return BadRequest(); 34 | } 35 | 36 | // Note: the "returnUrl" parameter corresponds to the endpoint the user agent 37 | // will be redirected to after a successful authentication and not 38 | // the redirect_uri of the requesting client application. 39 | if (string.IsNullOrEmpty(returnUrl)) 40 | { 41 | return BadRequest(); 42 | } 43 | 44 | // Instruct the middleware corresponding to the requested external identity 45 | // provider to redirect the user agent to its own authorization endpoint. 46 | // Note: the authenticationScheme parameter must match the value configured in Startup.cs 47 | return Challenge(new AuthenticationProperties { RedirectUri = returnUrl }, provider); 48 | } 49 | 50 | [HttpGet("~/signout"), HttpPost("~/signout")] 51 | public ActionResult SignOut() 52 | { 53 | // Instruct the cookies middleware to delete the local cookie created 54 | // when the user agent is redirected from the external identity provider 55 | // after a successful authentication flow (e.g Google or Facebook). 56 | return SignOut("ServerCookie"); 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /samples/Cordova/Backend/Controllers/ResourceController.cs: -------------------------------------------------------------------------------- 1 | using System.Security.Claims; 2 | using Microsoft.AspNetCore.Authorization; 3 | using Microsoft.AspNetCore.Mvc; 4 | 5 | namespace Backend.Controllers 6 | { 7 | [Route("api")] 8 | public class ResourceController : Controller 9 | { 10 | [Authorize, HttpGet, Route("message")] 11 | public IActionResult GetMessage() 12 | { 13 | var identity = User.Identity as ClaimsIdentity; 14 | if (identity == null) 15 | { 16 | return BadRequest(); 17 | } 18 | 19 | return Content($"{identity.Name} has been successfully authenticated."); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /samples/Cordova/Backend/Extensions/AppBuilderExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.AspNetCore.Builder; 3 | using Microsoft.AspNetCore.Hosting; 4 | using Microsoft.AspNetCore.Http; 5 | 6 | namespace Backend.Extensions 7 | { 8 | public static class AppBuilderExtensions 9 | { 10 | public static IApplicationBuilder UseWhen(this IApplicationBuilder app, 11 | Func condition, Action configuration) 12 | { 13 | if (app == null) 14 | { 15 | throw new ArgumentNullException(nameof(app)); 16 | } 17 | 18 | if (condition == null) 19 | { 20 | throw new ArgumentNullException(nameof(condition)); 21 | } 22 | 23 | if (configuration == null) 24 | { 25 | throw new ArgumentNullException(nameof(configuration)); 26 | } 27 | 28 | var builder = app.New(); 29 | configuration(builder); 30 | 31 | return app.Use(next => 32 | { 33 | builder.Run(next); 34 | 35 | var branch = builder.Build(); 36 | 37 | return context => 38 | { 39 | if (condition(context)) 40 | { 41 | return branch(context); 42 | } 43 | 44 | return next(context); 45 | }; 46 | }); 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /samples/Cordova/Backend/Extensions/HttpContextExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using Microsoft.AspNetCore.Http; 5 | using Microsoft.AspNetCore.Http.Authentication; 6 | 7 | namespace Backend.Extensions 8 | { 9 | public static class HttpContextExtensions 10 | { 11 | public static IEnumerable GetExternalProviders(this HttpContext context) 12 | { 13 | if (context == null) 14 | { 15 | throw new ArgumentNullException(nameof(context)); 16 | } 17 | 18 | return from description in context.Authentication.GetAuthenticationSchemes() 19 | where !string.IsNullOrEmpty(description.DisplayName) 20 | select description; 21 | } 22 | 23 | public static bool IsProviderSupported(this HttpContext context, string provider) 24 | { 25 | if (context == null) 26 | { 27 | throw new ArgumentNullException(nameof(context)); 28 | } 29 | 30 | return (from description in context.GetExternalProviders() 31 | where string.Equals(description.AuthenticationScheme, provider, StringComparison.OrdinalIgnoreCase) 32 | select description).Any(); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /samples/Cordova/Backend/Helpers/FormValueRequiredAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.AspNetCore.Mvc.Abstractions; 3 | using Microsoft.AspNetCore.Mvc.ActionConstraints; 4 | using Microsoft.AspNetCore.Routing; 5 | 6 | namespace Backend.Helpers 7 | { 8 | public sealed class FormValueRequiredAttribute : ActionMethodSelectorAttribute 9 | { 10 | private readonly string _name; 11 | 12 | public FormValueRequiredAttribute(string name) 13 | { 14 | _name = name; 15 | } 16 | 17 | public override bool IsValidForRequest(RouteContext context, ActionDescriptor action) 18 | { 19 | if (string.Equals(context.HttpContext.Request.Method, "GET", StringComparison.OrdinalIgnoreCase) || 20 | string.Equals(context.HttpContext.Request.Method, "HEAD", StringComparison.OrdinalIgnoreCase) || 21 | string.Equals(context.HttpContext.Request.Method, "DELETE", StringComparison.OrdinalIgnoreCase) || 22 | string.Equals(context.HttpContext.Request.Method, "TRACE", StringComparison.OrdinalIgnoreCase)) 23 | { 24 | return false; 25 | } 26 | 27 | if (string.IsNullOrEmpty(context.HttpContext.Request.ContentType)) 28 | { 29 | return false; 30 | } 31 | 32 | if (!context.HttpContext.Request.ContentType.StartsWith("application/x-www-form-urlencoded", StringComparison.OrdinalIgnoreCase)) 33 | { 34 | return false; 35 | } 36 | 37 | return !string.IsNullOrEmpty(context.HttpContext.Request.Form[_name]); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /samples/Cordova/Backend/Models/Application.cs: -------------------------------------------------------------------------------- 1 | namespace Backend.Models 2 | { 3 | public class Application 4 | { 5 | public string ApplicationID { get; set; } 6 | public string DisplayName { get; set; } 7 | public string RedirectUri { get; set; } 8 | public string LogoutRedirectUri { get; set; } 9 | public string Secret { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /samples/Cordova/Backend/Models/ApplicationContext.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | 3 | namespace Backend.Models 4 | { 5 | public class ApplicationContext : DbContext 6 | { 7 | public ApplicationContext(DbContextOptions options) 8 | : base(options) { } 9 | 10 | public DbSet Applications { get; set; } 11 | } 12 | } -------------------------------------------------------------------------------- /samples/Cordova/Backend/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Hosting; 2 | using Microsoft.Extensions.Configuration; 3 | using Microsoft.Extensions.Logging; 4 | 5 | namespace Backend 6 | { 7 | public static class Program 8 | { 9 | public static void Main(string[] args) 10 | { 11 | var configuration = new ConfigurationBuilder() 12 | .AddEnvironmentVariables() 13 | .AddCommandLine(args) 14 | .Build(); 15 | 16 | var host = new WebHostBuilder() 17 | .ConfigureLogging(options => options.AddConsole()) 18 | .ConfigureLogging(options => options.AddDebug()) 19 | .UseConfiguration(configuration) 20 | .UseIISIntegration() 21 | .UseKestrel() 22 | .UseStartup() 23 | .Build(); 24 | 25 | host.Run(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /samples/Cordova/Backend/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:54540/", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "launchUrl": "http://localhost:54540/", 15 | "environmentVariables": { 16 | "ASPNETCORE_ENVIRONMENT": "Development" 17 | } 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /samples/Cordova/Backend/Views/Shared/Authorize.cshtml: -------------------------------------------------------------------------------- 1 | @using AspNet.Security.OpenIdConnect.Primitives 2 | @using Backend.Models 3 | 4 | @model Tuple 5 | 6 |
7 |

Authorization

8 | 9 |

Do you wanna grant @Model.Item2.DisplayName an access to your resources? (scopes requested: @Model.Item1.Scope)

10 | 11 |
12 | @Html.AntiForgeryToken() 13 | 14 | @foreach (var parameter in Model.Item1.GetParameters()) { 15 | 16 | } 17 | 18 | 19 | 20 |
21 |
22 | -------------------------------------------------------------------------------- /samples/Cordova/Backend/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @using AspNet.Security.OpenIdConnect.Primitives 2 | @model OpenIdConnectResponse 3 | 4 |
5 |

An OpenID Connect error has occurred

6 |

7 | @Model.Error 8 | @if (!string.IsNullOrEmpty(Model.ErrorDescription)) { 9 | @Model.ErrorDescription 10 | } 11 |

12 |
-------------------------------------------------------------------------------- /samples/Cordova/Backend/Views/Shared/Logout.cshtml: -------------------------------------------------------------------------------- 1 | @using AspNet.Security.OpenIdConnect.Primitives 2 | @using Backend.Models 3 | @using System.Security.Claims 4 | 5 | @model Tuple 6 | 7 |
8 |

Log out

9 |

Are you sure you want to sign out?

10 | 11 | @if (Model.Item2 != null && Model.Item2.Identity != null) { 12 |

Connected user: @Model.Item2.Identity.Name

13 | } 14 | 15 |
16 | @Html.AntiForgeryToken() 17 | 18 | @* Flow the logout request *@ 19 | @foreach (var parameter in Model.Item1.GetParameters()) { 20 | 21 | } 22 | 23 | 24 |
25 |
-------------------------------------------------------------------------------- /samples/Cordova/Backend/Views/Shared/SignIn.cshtml: -------------------------------------------------------------------------------- 1 | @using Microsoft.AspNetCore.Http.Authentication 2 | @model IEnumerable 3 | 4 |
5 |

Authentication

6 |

Sign in using one of these external providers:

7 | 8 | @foreach (var description in Model) { 9 |
10 | 11 | 12 | 13 | 14 |
15 | } 16 |
-------------------------------------------------------------------------------- /samples/Cordova/Backend/Views/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Backend (OSOS sample) 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 |

Your application (Backend)

20 |
21 | 22 | @RenderBody() 23 | 24 | 27 | 28 |
29 | 30 | -------------------------------------------------------------------------------- /samples/Cordova/Backend/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } -------------------------------------------------------------------------------- /samples/Cordova/Backend/web.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /samples/Cordova/Backend/wwwroot/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/Backend/wwwroot/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /samples/Cordova/Backend/wwwroot/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/Backend/wwwroot/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /samples/Cordova/Backend/wwwroot/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/Backend/wwwroot/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /samples/Cordova/Backend/wwwroot/stylesheets/jumbotron-narrow.css: -------------------------------------------------------------------------------- 1 | /* Space out content a bit */ 2 | body { 3 | padding-top: 20px; 4 | padding-bottom: 20px; 5 | } 6 | 7 | /* Everything but the jumbotron gets side spacing for mobile first views */ 8 | .header, 9 | .marketing, 10 | .footer { 11 | padding-right: 15px; 12 | padding-left: 15px; 13 | } 14 | 15 | /* Custom page header */ 16 | .header { 17 | border-bottom: 1px solid #e5e5e5; 18 | } 19 | /* Make the masthead heading the same height as the navigation */ 20 | .header h3 { 21 | padding-bottom: 19px; 22 | margin-top: 0; 23 | margin-bottom: 0; 24 | line-height: 40px; 25 | } 26 | 27 | /* Custom page footer */ 28 | .footer { 29 | padding-top: 19px; 30 | color: #777; 31 | border-top: 1px solid #e5e5e5; 32 | } 33 | 34 | /* Customize container */ 35 | @media (min-width: 768px) { 36 | .container { 37 | max-width: 730px; 38 | } 39 | } 40 | .container-narrow > hr { 41 | margin: 30px 0; 42 | } 43 | 44 | /* Main marketing message and sign up button */ 45 | .jumbotron { 46 | text-align: center; 47 | border-bottom: 1px solid #e5e5e5; 48 | } 49 | .jumbotron .btn { 50 | padding: 14px 24px; 51 | font-size: 21px; 52 | } 53 | 54 | /* Supporting marketing content */ 55 | .marketing { 56 | margin: 40px 0; 57 | } 58 | .marketing p + h4 { 59 | margin-top: 28px; 60 | } 61 | 62 | /* Responsive: Portrait tablets and up */ 63 | @media screen and (min-width: 768px) { 64 | /* Remove the padding we set earlier */ 65 | .header, 66 | .marketing, 67 | .footer { 68 | padding-right: 0; 69 | padding-left: 0; 70 | } 71 | /* Space out the masthead */ 72 | .header { 73 | margin-bottom: 30px; 74 | } 75 | /* Remove the bottom border on the jumbotron for visual effect */ 76 | .jumbotron { 77 | border-bottom: 0; 78 | } 79 | } -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/.gitignore: -------------------------------------------------------------------------------- 1 | # .gitignore 2 | [Pp]lugins/android.json 3 | [Pp]lugins/windows.json 4 | [Pp]lugins/wp8.json 5 | [Pp]lugins/remote_ios.json 6 | [Pp]latforms/ 7 | 8 | 9 | bower_components/ 10 | node_modules/ -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "MobileApp", 3 | "dependencies": { 4 | "angular-local-storage": "~0.2.3", 5 | "angular-jwt": "~0.0.9", 6 | "ionic": "~1.2.4" 7 | }, 8 | "exportsOverride": { 9 | "angular": { 10 | }, 11 | "angular-local-storage": { 12 | "scripts/libraries": [ 13 | "dist/angular-local-storage.min.js" 14 | ] 15 | }, 16 | "angular-animate": {}, 17 | "angular-sanitize": {}, 18 | "angular-ui-router": {}, 19 | "angular-jwt": { 20 | "scripts/libraries": [ 21 | "dist/angular-jwt.min.js" 22 | ] 23 | }, 24 | "ionic": { 25 | "scripts/libraries": [ 26 | "release/js/ionic.bundle.min.js" 27 | ], 28 | "css": [ 29 | "release/css/ionic.min.css" 30 | ], 31 | "fonts": [ 32 | "release/fonts/*" 33 | ] 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/build.json: -------------------------------------------------------------------------------- 1 | { 2 | "android": { 3 | "release": { 4 | "keystore": "", 5 | "storePassword": "", 6 | "alias": "", 7 | "password" : "", 8 | "keystoreType": "" 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/gruntfile.js: -------------------------------------------------------------------------------- 1 | /// 2 | // This file in the main entry point for defining grunt tasks and using grunt plugins. 3 | // Click here to learn more. http://go.microsoft.com/fwlink/?LinkID=513275&clcid=0x409 4 | 5 | module.exports = function (grunt) { 6 | grunt.initConfig({ 7 | bower: { 8 | install: { 9 | options: { 10 | targetDir: 'www', 11 | layout: function (type, component, source) { return type; }, 12 | install: true, 13 | verbose: true, 14 | cleanTargetDir: false, 15 | bowerOptions: {} 16 | } 17 | } 18 | } 19 | }); 20 | 21 | grunt.loadNpmTasks("grunt-bower-task"); 22 | 23 | }; -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/merges/android/scripts/android2.3-jscompat.js: -------------------------------------------------------------------------------- 1 | // Polyfill pour la prise en charge de Function.prototype.bind() sur Android 2.3 2 | (function () { 3 | if (!Function.prototype.bind) { 4 | Function.prototype.bind = function (thisValue) { 5 | if (typeof this !== "function") { 6 | throw new TypeError(this + " cannot be bound as it is not a function"); 7 | } 8 | 9 | // bind() permet également d'ajouter des arguments au début de l'appel 10 | var preArgs = Array.prototype.slice.call(arguments, 1); 11 | 12 | // Fonction réelle à laquelle lier la valeur et les arguments "this" 13 | var functionToBind = this; 14 | var noOpFunction = function () { }; 15 | 16 | // Argument "this" à utiliser 17 | var thisArg = this instanceof noOpFunction && thisValue ? this : thisValue; 18 | 19 | // Fonction liée résultante 20 | var boundFunction = function () { 21 | return functionToBind.apply(thisArg, preArgs.concat(Array.prototype.slice.call(arguments))); 22 | }; 23 | 24 | noOpFunction.prototype = this.prototype; 25 | boundFunction.prototype = new noOpFunction(); 26 | 27 | return boundFunction; 28 | }; 29 | } 30 | }()); 31 | -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/merges/android/scripts/platformOverrides.js: -------------------------------------------------------------------------------- 1 | (function () { 2 | // Ajouter le polyfill bind() 3 | var scriptElem = document.createElement('script'); 4 | scriptElem.setAttribute('src', 'scripts/android2.3-jscompat.js'); 5 | if (document.body) { 6 | document.body.appendChild(scriptElem); 7 | } else { 8 | document.head.appendChild(scriptElem); 9 | } 10 | }()); -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/merges/windows/scripts/platformOverrides.js: -------------------------------------------------------------------------------- 1 | (function () { 2 | // Ajouter le polyfill safeHTML 3 | var scriptElem = document.createElement('script'); 4 | scriptElem.setAttribute('src', 'scripts/winstore-jscompat.js'); 5 | if (document.body) { 6 | document.body.appendChild(scriptElem); 7 | } else { 8 | document.head.appendChild(scriptElem); 9 | } 10 | }()); -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "MobileApp", 3 | "version": "1.0.0", 4 | "dependencies": {}, 5 | "devDependencies": { 6 | "grunt": "^0.4.5", 7 | "grunt-bower-task": "^0.4.0", 8 | "grunt-cli": "^0.1.13" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | 21 | 22 | # Contributing to Apache Cordova 23 | 24 | Anyone can contribute to Cordova. And we need your contributions. 25 | 26 | There are multiple ways to contribute: report bugs, improve the docs, and 27 | contribute code. 28 | 29 | For instructions on this, start with the 30 | [contribution overview](http://cordova.apache.org/contribute/). 31 | 32 | The details are explained there, but the important items are: 33 | - Sign and submit an Apache ICLA (Contributor License Agreement). 34 | - Have a Jira issue open that corresponds to your contribution. 35 | - Run the tests so your patch doesn't break existing functionality. 36 | 37 | We look forward to your contributions! 38 | -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/NOTICE: -------------------------------------------------------------------------------- 1 | Apache Cordova 2 | Copyright 2012 The Apache Software Foundation 3 | 4 | This product includes software developed at 5 | The Apache Software Foundation (http://www.apache.org/). 6 | -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cordova-plugin-inappbrowser", 3 | "version": "1.1.1", 4 | "description": "Cordova InAppBrowser Plugin", 5 | "cordova": { 6 | "id": "cordova-plugin-inappbrowser", 7 | "platforms": [ 8 | "android", 9 | "amazon-fireos", 10 | "ubuntu", 11 | "ios", 12 | "wp7", 13 | "wp8", 14 | "windows8", 15 | "windows", 16 | "firefoxos" 17 | ] 18 | }, 19 | "repository": { 20 | "type": "git", 21 | "url": "https://github.com/apache/cordova-plugin-inappbrowser" 22 | }, 23 | "keywords": [ 24 | "cordova", 25 | "in", 26 | "app", 27 | "browser", 28 | "inappbrowser", 29 | "ecosystem:cordova", 30 | "cordova-android", 31 | "cordova-amazon-fireos", 32 | "cordova-ubuntu", 33 | "cordova-ios", 34 | "cordova-wp7", 35 | "cordova-wp8", 36 | "cordova-windows8", 37 | "cordova-windows", 38 | "cordova-firefoxos" 39 | ], 40 | "engines": [ 41 | { 42 | "name": "cordova", 43 | "version": ">=3.1.0" 44 | } 45 | ], 46 | "author": "Apache Software Foundation", 47 | "license": "Apache 2.0" 48 | } 49 | -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/src/android/InAppBrowserDialog.java: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed to the Apache Software Foundation (ASF) under one 3 | or more contributor license agreements. See the NOTICE file 4 | distributed with this work for additional information 5 | regarding copyright ownership. The ASF licenses this file 6 | to you under the Apache License, Version 2.0 (the 7 | "License"); you may not use this file except in compliance 8 | with the License. You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, 13 | software distributed under the License is distributed on an 14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, either express or implied. See the License for the 16 | specific language governing permissions and limitations 17 | under the License. 18 | */ 19 | package org.apache.cordova.inappbrowser; 20 | 21 | import android.app.AlertDialog; 22 | import android.app.Dialog; 23 | import android.content.Context; 24 | import android.util.Log; 25 | 26 | import org.json.JSONException; 27 | import org.json.JSONObject; 28 | 29 | /** 30 | * Created by Oliver on 22/11/2013. 31 | */ 32 | public class InAppBrowserDialog extends Dialog { 33 | Context context; 34 | InAppBrowser inAppBrowser = null; 35 | 36 | public InAppBrowserDialog(Context context, int theme) { 37 | super(context, theme); 38 | this.context = context; 39 | } 40 | 41 | public void setInAppBroswer(InAppBrowser browser) { 42 | this.inAppBrowser = browser; 43 | } 44 | 45 | public void onBackPressed () { 46 | if (this.inAppBrowser == null) { 47 | this.dismiss(); 48 | } else { 49 | // better to go through the in inAppBrowser 50 | // because it does a clean up 51 | if (this.inAppBrowser.hardwareBack() && this.inAppBrowser.canGoBack()) { 52 | this.inAppBrowser.goBack(); 53 | } else { 54 | this.inAppBrowser.closeDialog(); 55 | } 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-hdpi/ic_action_next_item.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-hdpi/ic_action_next_item.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-hdpi/ic_action_previous_item.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-hdpi/ic_action_previous_item.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-hdpi/ic_action_remove.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-hdpi/ic_action_remove.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-mdpi/ic_action_next_item.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-mdpi/ic_action_next_item.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-mdpi/ic_action_previous_item.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-mdpi/ic_action_previous_item.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-mdpi/ic_action_remove.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-mdpi/ic_action_remove.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xhdpi/ic_action_next_item.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xhdpi/ic_action_next_item.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xhdpi/ic_action_previous_item.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xhdpi/ic_action_previous_item.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xhdpi/ic_action_remove.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xhdpi/ic_action_remove.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xxhdpi/ic_action_next_item.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xxhdpi/ic_action_next_item.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xxhdpi/ic_action_previous_item.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xxhdpi/ic_action_previous_item.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xxhdpi/ic_action_remove.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xxhdpi/ic_action_remove.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/src/blackberry10/README.md: -------------------------------------------------------------------------------- 1 | 19 | # BlackBerry 10 In-App-Browser Plugin 20 | 21 | The in app browser functionality is entirely contained within common js. There is no native implementation required. 22 | To install this plugin, follow the [Command-line Interface Guide](http://cordova.apache.org/docs/en/edge/guide_cli_index.md.html#The%20Command-line%20Interface). 23 | 24 | If you are not using the Cordova Command-line Interface, follow [Using Plugman to Manage Plugins](http://cordova.apache.org/docs/en/edge/guide_plugin_ref_plugman.md.html). 25 | ./cordova-plugin-battery-status/README.md 26 | ./cordova-plugin-camera/README.md 27 | ./cordova-plugin-console/README.md 28 | ./cordova-plugin-contacts/README.md 29 | ./cordova-plugin-device/README.md 30 | ./cordova-plugin-device-motion/README.md 31 | ./cordova-plugin-device-orientation/README.md 32 | ./cordova-plugin-device-orientation/src/blackberry10/README.md 33 | ./cordova-plugin-file/README.md 34 | ./cordova-plugin-file-transfer/README.md 35 | ./cordova-plugin-geolocation/README.md 36 | ./cordova-plugin-globalization/README.md 37 | ./cordova-plugin-inappbrowser/README.md 38 | ./cordova-plugin-inappbrowser/src/blackberry10/README.md 39 | ./cordova-plugin-media/README.md 40 | ./cordova-plugin-media-capture/README.md 41 | ./cordova-plugin-network-information/README.md 42 | ./cordova-plugin-splashscreen/README.md 43 | ./cordova-plugin-vibration/README.md 44 | -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/de/README.md: -------------------------------------------------------------------------------- 1 | 19 | 20 | # BlackBerry 10-In-App-Browser-Plugin 21 | 22 | Die Funktionalität ist im app-Browser vollständig in gemeinsamen Js enthalten. Es gibt keine native Implementierung benötigt. Um dieses Plugin zu installieren, folgen Sie dem [Command-Line Interface Guide](http://cordova.apache.org/docs/en/edge/guide_cli_index.md.html#The%20Command-line%20Interface). 23 | 24 | Wenn Sie nicht die Cordova-Befehlszeilenschnittstelle verwenden, folgen Sie [Verwenden Plugman zu Plugins verwalten](http://cordova.apache.org/docs/en/edge/guide_plugin_ref_plugman.md.html). ./cordova-plugin-battery-status/README.md ./cordova-plugin-camera/README.md ./cordova-plugin-console/README.md ./cordova-plugin-contacts/README.md ./cordova-plugin-device/README.md ./cordova-plugin-device-motion/README.md ./cordova-plugin-device-orientation/README.md ./cordova-plugin-device-orientation/src/blackberry10/README.md ./cordova-plugin-file/README.md ./cordova-plugin-file-transfer/README.md ./cordova-plugin-geolocation/README.md ./cordova-plugin-globalization/README.md ./cordova-plugin-inappbrowser/README.md ./cordova-plugin-inappbrowser/src/blackberry10/README.md ./cordova-plugin-media/README.md ./cordova-plugin-media-capture/README.md ./cordova-plugin-network-information/README.md ./cordova-plugin-splashscreen/README.md ./cordova-plugin-vibration/README.md -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/es/README.md: -------------------------------------------------------------------------------- 1 | 19 | 20 | # BlackBerry 10 In-App-Browser Plugin 21 | 22 | El en el navegador de aplicación funcionalidad está enteramente dentro de js común. No hay ninguna aplicación nativa necesaria. Para instalar este plugin, siga la [Guía de la interfaz de línea de comandos](http://cordova.apache.org/docs/en/edge/guide_cli_index.md.html#The%20Command-line%20Interface). 23 | 24 | Si no utiliza la interfaz de línea de comandos de Cordova, siga [Usando Plugman para gestionar Plugins](http://cordova.apache.org/docs/en/edge/guide_plugin_ref_plugman.md.html). ./cordova-plugin-battery-status/README.md ./cordova-plugin-camera/README.md ./cordova-plugin-console/README.md ./cordova-plugin-contacts/README.md ./cordova-plugin-device/README.md ./cordova-plugin-device-motion/README.md ./cordova-plugin-device-orientation/README.md ./cordova-plugin-device-orientation/src/blackberry10/README.md ./cordova-plugin-file/README.md ./cordova-plugin-file-transfer/README.md ./cordova-plugin-geolocation/README.md ./cordova-plugin-globalization/README.md ./cordova-plugin-inappbrowser/README.md ./cordova-plugin-inappbrowser/src/blackberry10/README.md ./cordova-plugin-media/README.md ./cordova-plugin-media-capture/README.md ./cordova-plugin-network-information/README.md ./cordova-plugin-splashscreen/README.md ./cordova-plugin-vibration/README.md -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/fr/README.md: -------------------------------------------------------------------------------- 1 | 19 | 20 | # BlackBerry 10 In-App-Browser Plugin 21 | 22 | Le dans le navigateur de l'application, la fonctionnalité est entièrement contenue dans js commun. Il n'y a aucune implémentation native requise. Pour installer ce plugin, suivez le [Guide de l'Interface de ligne de commande](http://cordova.apache.org/docs/en/edge/guide_cli_index.md.html#The%20Command-line%20Interface). 23 | 24 | Si vous n'utilisez pas l'Interface de ligne de commande de Cordova, suivez [Les Plugman à l'aide à gérer les Plugins](http://cordova.apache.org/docs/en/edge/guide_plugin_ref_plugman.md.html). ./cordova-plugin-battery-status/README.md ./cordova-plugin-camera/README.md ./cordova-plugin-console/README.md ./cordova-plugin-contacts/README.md ./cordova-plugin-device/README.md ./cordova-plugin-device-motion/README.md ./cordova-plugin-device-orientation/README.md ./cordova-plugin-device-orientation/src/blackberry10/README.md ./cordova-plugin-file/README.md ./cordova-plugin-file-transfer/README.md ./cordova-plugin-geolocation/README.md ./cordova-plugin-globalization/README.md ./cordova-plugin-inappbrowser/README.md ./cordova-plugin-inappbrowser/src/blackberry10/README.md ./cordova-plugin-media/README.md ./cordova-plugin-media-capture/README.md ./cordova-plugin-network-information/README.md ./cordova-plugin-splashscreen/README.md ./cordova-plugin-vibration/README.md -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/it/README.md: -------------------------------------------------------------------------------- 1 | 19 | 20 | # BlackBerry 10 In-App-Browser Plugin 21 | 22 | Il browser app funzionalità è interamente contenuta nel comune js. Non esiste alcuna implementazione nativa richiesto. Per installare questo plugin, seguire la [Guida per l'interfaccia della riga di comando](http://cordova.apache.org/docs/en/edge/guide_cli_index.md.html#The%20Command-line%20Interface). 23 | 24 | Se non si utilizza l'interfaccia della riga di comando di Cordova, seguire [Utilizzando Plugman per gestire i plugin](http://cordova.apache.org/docs/en/edge/guide_plugin_ref_plugman.md.html). ./cordova-plugin-battery-status/README.md ./cordova-plugin-camera/README.md ./cordova-plugin-console/README.md ./cordova-plugin-contacts/README.md ./cordova-plugin-device/README.md ./cordova-plugin-device-motion/README.md ./cordova-plugin-device-orientation/README.md ./cordova-plugin-device-orientation/src/blackberry10/README.md ./cordova-plugin-file/README.md ./cordova-plugin-file-transfer/README.md ./cordova-plugin-geolocation/README.md ./cordova-plugin-globalization/README.md ./cordova-plugin-inappbrowser/README.md ./cordova-plugin-inappbrowser/src/blackberry10/README.md ./cordova-plugin-media/README.md ./cordova-plugin-media-capture/README.md ./cordova-plugin-network-information/README.md ./cordova-plugin-splashscreen/README.md ./cordova-plugin-vibration/README.md -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/ja/README.md: -------------------------------------------------------------------------------- 1 | 19 | 20 | # BlackBerry 10 In-App-Browser Plugin 21 | 22 | アプリケーション ブラウザーの機能は全く一般的な js に含まれています。 ネイティブ実装する必要はありません。 このプラグインをインストールするには[コマンド ライン インターフェイス ガイド](http://cordova.apache.org/docs/en/edge/guide_cli_index.md.html#The%20Command-line%20Interface). 23 | 24 | コルドバのコマンド ライン インターフェイスを使用していない場合は場合、[管理のプラグインを使用して Plugman](http://cordova.apache.org/docs/en/edge/guide_plugin_ref_plugman.md.html)に従ってください。 ./cordova-plugin-battery-status/README.md ./cordova-plugin-camera/README.md ./cordova-plugin-console/README.md ./cordova-plugin-contacts/README.md ./cordova-plugin-device/README.md ./cordova-plugin-device-motion/README.md ./cordova-plugin-device-orientation/README.md ./cordova-plugin-device-orientation/src/blackberry10/README.md ./cordova-plugin-file/README.md ./cordova-plugin-file-transfer/README.md ./cordova-plugin-geolocation/README.md ./cordova-plugin-globalization/README.md ./cordova-plugin-inappbrowser/README.md ./cordova-plugin-inappbrowser/src/blackberry10/README.md ./cordova-plugin-media/README.md ./cordova-plugin-media-capture/README.md ./cordova-plugin-network-information/README.md ./cordova-plugin-splashscreen/README.md ./cordova-plugin-vibration/README.md -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/ko/README.md: -------------------------------------------------------------------------------- 1 | 19 | 20 | # 블랙베리 10 애플 리 케이 션-브라우저 플러그인 21 | 22 | 응용 프로그램 브라우저에서 기능은 완전히 포함 된 일반적인 js. 필요 없는 기본 구현이입니다. 이 플러그인을 설치 하려면 [명령줄 인터페이스 가이드](http://cordova.apache.org/docs/en/edge/guide_cli_index.md.html#The%20Command-line%20Interface) 를 따라합니다. 23 | 24 | 코르도바 명령줄 인터페이스를 사용 하지 않는 경우 [관리 플러그인을 사용 하 여 Plugman](http://cordova.apache.org/docs/en/edge/guide_plugin_ref_plugman.md.html)를 따르십시오. ./cordova-plugin-battery-status/README.md ./cordova-plugin-camera/README.md ./cordova-plugin-console/README.md ./cordova-plugin-contacts/README.md ./cordova-plugin-device/README.md ./cordova-plugin-device-motion/README.md ./cordova-plugin-device-orientation/README.md ./cordova-plugin-device-orientation/src/blackberry10/README.md ./cordova-plugin-file/README.md ./cordova-plugin-file-transfer/README.md ./cordova-plugin-geolocation/README.md ./cordova-plugin-globalization/README.md ./cordova-plugin-inappbrowser/README.md ./cordova-plugin-inappbrowser/src/blackberry10/README.md ./cordova-plugin-media/README.md ./cordova-plugin-media-capture/README.md ./cordova-plugin-network-information/README.md ./cordova-plugin-splashscreen/README.md ./cordova-plugin-vibration/README.md -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/pl/README.md: -------------------------------------------------------------------------------- 1 | 19 | 20 | # BlackBerry 10 In-App-Browser Plugin 21 | 22 | W aplikacji Przeglądarka funkcjonalność jest całkowicie zawarty w wspólnej js. Tam jest nie native wdrażania wymagane. Aby zainstalować ten plugin, następować po ten [Przewodnik interfejsu wiersza polecenia](http://cordova.apache.org/docs/en/edge/guide_cli_index.md.html#The%20Command-line%20Interface). 23 | 24 | Jeśli nie używasz interfejsu wiersza polecenia Cordova, następować po [Przy użyciu Plugman do zarządzania wtyczki](http://cordova.apache.org/docs/en/edge/guide_plugin_ref_plugman.md.html). ./cordova-plugin-battery-status/README.md ./cordova-plugin-camera/README.md ./cordova-plugin-console/README.md ./cordova-plugin-contacts/README.md ./cordova-plugin-device/README.md ./cordova-plugin-device-motion/README.md ./cordova-plugin-device-orientation/README.md ./cordova-plugin-device-orientation/src/blackberry10/README.md ./cordova-plugin-file/README.md ./cordova-plugin-file-transfer/README.md ./cordova-plugin-geolocation/README.md ./cordova-plugin-globalization/README.md ./cordova-plugin-inappbrowser/README.md ./cordova-plugin-inappbrowser/src/blackberry10/README.md ./cordova-plugin-media/README.md ./cordova-plugin-media-capture/README.md ./cordova-plugin-network-information/README.md ./cordova-plugin-splashscreen/README.md ./cordova-plugin-vibration/README.md -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/zh/README.md: -------------------------------------------------------------------------------- 1 | 19 | 20 | # 黑莓 10 的應用程式瀏覽器外掛程式 21 | 22 | 在應用程式瀏覽器功能完全包含在常見的 js。 還有沒有本機的實施所需。 若要安裝此外掛程式,請按照[命令列介面指南](http://cordova.apache.org/docs/en/edge/guide_cli_index.md.html#The%20Command-line%20Interface). 23 | 24 | 如果你不使用的科爾多瓦命令列介面,請按照[使用 Plugman 管理外掛程式](http://cordova.apache.org/docs/en/edge/guide_plugin_ref_plugman.md.html)。 ./cordova-plugin-battery-status/README.md ./cordova-plugin-camera/README.md ./cordova-plugin-console/README.md ./cordova-plugin-contacts/README.md ./cordova-plugin-device/README.md ./cordova-plugin-device-motion/README.md ./cordova-plugin-device-orientation/README.md ./cordova-plugin-device-orientation/src/blackberry10/README.md ./cordova-plugin-file/README.md ./cordova-plugin-file-transfer/README.md ./cordova-plugin-geolocation/README.md ./cordova-plugin-globalization/README.md ./cordova-plugin-inappbrowser/README.md ./cordova-plugin-inappbrowser/src/blackberry10/README.md ./cordova-plugin-media/README.md ./cordova-plugin-media-capture/README.md ./cordova-plugin-network-information/README.md ./cordova-plugin-splashscreen/README.md ./cordova-plugin-vibration/README.md -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/src/ios/CDVInAppBrowser.h: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed to the Apache Software Foundation (ASF) under one 3 | or more contributor license agreements. See the NOTICE file 4 | distributed with this work for additional information 5 | regarding copyright ownership. The ASF licenses this file 6 | to you under the Apache License, Version 2.0 (the 7 | "License"); you may not use this file except in compliance 8 | with the License. You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, 13 | software distributed under the License is distributed on an 14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, either express or implied. See the License for the 16 | specific language governing permissions and limitations 17 | under the License. 18 | */ 19 | 20 | #import 21 | #import 22 | #import 23 | 24 | #ifdef __CORDOVA_4_0_0 25 | #import 26 | #else 27 | #import 28 | #endif 29 | 30 | @class CDVInAppBrowserViewController; 31 | 32 | @interface CDVInAppBrowser : CDVPlugin { 33 | } 34 | 35 | @property (nonatomic, retain) CDVInAppBrowserViewController* inAppBrowserViewController; 36 | @property (nonatomic, copy) NSString* callbackId; 37 | @property (nonatomic, copy) NSRegularExpression *callbackIdPattern; 38 | 39 | - (void)open:(CDVInvokedUrlCommand*)command; 40 | - (void)close:(CDVInvokedUrlCommand*)command; 41 | - (void)injectScriptCode:(CDVInvokedUrlCommand*)command; 42 | - (void)show:(CDVInvokedUrlCommand*)command; 43 | 44 | @end 45 | 46 | @interface CDVInAppBrowserOptions : NSObject {} 47 | 48 | @property (nonatomic, assign) BOOL location; 49 | @property (nonatomic, assign) BOOL toolbar; 50 | @property (nonatomic, copy) NSString* closebuttoncaption; 51 | @property (nonatomic, copy) NSString* toolbarposition; 52 | @property (nonatomic, assign) BOOL clearcache; 53 | @property (nonatomic, assign) BOOL clearsessioncache; 54 | 55 | @property (nonatomic, copy) NSString* presentationstyle; 56 | @property (nonatomic, copy) NSString* transitionstyle; 57 | 58 | @property (nonatomic, assign) BOOL enableviewportscale; 59 | @property (nonatomic, assign) BOOL mediaplaybackrequiresuseraction; 60 | @property (nonatomic, assign) BOOL allowinlinemediaplayback; 61 | @property (nonatomic, assign) BOOL keyboarddisplayrequiresuseraction; 62 | @property (nonatomic, assign) BOOL suppressesincrementalrendering; 63 | @property (nonatomic, assign) BOOL hidden; 64 | @property (nonatomic, assign) BOOL disallowoverscroll; 65 | 66 | + (CDVInAppBrowserOptions*)parseOptions:(NSString*)options; 67 | 68 | @end 69 | 70 | @interface CDVInAppBrowserViewController : UIViewController { 71 | @private 72 | NSString* _userAgent; 73 | NSString* _prevUserAgent; 74 | NSInteger _userAgentLockToken; 75 | CDVInAppBrowserOptions *_browserOptions; 76 | 77 | #ifdef __CORDOVA_4_0_0 78 | CDVUIWebViewDelegate* _webViewDelegate; 79 | #else 80 | CDVWebViewDelegate* _webViewDelegate; 81 | #endif 82 | 83 | } 84 | 85 | @property (nonatomic, strong) IBOutlet UIWebView* webView; 86 | @property (nonatomic, strong) IBOutlet UIBarButtonItem* closeButton; 87 | @property (nonatomic, strong) IBOutlet UILabel* addressLabel; 88 | @property (nonatomic, strong) IBOutlet UIBarButtonItem* backButton; 89 | @property (nonatomic, strong) IBOutlet UIBarButtonItem* forwardButton; 90 | @property (nonatomic, strong) IBOutlet UIActivityIndicatorView* spinner; 91 | @property (nonatomic, strong) IBOutlet UIToolbar* toolbar; 92 | 93 | @property (nonatomic, weak) id orientationDelegate; 94 | @property (nonatomic, weak) CDVInAppBrowser* navigationDelegate; 95 | @property (nonatomic) NSURL* currentURL; 96 | 97 | - (void)close; 98 | - (void)navigateTo:(NSURL*)url; 99 | - (void)showLocationBar:(BOOL)show; 100 | - (void)showToolBar:(BOOL)show : (NSString *) toolbarPosition; 101 | - (void)setCloseButtonTitle:(NSString*)title; 102 | 103 | - (id)initWithUserAgent:(NSString*)userAgent prevUserAgent:(NSString*)prevUserAgent browserOptions: (CDVInAppBrowserOptions*) browserOptions; 104 | 105 | @end 106 | 107 | @interface CDVInAppBrowserNavigationController : UINavigationController 108 | 109 | @property (nonatomic, weak) id orientationDelegate; 110 | 111 | @end 112 | 113 | -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/src/ubuntu/InAppBrowser.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2013 Canonical Ltd. 4 | * 5 | * Licensed to the Apache Software Foundation (ASF) under one 6 | * or more contributor license agreements. See the NOTICE file 7 | * distributed with this work for additional information 8 | * regarding copyright ownership. The ASF licenses this file 9 | * to you under the Apache License, Version 2.0 (the 10 | * "License"); you may not use this file except in compliance 11 | * with the License. You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, 16 | * software distributed under the License is distributed on an 17 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 18 | * KIND, either express or implied. See the License for the 19 | * specific language governing permissions and limitations 20 | * under the License. 21 | * 22 | */ 23 | import QtQuick 2.0 24 | import Ubuntu.Components.Popups 0.1 25 | import Ubuntu.Components 0.1 26 | import com.canonical.Oxide 1.0 27 | 28 | Rectangle { 29 | anchors.fill: parent 30 | id: inappbrowser 31 | property string url1 32 | Rectangle { 33 | border.color: "black" 34 | width: parent.width 35 | height: urlEntry.height 36 | color: "gray" 37 | TextInput { 38 | id: urlEntry 39 | width: parent.width - closeButton.width 40 | text: url1 41 | activeFocusOnPress: false 42 | } 43 | Image { 44 | id: closeButton 45 | width: height 46 | x: parent.width - width 47 | height: parent.height 48 | source: "close.png" 49 | MouseArea { 50 | anchors.fill: parent 51 | onClicked: { 52 | root.exec("InAppBrowser", "close", [0, 0]) 53 | } 54 | } 55 | } 56 | } 57 | 58 | property string usContext: "oxide://main-world/2" 59 | 60 | function executeJS(scId, code) { 61 | var req = _view.rootFrame.sendMessage(usContext, "EXECUTE", {code: code}); 62 | 63 | req.onreply = function(response) { 64 | var code = 'cordova.callback(' + scId + ', JSON.parse(\'' + JSON.stringify(response.result) + '\'))'; 65 | console.warn(code); 66 | cordova.javaScriptExecNeeded(code); 67 | console.warn("RESP:" + JSON.stringify(response)); 68 | }; 69 | } 70 | 71 | WebView { 72 | width: parent.width 73 | y: urlEntry.height 74 | height: parent.height - y 75 | url: url1 76 | id: _view 77 | onLoadingStateChanged: { 78 | root.exec("InAppBrowser", "loadFinished", [_view.loading]) 79 | } 80 | context: WebContext { 81 | id: webcontext 82 | 83 | userScripts: [ 84 | UserScript { 85 | context: usContext 86 | emulateGreasemonkey: true 87 | url: "InAppBrowser_escapeScript.js" 88 | } 89 | ] 90 | } 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/src/ubuntu/InAppBrowser_escapeScript.js: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | * 20 | */ 21 | 22 | oxide.addMessageHandler("EXECUTE", function(msg) { 23 | var code = msg.args.code; 24 | try { 25 | msg.reply({result: eval(code)}); 26 | } catch(e) { 27 | msg.error("Code threw exception: \"" + e + "\""); 28 | } 29 | }); 30 | -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/src/ubuntu/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/src/ubuntu/close.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/src/ubuntu/inappbrowser.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2013 Canonical Ltd. 4 | * 5 | * Licensed to the Apache Software Foundation (ASF) under one 6 | * or more contributor license agreements. See the NOTICE file 7 | * distributed with this work for additional information 8 | * regarding copyright ownership. The ASF licenses this file 9 | * to you under the Apache License, Version 2.0 (the 10 | * "License"); you may not use this file except in compliance 11 | * with the License. You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, 16 | * software distributed under the License is distributed on an 17 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 18 | * KIND, either express or implied. See the License for the 19 | * specific language governing permissions and limitations 20 | * under the License. 21 | * 22 | */ 23 | 24 | #include 25 | #include 26 | 27 | #include "inappbrowser.h" 28 | #include 29 | 30 | Inappbrowser::Inappbrowser(Cordova *cordova): CPlugin(cordova), _eventCb(0) { 31 | } 32 | 33 | const char code[] = "\ 34 | var component; \ 35 | function createObject() { \ 36 | component = Qt.createComponent(%1); \ 37 | if (component.status == Component.Ready) \ 38 | finishCreation(); \ 39 | else \ 40 | component.statusChanged.connect(finishCreation); \ 41 | } \ 42 | function finishCreation() { \ 43 | CordovaWrapper.global.inappbrowser = component.createObject(root, \ 44 | {root: root, cordova: cordova, url1: %2}); \ 45 | } \ 46 | createObject()"; 47 | 48 | const char EXIT_EVENT[] = "{type: 'exit'}"; 49 | const char LOADSTART_EVENT[] = "{type: 'loadstart'}"; 50 | const char LOADSTOP_EVENT[] = "{type: 'loadstop'}"; 51 | const char LOADERROR_EVENT[] = "{type: 'loaderror'}"; 52 | 53 | void Inappbrowser::open(int cb, int, const QString &url, const QString &, const QString &) { 54 | assert(_eventCb == 0); 55 | 56 | _eventCb = cb; 57 | 58 | QString path = m_cordova->get_app_dir() + "/../qml/InAppBrowser.qml"; 59 | QString qml = QString(code) 60 | .arg(CordovaInternal::format(path)).arg(CordovaInternal::format(url)); 61 | m_cordova->execQML(qml); 62 | } 63 | 64 | void Inappbrowser::show(int, int) { 65 | m_cordova->execQML("CordovaWrapper.global.inappbrowser.visible = true"); 66 | } 67 | 68 | void Inappbrowser::close(int, int) { 69 | m_cordova->execQML("CordovaWrapper.global.inappbrowser.destroy()"); 70 | this->callbackWithoutRemove(_eventCb, EXIT_EVENT); 71 | _eventCb = 0; 72 | } 73 | 74 | void Inappbrowser::injectStyleFile(int scId, int ecId, const QString& src, bool b) { 75 | QString code("(function(d) { var c = d.createElement('link'); c.rel='stylesheet'; c.type='text/css'; c.href = %1; d.head.appendChild(c);})(document)"); 76 | code = code.arg(CordovaInternal::format(src)); 77 | 78 | injectScriptCode(scId, ecId, code, b); 79 | } 80 | 81 | void Inappbrowser::injectStyleCode(int scId, int ecId, const QString& src, bool b) { 82 | QString code("(function(d) { var c = d.createElement('style'); c.innerHTML = %1; d.body.appendChild(c); })(document)"); 83 | code = code.arg(CordovaInternal::format(src)); 84 | 85 | injectScriptCode(scId, ecId, code, b); 86 | } 87 | 88 | void Inappbrowser::injectScriptFile(int scId, int ecId, const QString& src, bool b) { 89 | QString code("(function(d) { var c = d.createElement('script'); c.src = %1; d.body.appendChild(c);})(document)"); 90 | code = code.arg(CordovaInternal::format(src)); 91 | 92 | injectScriptCode(scId, ecId, code, b); 93 | } 94 | 95 | void Inappbrowser::injectScriptCode(int scId, int, const QString& code, bool) { 96 | m_cordova->execQML(QString("CordovaWrapper.global.inappbrowser.executeJS(%2, %1)").arg(CordovaInternal::format(code)).arg(scId)); 97 | } 98 | 99 | void Inappbrowser::loadFinished(bool status) { 100 | if (!status) { 101 | this->callbackWithoutRemove(_eventCb, LOADSTOP_EVENT); 102 | } else { 103 | this->callbackWithoutRemove(_eventCb, LOADSTART_EVENT); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/src/ubuntu/inappbrowser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2013 Canonical Ltd. 4 | * 5 | * Licensed to the Apache Software Foundation (ASF) under one 6 | * or more contributor license agreements. See the NOTICE file 7 | * distributed with this work for additional information 8 | * regarding copyright ownership. The ASF licenses this file 9 | * to you under the Apache License, Version 2.0 (the 10 | * "License"); you may not use this file except in compliance 11 | * with the License. You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, 16 | * software distributed under the License is distributed on an 17 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 18 | * KIND, either express or implied. See the License for the 19 | * specific language governing permissions and limitations 20 | * under the License. 21 | * 22 | */ 23 | #ifndef INAPPBROWSER_H 24 | #define INAPPBROWSER_H 25 | 26 | #include 27 | #include 28 | 29 | class Inappbrowser: public CPlugin { 30 | Q_OBJECT 31 | public: 32 | Inappbrowser(Cordova *cordova); 33 | 34 | virtual const QString fullName() override { 35 | return Inappbrowser::fullID(); 36 | } 37 | 38 | virtual const QString shortName() override { 39 | return "InAppBrowser"; 40 | } 41 | 42 | static const QString fullID() { 43 | return "InAppBrowser"; 44 | } 45 | 46 | public slots: 47 | void open(int cb, int, const QString &url, const QString &windowName, const QString &windowFeatures); 48 | void show(int, int); 49 | void close(int, int); 50 | void injectStyleFile(int cb, int, const QString&, bool); 51 | void injectStyleCode(int cb, int, const QString&, bool); 52 | void injectScriptFile(int cb, int, const QString&, bool); 53 | void injectScriptCode(int cb, int, const QString&, bool); 54 | 55 | void loadFinished(bool status); 56 | 57 | private: 58 | int _eventCb; 59 | }; 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/tests/plugin.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 24 | Cordova InAppBrowser Plugin Tests 25 | Apache 2.0 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/tests/resources/inject.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #style-update-file { 20 | display: block !important; 21 | } 22 | -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/tests/resources/inject.html: -------------------------------------------------------------------------------- 1 | 2 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | Cordova Mobile Spec 29 | 30 | 31 | 32 |

InAppBrowser - Script / Style Injection Test

33 | 34 | 35 |
User-Agent:
36 | 37 | 44 | 45 | -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/tests/resources/inject.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | var d = document.getElementById("header") 20 | d.innerHTML = "Script file successfully injected"; 21 | -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/tests/resources/local.html: -------------------------------------------------------------------------------- 1 | 2 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | IAB test page 29 | 30 | 36 | 39 | 40 | 41 |

Local URL

42 |
43 | You have successfully loaded a local URL: 44 | 45 |
46 |
47 |
User-Agent =
48 |
49 |
Likely running inAppBrowser: Device version from Cordova=not found, Back link should not work, toolbar may be present, logcat should show failed 'gap:' calls.
50 |
51 |
Visit Google (whitelisted)
52 |
Visit Yahoo (not whitelisted)
53 | 54 | 55 |

Back 56 |

57 | 58 |

tall div with border
59 | 60 | 67 | 68 | -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/tests/resources/local.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/tests/resources/local.pdf -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/tests/resources/video.html: -------------------------------------------------------------------------------- 1 | 2 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | Cordova Mobile Spec 29 | 30 | 31 | 32 | 37 |
38 | 39 | 40 |
41 | 42 | 43 | -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/www/inappbrowser.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | .inAppBrowserWrap { 21 | margin: 0; 22 | padding: 0; 23 | outline: 0; 24 | font-size: 100%; 25 | vertical-align: baseline; 26 | background: 0 0; 27 | position: fixed; 28 | top: 0; 29 | left: 0; 30 | width: 100%; 31 | height: 100%; 32 | z-index: 9999999; 33 | box-sizing: border-box; 34 | border: 40px solid #bfbfbf; 35 | border: 40px solid rgba(0, 0, 0, 0.25); 36 | } 37 | 38 | .inAppBrowserWrapFullscreen { 39 | border: 0; 40 | } 41 | -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/plugins/cordova-plugin-inappbrowser/www/inappbrowser.js: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | * 20 | */ 21 | 22 | // special patch to correctly work on Ripple emulator (CB-9760) 23 | if (window.parent && !!window.parent.ripple) { // https://gist.github.com/triceam/4658021 24 | module.exports = window.open.bind(window); // fallback to default window.open behaviour 25 | return; 26 | } 27 | 28 | var exec = require('cordova/exec'); 29 | var channel = require('cordova/channel'); 30 | var modulemapper = require('cordova/modulemapper'); 31 | var urlutil = require('cordova/urlutil'); 32 | 33 | function InAppBrowser() { 34 | this.channels = { 35 | 'loadstart': channel.create('loadstart'), 36 | 'loadstop' : channel.create('loadstop'), 37 | 'loaderror' : channel.create('loaderror'), 38 | 'exit' : channel.create('exit') 39 | }; 40 | } 41 | 42 | InAppBrowser.prototype = { 43 | _eventHandler: function (event) { 44 | if (event && (event.type in this.channels)) { 45 | this.channels[event.type].fire(event); 46 | } 47 | }, 48 | close: function (eventname) { 49 | exec(null, null, "InAppBrowser", "close", []); 50 | }, 51 | show: function (eventname) { 52 | exec(null, null, "InAppBrowser", "show", []); 53 | }, 54 | addEventListener: function (eventname,f) { 55 | if (eventname in this.channels) { 56 | this.channels[eventname].subscribe(f); 57 | } 58 | }, 59 | removeEventListener: function(eventname, f) { 60 | if (eventname in this.channels) { 61 | this.channels[eventname].unsubscribe(f); 62 | } 63 | }, 64 | 65 | executeScript: function(injectDetails, cb) { 66 | if (injectDetails.code) { 67 | exec(cb, null, "InAppBrowser", "injectScriptCode", [injectDetails.code, !!cb]); 68 | } else if (injectDetails.file) { 69 | exec(cb, null, "InAppBrowser", "injectScriptFile", [injectDetails.file, !!cb]); 70 | } else { 71 | throw new Error('executeScript requires exactly one of code or file to be specified'); 72 | } 73 | }, 74 | 75 | insertCSS: function(injectDetails, cb) { 76 | if (injectDetails.code) { 77 | exec(cb, null, "InAppBrowser", "injectStyleCode", [injectDetails.code, !!cb]); 78 | } else if (injectDetails.file) { 79 | exec(cb, null, "InAppBrowser", "injectStyleFile", [injectDetails.file, !!cb]); 80 | } else { 81 | throw new Error('insertCSS requires exactly one of code or file to be specified'); 82 | } 83 | } 84 | }; 85 | 86 | module.exports = function(strUrl, strWindowName, strWindowFeatures, callbacks) { 87 | // Don't catch calls that write to existing frames (e.g. named iframes). 88 | if (window.frames && window.frames[strWindowName]) { 89 | var origOpenFunc = modulemapper.getOriginalSymbol(window, 'open'); 90 | return origOpenFunc.apply(window, arguments); 91 | } 92 | 93 | strUrl = urlutil.makeAbsolute(strUrl); 94 | var iab = new InAppBrowser(); 95 | 96 | callbacks = callbacks || {}; 97 | for (var callbackName in callbacks) { 98 | iab.addEventListener(callbackName, callbacks[callbackName]); 99 | } 100 | 101 | var cb = function(eventname) { 102 | iab._eventHandler(eventname); 103 | }; 104 | 105 | strWindowFeatures = strWindowFeatures || ""; 106 | 107 | exec(cb, cb, "InAppBrowser", "open", [strUrl, strWindowName, strWindowFeatures]); 108 | return iab; 109 | }; 110 | 111 | -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/plugins/cordova-plugin-whitelist/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | 21 | 22 | # Contributing to Apache Cordova 23 | 24 | Anyone can contribute to Cordova. And we need your contributions. 25 | 26 | There are multiple ways to contribute: report bugs, improve the docs, and 27 | contribute code. 28 | 29 | For instructions on this, start with the 30 | [contribution overview](http://cordova.apache.org/contribute/). 31 | 32 | The details are explained there, but the important items are: 33 | - Sign and submit an Apache ICLA (Contributor License Agreement). 34 | - Have a Jira issue open that corresponds to your contribution. 35 | - Run the tests so your patch doesn't break existing functionality. 36 | 37 | We look forward to your contributions! 38 | -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/plugins/cordova-plugin-whitelist/NOTICE: -------------------------------------------------------------------------------- 1 | Apache Cordova 2 | Copyright 2012 The Apache Software Foundation 3 | 4 | This product includes software developed at 5 | The Apache Software Foundation (http://www.apache.org/). 6 | -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/plugins/cordova-plugin-whitelist/RELEASENOTES.md: -------------------------------------------------------------------------------- 1 | 21 | # Release Notes 22 | 23 | ### 1.2.0 (Nov 18, 2015) 24 | * removed **iOS** engine check from `plugin.xml` 25 | * [CB-10035](https://issues.apache.org/jira/browse/CB-10035) Updated `RELEASENOTES` to be newest to oldest 26 | * [CB-9972](https://issues.apache.org/jira/browse/CB-9972) - Remove **iOS** whitelist 27 | * Updated the text, it should read 4.0.x and greater, since this plugin will be required for `cordova-android 5.0` 28 | * Fixing contribute link. 29 | * Updated `plugin.xml ` tag to remove warning about not needing this plugin if you are using the **iOS 9 SDK** 30 | * [CB-9738](https://issues.apache.org/jira/browse/CB-9738) - Disable whitelist use when runtime environment is **iOS 9** 31 | * [CB-9740](https://issues.apache.org/jira/browse/CB-9740) - Add `` tag describing whitelist plugin not needed on `cordova-ios` and cordova-android 3.x` 32 | * [CB-9568](https://issues.apache.org/jira/browse/CB-9568) - Update whitelist plugin to allow all network access by default 33 | * [CB-9337](https://issues.apache.org/jira/browse/CB-9337) - enable use of `` tags for native code network requests 34 | 35 | ### 1.1.0 (Jun 17, 2015) 36 | * [CB-9128](https://issues.apache.org/jira/browse/CB-9128) cordova-plugin-whitelist documentation translation: cordova-plugin-whitelist 37 | * fix npm md issue 38 | * Usage of CDVURLRequestFilter protocol. 39 | * [CB-9089](https://issues.apache.org/jira/browse/CB-9089) - iOS whitelist plugin does not compile 40 | * [CB-9090](https://issues.apache.org/jira/browse/CB-9090) - Enable whitelist plugin for cordova-ios 4.0.0 41 | * Fixed error in Content-Security-Policy example 42 | 43 | ### 1.0.0 (Mar 25, 2015) 44 | * [CB-8739](https://issues.apache.org/jira/browse/CB-8739) added missing license headers 45 | * Add @Override to CustomConfigXmlParser methods 46 | * Change ID to cordova-plugin-whitelist rather than reverse-DNS-style 47 | * Tweak CSP examples in README 48 | * [CB-8660](https://issues.apache.org/jira/browse/CB-8660) remove extra commas from package.json 49 | -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/plugins/cordova-plugin-whitelist/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cordova-plugin-whitelist", 3 | "version": "1.2.0", 4 | "description": "Cordova Whitelist Plugin", 5 | "cordova": { 6 | "platforms": [ 7 | "android" 8 | ] 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "https://github.com/apache/cordova-plugin-whitelist" 13 | }, 14 | "keywords": [ 15 | "cordova", 16 | "whitelist", 17 | "ecosystem:cordova", 18 | "cordova-android" 19 | ], 20 | "engines": [ 21 | { 22 | "name": "cordova-android", 23 | "version": ">=4.0.0-dev" 24 | } 25 | ], 26 | "author": "Apache Software Foundation", 27 | "license": "Apache 2.0" 28 | } 29 | -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/plugins/cordova-plugin-whitelist/plugin.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 24 | Whitelist 25 | Cordova Network Whitelist Plugin 26 | Apache 2.0 27 | cordova,whitelist,policy 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | This plugin is only applicable for versions of cordova-android greater than 4.0. If you have a previous platform version, you do *not* need this plugin since the whitelist will be built in. 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/plugins/cordova-plugin-whitelist/whitelist.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | * 19 | */ 20 | 21 | if (!document.querySelector('meta[http-equiv=Content-Security-Policy]')) { 22 | var msg = 'No Content-Security-Policy meta tag found. Please add one when using the cordova-plugin-whitelist plugin.'; 23 | console.error(msg); 24 | setInterval(function() { 25 | console.warn(msg); 26 | }, 10000); 27 | } 28 | -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/plugins/fetch.json: -------------------------------------------------------------------------------- 1 | { 2 | "cordova-plugin-inappbrowser": { 3 | "source": { 4 | "type": "registry", 5 | "id": "cordova-plugin-inappbrowser" 6 | }, 7 | "is_top_level": true, 8 | "variables": {} 9 | }, 10 | "cordova-plugin-whitelist": { 11 | "source": { 12 | "type": "registry", 13 | "id": "cordova-plugin-whitelist@1" 14 | }, 15 | "is_top_level": true, 16 | "variables": {} 17 | } 18 | } -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/icons/android/icon-36-ldpi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/icons/android/icon-36-ldpi.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/icons/android/icon-48-mdpi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/icons/android/icon-48-mdpi.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/icons/android/icon-72-hdpi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/icons/android/icon-72-hdpi.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/icons/android/icon-96-xhdpi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/icons/android/icon-96-xhdpi.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/icons/ios/icon-40-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/icons/ios/icon-40-2x.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/icons/ios/icon-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/icons/ios/icon-40.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/icons/ios/icon-50-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/icons/ios/icon-50-2x.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/icons/ios/icon-50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/icons/ios/icon-50.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/icons/ios/icon-57-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/icons/ios/icon-57-2x.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/icons/ios/icon-57.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/icons/ios/icon-57.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/icons/ios/icon-60-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/icons/ios/icon-60-2x.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/icons/ios/icon-60-3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/icons/ios/icon-60-3x.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/icons/ios/icon-60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/icons/ios/icon-60.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/icons/ios/icon-72-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/icons/ios/icon-72-2x.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/icons/ios/icon-72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/icons/ios/icon-72.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/icons/ios/icon-76-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/icons/ios/icon-76-2x.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/icons/ios/icon-76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/icons/ios/icon-76.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/icons/ios/icon-small-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/icons/ios/icon-small-2x.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/icons/ios/icon-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/icons/ios/icon-small.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/icons/windows/Square150x150Logo.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/icons/windows/Square150x150Logo.scale-100.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/icons/windows/Square150x150Logo.scale-240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/icons/windows/Square150x150Logo.scale-240.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/icons/windows/Square30x30Logo.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/icons/windows/Square30x30Logo.scale-100.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/icons/windows/Square310x310Logo.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/icons/windows/Square310x310Logo.scale-100.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/icons/windows/Square44x44Logo.scale-240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/icons/windows/Square44x44Logo.scale-240.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/icons/windows/Square70x70Logo.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/icons/windows/Square70x70Logo.scale-100.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/icons/windows/Square71x71Logo.scale-240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/icons/windows/Square71x71Logo.scale-240.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/icons/windows/StoreLogo.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/icons/windows/StoreLogo.scale-100.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/icons/windows/StoreLogo.scale-240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/icons/windows/StoreLogo.scale-240.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/icons/windows/Wide310x150Logo.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/icons/windows/Wide310x150Logo.scale-100.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/icons/windows/Wide310x150Logo.scale-240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/icons/windows/Wide310x150Logo.scale-240.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/icons/wp8/ApplicationIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/icons/wp8/ApplicationIcon.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/icons/wp8/Background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/icons/wp8/Background.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/native/android/ant.properties: -------------------------------------------------------------------------------- 1 | key.store= 2 | key.alias= 3 | key.store.password= 4 | key.alias.password= -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/screens/android/screen-hdpi-landscape.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/screens/android/screen-hdpi-landscape.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/screens/android/screen-hdpi-portrait.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/screens/android/screen-hdpi-portrait.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/screens/android/screen-ldpi-landscape.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/screens/android/screen-ldpi-landscape.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/screens/android/screen-ldpi-portrait.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/screens/android/screen-ldpi-portrait.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/screens/android/screen-mdpi-landscape.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/screens/android/screen-mdpi-landscape.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/screens/android/screen-mdpi-portrait.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/screens/android/screen-mdpi-portrait.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/screens/android/screen-xhdpi-landscape.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/screens/android/screen-xhdpi-landscape.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/screens/android/screen-xhdpi-portrait.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/screens/android/screen-xhdpi-portrait.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/screens/ios/screen-ipad-landscape-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/screens/ios/screen-ipad-landscape-2x.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/screens/ios/screen-ipad-landscape.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/screens/ios/screen-ipad-landscape.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/screens/ios/screen-ipad-portrait-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/screens/ios/screen-ipad-portrait-2x.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/screens/ios/screen-ipad-portrait.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/screens/ios/screen-ipad-portrait.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/screens/ios/screen-iphone-568h-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/screens/ios/screen-iphone-568h-2x.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/screens/ios/screen-iphone-landscape-736h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/screens/ios/screen-iphone-landscape-736h.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/screens/ios/screen-iphone-portrait-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/screens/ios/screen-iphone-portrait-2x.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/screens/ios/screen-iphone-portrait-667h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/screens/ios/screen-iphone-portrait-667h.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/screens/ios/screen-iphone-portrait-736h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/screens/ios/screen-iphone-portrait-736h.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/screens/ios/screen-iphone-portrait.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/screens/ios/screen-iphone-portrait.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/screens/windows/SplashScreen.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/screens/windows/SplashScreen.scale-100.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/screens/windows/SplashScreen.scale-240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/screens/windows/SplashScreen.scale-240.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/screens/windows/SplashScreenPhone.scale-240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/screens/windows/SplashScreenPhone.scale-240.png -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/res/screens/wp8/SplashScreenImage.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/res/screens/wp8/SplashScreenImage.jpg -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/taco.json: -------------------------------------------------------------------------------- 1 | { 2 | "cordova-cli": "5.3.3" 3 | } 4 | -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/www/fonts/ionicons.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/www/fonts/ionicons.eot -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/www/fonts/ionicons.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/www/fonts/ionicons.ttf -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/www/fonts/ionicons.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Cordova/MobileApp/www/fonts/ionicons.woff -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/www/index.html: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | MobileApp 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |

Your application (Mobile)

29 |
30 | 31 |

Welcome, {{authentication.userName || 'Anonymous'}}

32 |
33 |
34 | {{message}} 35 |
36 |
37 | 40 | 43 | 46 |
47 | 48 | -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/www/scripts/controllers/authController.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | app.controller('authController', ['$sce', '$scope', '$location', 'authService', function ($sce, $scope, $location, authService) { 3 | 4 | $scope.message = ""; 5 | 6 | $scope.logIn = function () { 7 | authService.logIn().then(function (response) { 8 | authService.confirmMessage().then(function (response) { $scope.message = response; }); 9 | }, function (err) { 10 | $scope.message = err; 11 | }); 12 | }; 13 | 14 | $scope.logOut = function () { 15 | authService.logOut().then(function (response) { 16 | $scope.message = ""; 17 | }, function (err) { 18 | $scope.message = err; 19 | }); 20 | }; 21 | 22 | $scope.queryServer = function () { 23 | authService.confirmMessage().then(function (response) { $scope.message = response; }); 24 | }; 25 | 26 | $scope.authentication = authService.authentication; 27 | }]); -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/www/scripts/init.js: -------------------------------------------------------------------------------- 1 | var app = angular.module('mainApp', ['LocalStorageModule', 'ionic', 'angular-jwt']); 2 | 3 | app.constant('authConfig', { 4 | clientId: 'myClient', 5 | logInApi: 'http://localhost:54540/connect/authorize', 6 | logOutApi: 'http://localhost:54540/connect/logout', 7 | tokenApi: 'http://localhost:54540/connect/token', 8 | messageApi: 'http://localhost:54540/api/message', 9 | redirect_uri: 'http://localhost/callback', 10 | post_logout_redirect_uri: 'http://localhost/callback' 11 | }); 12 | 13 | app.config(function ($httpProvider) { 14 | $httpProvider.interceptors.push('authInterceptorService'); 15 | }); 16 | 17 | app.run(['authService', function (authService) { 18 | authService.fillAuthData(); 19 | }]); 20 | 21 | -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/www/scripts/libraries/angular-jwt.min.js: -------------------------------------------------------------------------------- 1 | !function(){angular.module("angular-jwt",["angular-jwt.interceptor","angular-jwt.jwt"]),angular.module("angular-jwt.interceptor",[]).provider("jwtInterceptor",function(){this.urlParam=null,this.authHeader="Authorization",this.authPrefix="Bearer ",this.tokenGetter=function(){return null};var e=this;this.$get=["$q","$injector","$rootScope",function(r,t,a){return{request:function(a){if(a.skipAuthorization)return a;if(e.urlParam){if(a.params=a.params||{},a.params[e.urlParam])return a}else if(a.headers=a.headers||{},a.headers[e.authHeader])return a;var n=r.when(t.invoke(e.tokenGetter,this,{config:a}));return n.then(function(r){return r&&(e.urlParam?a.params[e.urlParam]=r:a.headers[e.authHeader]=e.authPrefix+r),a})},responseError:function(e){return 401===e.status&&a.$broadcast("unauthenticated",e),r.reject(e)}}}]}),angular.module("angular-jwt.jwt",[]).service("jwtHelper",function(){this.urlBase64Decode=function(e){var r=e.replace(/-/g,"+").replace(/_/g,"/");switch(r.length%4){case 0:break;case 2:r+="==";break;case 3:r+="=";break;default:throw"Illegal base64url string!"}return decodeURIComponent(escape(window.atob(r)))},this.decodeToken=function(e){var r=e.split(".");if(3!==r.length)throw new Error("JWT must have 3 parts");var t=this.urlBase64Decode(r[1]);if(!t)throw new Error("Cannot decode the token");return JSON.parse(t)},this.getTokenExpirationDate=function(e){var r;if(r=this.decodeToken(e),"undefined"==typeof r.exp)return null;var t=new Date(0);return t.setUTCSeconds(r.exp),t},this.isTokenExpired=function(e,r){var t=this.getTokenExpirationDate(e);return r=r||0,null===t?!1:!(t.valueOf()>(new Date).valueOf()+1e3*r)}})}(); -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/www/scripts/services/authInterceptorService.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | app.factory('authInterceptorService', ['$q', '$location', 'localStorageService', function ($q, $location, localStorageService) { 3 | 4 | var authInterceptorServiceFactory = {}; 5 | 6 | var _request = function (config) { 7 | config.headers = config.headers || {}; 8 | var authData = localStorageService.get('authorizationData'); 9 | if (authData) { 10 | config.headers.Authorization = 'Bearer ' + authData.token; 11 | } 12 | return config; 13 | } 14 | 15 | authInterceptorServiceFactory.request = _request; 16 | 17 | return authInterceptorServiceFactory; 18 | }]); -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/www/scripts/services/authService.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | app.factory('authService', ['$http', '$q', 'localStorageService', 'utilitiesService', 'jwtHelper', 'authConfig', function ($http, $q, localStorageService, utilitiesService, jwtHelper, authConfig) { 3 | 4 | var authServiceFactory = {}; 5 | 6 | var _authentication = { 7 | isAuth: false, 8 | userName: "" 9 | }; 10 | 11 | var _logIn = function () { 12 | var deferred = $q.defer(); 13 | var ref = window.open(authConfig.logInApi + '?client_id=' + authConfig.clientId + '&redirect_uri=' + authConfig.redirect_uri + '&response_type=code&scope=openid', '_blank', 'location=no'); 14 | ref.addEventListener('loadstart', function (event) { 15 | if (utilitiesService.startsWith(event.url, authConfig.redirect_uri)) { 16 | var authorizationCode = utilitiesService.getURLParameter(event.url, "code"); 17 | $http.post(authConfig.tokenApi, 18 | 'grant_type=authorization_code&code=' + authorizationCode + '&client_id=' + authConfig.clientId + '&redirect_uri=' + authConfig.redirect_uri, 19 | { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }).then(function successCallback(response) { 20 | var requestToken = response.data.access_token; 21 | var idToken = response.data.id_token; 22 | var userName = jwtHelper.decodeToken(idToken).unique_name; 23 | localStorageService.set('authorizationData', { token: requestToken, userName: userName }); 24 | _fillAuthData(); 25 | deferred.resolve(ref.close()); 26 | }); 27 | } 28 | }); 29 | return deferred.promise; 30 | }; 31 | 32 | var _logOut = function () { 33 | var deferred = $q.defer(); 34 | var ref = window.open(authConfig.logOutApi + '?post_logout_redirect_uri=' + authConfig.post_logout_redirect_uri, '_blank', 'location=no'); 35 | ref.addEventListener('loadstart', function (event) { 36 | if (utilitiesService.startsWith(event.url, authConfig.post_logout_redirect_uri)) { 37 | localStorageService.remove('authorizationData'); 38 | _authentication.isAuth = false; 39 | _authentication.userName = ""; 40 | deferred.resolve(ref.close()); 41 | } 42 | }); 43 | return deferred.promise; 44 | }; 45 | 46 | var _fillAuthData = function () { 47 | var authData = localStorageService.get('authorizationData'); 48 | if (authData) { 49 | _authentication.isAuth = true; 50 | _authentication.userName = authData.userName; 51 | } 52 | }; 53 | 54 | var _confirmMessage = function () { 55 | return $http.get(authConfig.messageApi).then(function successCallback(response) { 56 | return response.data; 57 | }); 58 | }; 59 | 60 | authServiceFactory.logIn = _logIn; 61 | authServiceFactory.logOut = _logOut; 62 | authServiceFactory.fillAuthData = _fillAuthData; 63 | authServiceFactory.confirmMessage = _confirmMessage; 64 | authServiceFactory.authentication = _authentication; 65 | 66 | return authServiceFactory; 67 | }]); -------------------------------------------------------------------------------- /samples/Cordova/MobileApp/www/scripts/services/utilitiesService.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | app.factory('utilitiesService', [function () { 3 | 4 | var utilitiesServiceFactory = {}; 5 | 6 | var _startsWith = function (str, searchvalue) { 7 | return str.indexOf(searchvalue) == 0; 8 | }; 9 | 10 | var _getURLParameter = function (url, name) { 11 | return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(url) || [, ""])[1].replace(/\+/g, '%20')) || null 12 | }; 13 | 14 | utilitiesServiceFactory.startsWith = _startsWith; 15 | utilitiesServiceFactory.getURLParameter = _getURLParameter; 16 | 17 | return utilitiesServiceFactory; 18 | }]); -------------------------------------------------------------------------------- /samples/Mvc/Mvc.Client/Controllers/AuthenticationController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Authentication.OpenIdConnect; 2 | using Microsoft.AspNetCore.Http.Authentication; 3 | using Microsoft.AspNetCore.Mvc; 4 | 5 | namespace Mvc.Client.Controllers 6 | { 7 | public class AuthenticationController : Controller 8 | { 9 | [HttpGet("~/signin")] 10 | public ActionResult SignIn() 11 | { 12 | // Instruct the OIDC client middleware to redirect the user agent to the identity provider. 13 | // Note: the authenticationType parameter must match the value configured in Startup.cs 14 | return Challenge(new AuthenticationProperties { RedirectUri = "/" }, OpenIdConnectDefaults.AuthenticationScheme); 15 | } 16 | 17 | [HttpGet("~/signout"), HttpPost("~/signout")] 18 | public ActionResult SignOut() 19 | { 20 | // Instruct the cookies middleware to delete the local cookie created when the user agent 21 | // is redirected from the identity provider after a successful authorization flow and 22 | // to redirect the user agent to the identity provider to sign out. 23 | return SignOut("ClientCookie", OpenIdConnectDefaults.AuthenticationScheme); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /samples/Mvc/Mvc.Client/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net.Http; 3 | using System.Net.Http.Headers; 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore.Authentication; 7 | using Microsoft.AspNetCore.Authorization; 8 | using Microsoft.AspNetCore.Mvc; 9 | 10 | namespace Mvc.Client.Controllers 11 | { 12 | public class HomeController : Controller 13 | { 14 | [HttpGet("~/")] 15 | public ActionResult Index() 16 | { 17 | return View("Home"); 18 | } 19 | 20 | [Authorize, HttpPost("~/")] 21 | public async Task Index(CancellationToken cancellationToken) 22 | { 23 | using (var client = new HttpClient()) 24 | { 25 | var token = await HttpContext.Authentication.GetTokenAsync("access_token"); 26 | if (string.IsNullOrEmpty(token)) 27 | { 28 | throw new InvalidOperationException("The access token cannot be found in the authentication ticket. " + 29 | "Make sure that SaveTokens is set to true in the OIDC options."); 30 | } 31 | 32 | var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost:54540/api/message"); 33 | request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token); 34 | 35 | var response = await client.SendAsync(request, cancellationToken); 36 | response.EnsureSuccessStatusCode(); 37 | 38 | return View("Home", model: await response.Content.ReadAsStringAsync()); 39 | } 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /samples/Mvc/Mvc.Client/Mvc.Client.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | net451;netcoreapp1.0 7 | true 8 | Exe 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /samples/Mvc/Mvc.Client/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Hosting; 2 | using Microsoft.Extensions.Configuration; 3 | using Microsoft.Extensions.Logging; 4 | 5 | namespace Mvc.Client 6 | { 7 | public static class Program 8 | { 9 | public static void Main(string[] args) 10 | { 11 | var configuration = new ConfigurationBuilder() 12 | .AddEnvironmentVariables() 13 | .AddCommandLine(args) 14 | .Build(); 15 | 16 | var host = new WebHostBuilder() 17 | .ConfigureLogging(options => options.AddConsole()) 18 | .ConfigureLogging(options => options.AddDebug()) 19 | .UseConfiguration(configuration) 20 | .UseIISIntegration() 21 | .UseKestrel() 22 | .UseStartup() 23 | .Build(); 24 | 25 | host.Run(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /samples/Mvc/Mvc.Client/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:53507/", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "launchUrl": "http://localhost:53507/", 15 | "environmentVariables": { 16 | "ASPNETCORE_ENVIRONMENT": "Development" 17 | } 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /samples/Mvc/Mvc.Client/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.AspNetCore.Authentication.Cookies; 3 | using Microsoft.AspNetCore.Builder; 4 | using Microsoft.AspNetCore.Http; 5 | using Microsoft.Extensions.DependencyInjection; 6 | using Microsoft.IdentityModel.Protocols.OpenIdConnect; 7 | 8 | namespace Mvc.Client 9 | { 10 | public class Startup 11 | { 12 | public void ConfigureServices(IServiceCollection services) 13 | { 14 | services.AddAuthentication(options => 15 | { 16 | options.SignInScheme = "ClientCookie"; 17 | }); 18 | 19 | services.AddMvc(); 20 | } 21 | 22 | public void Configure(IApplicationBuilder app) 23 | { 24 | app.UseDeveloperExceptionPage(); 25 | 26 | // Insert a new cookies middleware in the pipeline to store the user 27 | // identity after he has been redirected from the identity provider. 28 | app.UseCookieAuthentication(new CookieAuthenticationOptions 29 | { 30 | AutomaticAuthenticate = true, 31 | AutomaticChallenge = true, 32 | AuthenticationScheme = "ClientCookie", 33 | CookieName = CookieAuthenticationDefaults.CookiePrefix + "ClientCookie", 34 | ExpireTimeSpan = TimeSpan.FromMinutes(5), 35 | LoginPath = new PathString("/signin"), 36 | LogoutPath = new PathString("/signout") 37 | }); 38 | 39 | app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions 40 | { 41 | RequireHttpsMetadata = false, 42 | SaveTokens = true, 43 | 44 | // Note: these settings must match the application details 45 | // inserted in the database at the server level. 46 | ClientId = "myClient", 47 | ClientSecret = "secret_secret_secret", 48 | PostLogoutRedirectUri = "http://localhost:53507/", 49 | 50 | // Use the authorization code flow. 51 | ResponseType = OpenIdConnectResponseType.Code, 52 | 53 | // Note: setting the Authority allows the OIDC client middleware to automatically 54 | // retrieve the identity provider's configuration and spare you from setting 55 | // the different endpoints URIs or the token validation parameters explicitly. 56 | Authority = "http://localhost:54540/" 57 | }); 58 | 59 | app.UseStaticFiles(); 60 | 61 | app.UseMvc(); 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /samples/Mvc/Mvc.Client/Views/Shared/Home.cshtml: -------------------------------------------------------------------------------- 1 | @model string 2 | 3 |
4 | @if (User?.Identity?.IsAuthenticated ?? false) { 5 |

Welcome, @User.Identity.Name

6 | 7 |

8 | @foreach (var claim in Context.User.Claims) { 9 |

@claim.Type: @claim.Value
10 | } 11 |

12 | 13 | if (!string.IsNullOrEmpty(Model)) { 14 |

Message received from the resource controller: @Model

15 | } 16 | 17 |
18 | 19 |
20 | 21 | Sign out 22 | } 23 | 24 | else { 25 |

Welcome, anonymous

26 | Sign in 27 | } 28 |
-------------------------------------------------------------------------------- /samples/Mvc/Mvc.Client/Views/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Mvc.Client (OSOS sample) 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 |

Your application (Mvc.Client)

20 |
21 | 22 | @RenderBody() 23 | 24 | 27 | 28 |
29 | 30 | -------------------------------------------------------------------------------- /samples/Mvc/Mvc.Client/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } -------------------------------------------------------------------------------- /samples/Mvc/Mvc.Client/web.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /samples/Mvc/Mvc.Client/wwwroot/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Mvc/Mvc.Client/wwwroot/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /samples/Mvc/Mvc.Client/wwwroot/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Mvc/Mvc.Client/wwwroot/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /samples/Mvc/Mvc.Client/wwwroot/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Mvc/Mvc.Client/wwwroot/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /samples/Mvc/Mvc.Client/wwwroot/stylesheets/jumbotron-narrow.css: -------------------------------------------------------------------------------- 1 | /* Space out content a bit */ 2 | body { 3 | padding-top: 20px; 4 | padding-bottom: 20px; 5 | } 6 | 7 | /* Everything but the jumbotron gets side spacing for mobile first views */ 8 | .header, 9 | .marketing, 10 | .footer { 11 | padding-right: 15px; 12 | padding-left: 15px; 13 | } 14 | 15 | /* Custom page header */ 16 | .header { 17 | border-bottom: 1px solid #e5e5e5; 18 | } 19 | /* Make the masthead heading the same height as the navigation */ 20 | .header h3 { 21 | padding-bottom: 19px; 22 | margin-top: 0; 23 | margin-bottom: 0; 24 | line-height: 40px; 25 | } 26 | 27 | /* Custom page footer */ 28 | .footer { 29 | padding-top: 19px; 30 | color: #777; 31 | border-top: 1px solid #e5e5e5; 32 | } 33 | 34 | /* Customize container */ 35 | @media (min-width: 768px) { 36 | .container { 37 | max-width: 730px; 38 | } 39 | } 40 | .container-narrow > hr { 41 | margin: 30px 0; 42 | } 43 | 44 | /* Main marketing message and sign up button */ 45 | .jumbotron { 46 | text-align: center; 47 | border-bottom: 1px solid #e5e5e5; 48 | } 49 | .jumbotron .btn { 50 | padding: 14px 24px; 51 | font-size: 21px; 52 | } 53 | 54 | /* Supporting marketing content */ 55 | .marketing { 56 | margin: 40px 0; 57 | } 58 | .marketing p + h4 { 59 | margin-top: 28px; 60 | } 61 | 62 | /* Responsive: Portrait tablets and up */ 63 | @media screen and (min-width: 768px) { 64 | /* Remove the padding we set earlier */ 65 | .header, 66 | .marketing, 67 | .footer { 68 | padding-right: 0; 69 | padding-left: 0; 70 | } 71 | /* Space out the masthead */ 72 | .header { 73 | margin-bottom: 30px; 74 | } 75 | /* Remove the bottom border on the jumbotron for visual effect */ 76 | .jumbotron { 77 | border-bottom: 0; 78 | } 79 | } -------------------------------------------------------------------------------- /samples/Mvc/Mvc.Server/Certificate.pfx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Mvc/Mvc.Server/Certificate.pfx -------------------------------------------------------------------------------- /samples/Mvc/Mvc.Server/Controllers/AuthenticationController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Http.Authentication; 2 | using Microsoft.AspNetCore.Mvc; 3 | using Mvc.Server.Extensions; 4 | 5 | namespace Mvc.Server.Controllers 6 | { 7 | public class AuthenticationController : Controller 8 | { 9 | [HttpGet("~/signin")] 10 | public ActionResult SignIn(string returnUrl = null) 11 | { 12 | // Note: the "returnUrl" parameter corresponds to the endpoint the user agent 13 | // will be redirected to after a successful authentication and not 14 | // the redirect_uri of the requesting client application. 15 | ViewBag.ReturnUrl = returnUrl; 16 | 17 | // Note: in a real world application, you'd probably prefer creating a specific view model. 18 | return View("SignIn", HttpContext.GetExternalProviders()); 19 | } 20 | 21 | [HttpPost("~/signin")] 22 | public ActionResult SignIn(string provider, string returnUrl) 23 | { 24 | // Note: the "provider" parameter corresponds to the external 25 | // authentication provider choosen by the user agent. 26 | if (string.IsNullOrEmpty(provider)) 27 | { 28 | return BadRequest(); 29 | } 30 | 31 | if (!HttpContext.IsProviderSupported(provider)) 32 | { 33 | return BadRequest(); 34 | } 35 | 36 | // Note: the "returnUrl" parameter corresponds to the endpoint the user agent 37 | // will be redirected to after a successful authentication and not 38 | // the redirect_uri of the requesting client application. 39 | if (string.IsNullOrEmpty(returnUrl)) 40 | { 41 | return BadRequest(); 42 | } 43 | 44 | // Instruct the middleware corresponding to the requested external identity 45 | // provider to redirect the user agent to its own authorization endpoint. 46 | // Note: the authenticationScheme parameter must match the value configured in Startup.cs 47 | return Challenge(new AuthenticationProperties { RedirectUri = returnUrl }, provider); 48 | } 49 | 50 | [HttpGet("~/signout"), HttpPost("~/signout")] 51 | public ActionResult SignOut() 52 | { 53 | // Instruct the cookies middleware to delete the local cookie created 54 | // when the user agent is redirected from the external identity provider 55 | // after a successful authentication flow (e.g Google or Facebook). 56 | return SignOut("ServerCookie"); 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /samples/Mvc/Mvc.Server/Controllers/ResourceController.cs: -------------------------------------------------------------------------------- 1 | using System.Security.Claims; 2 | using Microsoft.AspNetCore.Authorization; 3 | using Microsoft.AspNetCore.Mvc; 4 | 5 | namespace Mvc.Server.Controllers 6 | { 7 | [Route("api")] 8 | public class ResourceController : Controller 9 | { 10 | [Authorize, HttpGet, Route("message")] 11 | public IActionResult GetMessage() 12 | { 13 | var identity = User.Identity as ClaimsIdentity; 14 | if (identity == null) 15 | { 16 | return BadRequest(); 17 | } 18 | 19 | return Content($"{identity.Name} has been successfully authenticated."); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /samples/Mvc/Mvc.Server/Extensions/AppBuilderExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.AspNetCore.Builder; 3 | using Microsoft.AspNetCore.Hosting; 4 | using Microsoft.AspNetCore.Http; 5 | 6 | namespace Mvc.Server.Extensions 7 | { 8 | public static class AppBuilderExtensions 9 | { 10 | public static IApplicationBuilder UseWhen(this IApplicationBuilder app, 11 | Func condition, Action configuration) 12 | { 13 | if (app == null) 14 | { 15 | throw new ArgumentNullException(nameof(app)); 16 | } 17 | 18 | if (condition == null) 19 | { 20 | throw new ArgumentNullException(nameof(condition)); 21 | } 22 | 23 | if (configuration == null) 24 | { 25 | throw new ArgumentNullException(nameof(configuration)); 26 | } 27 | 28 | var builder = app.New(); 29 | configuration(builder); 30 | 31 | return app.Use(next => 32 | { 33 | builder.Run(next); 34 | 35 | var branch = builder.Build(); 36 | 37 | return context => 38 | { 39 | if (condition(context)) 40 | { 41 | return branch(context); 42 | } 43 | 44 | return next(context); 45 | }; 46 | }); 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /samples/Mvc/Mvc.Server/Extensions/HttpContextExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using Microsoft.AspNetCore.Http; 5 | using Microsoft.AspNetCore.Http.Authentication; 6 | 7 | namespace Mvc.Server.Extensions 8 | { 9 | public static class HttpContextExtensions 10 | { 11 | public static IEnumerable GetExternalProviders(this HttpContext context) 12 | { 13 | if (context == null) 14 | { 15 | throw new ArgumentNullException(nameof(context)); 16 | } 17 | 18 | return from description in context.Authentication.GetAuthenticationSchemes() 19 | where !string.IsNullOrEmpty(description.DisplayName) 20 | select description; 21 | } 22 | 23 | public static bool IsProviderSupported(this HttpContext context, string provider) 24 | { 25 | if (context == null) 26 | { 27 | throw new ArgumentNullException(nameof(context)); 28 | } 29 | 30 | return (from description in context.GetExternalProviders() 31 | where string.Equals(description.AuthenticationScheme, provider, StringComparison.OrdinalIgnoreCase) 32 | select description).Any(); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /samples/Mvc/Mvc.Server/Helpers/FormValueRequiredAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.AspNetCore.Mvc.Abstractions; 3 | using Microsoft.AspNetCore.Mvc.ActionConstraints; 4 | using Microsoft.AspNetCore.Routing; 5 | 6 | namespace Mvc.Server.Helpers 7 | { 8 | public sealed class FormValueRequiredAttribute : ActionMethodSelectorAttribute 9 | { 10 | private readonly string _name; 11 | 12 | public FormValueRequiredAttribute(string name) 13 | { 14 | _name = name; 15 | } 16 | 17 | public override bool IsValidForRequest(RouteContext context, ActionDescriptor action) 18 | { 19 | if (string.Equals(context.HttpContext.Request.Method, "GET", StringComparison.OrdinalIgnoreCase) || 20 | string.Equals(context.HttpContext.Request.Method, "HEAD", StringComparison.OrdinalIgnoreCase) || 21 | string.Equals(context.HttpContext.Request.Method, "DELETE", StringComparison.OrdinalIgnoreCase) || 22 | string.Equals(context.HttpContext.Request.Method, "TRACE", StringComparison.OrdinalIgnoreCase)) 23 | { 24 | return false; 25 | } 26 | 27 | if (string.IsNullOrEmpty(context.HttpContext.Request.ContentType)) 28 | { 29 | return false; 30 | } 31 | 32 | if (!context.HttpContext.Request.ContentType.StartsWith("application/x-www-form-urlencoded", StringComparison.OrdinalIgnoreCase)) 33 | { 34 | return false; 35 | } 36 | 37 | return !string.IsNullOrEmpty(context.HttpContext.Request.Form[_name]); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /samples/Mvc/Mvc.Server/Models/Application.cs: -------------------------------------------------------------------------------- 1 | namespace Mvc.Server.Models 2 | { 3 | public class Application 4 | { 5 | public string ApplicationID { get; set; } 6 | public string DisplayName { get; set; } 7 | public string RedirectUri { get; set; } 8 | public string LogoutRedirectUri { get; set; } 9 | public string Secret { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /samples/Mvc/Mvc.Server/Models/ApplicationContext.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | 3 | namespace Mvc.Server.Models 4 | { 5 | public class ApplicationContext : DbContext 6 | { 7 | public ApplicationContext(DbContextOptions options) 8 | : base(options) { } 9 | 10 | public DbSet Applications { get; set; } 11 | } 12 | } -------------------------------------------------------------------------------- /samples/Mvc/Mvc.Server/Mvc.Server.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | net451;netcoreapp1.0 7 | true 8 | Exe 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /samples/Mvc/Mvc.Server/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Hosting; 2 | using Microsoft.Extensions.Configuration; 3 | using Microsoft.Extensions.Logging; 4 | 5 | namespace Mvc.Server 6 | { 7 | public static class Program 8 | { 9 | public static void Main(string[] args) 10 | { 11 | var configuration = new ConfigurationBuilder() 12 | .AddEnvironmentVariables() 13 | .AddCommandLine(args) 14 | .Build(); 15 | 16 | var host = new WebHostBuilder() 17 | .ConfigureLogging(options => options.AddConsole()) 18 | .ConfigureLogging(options => options.AddDebug()) 19 | .UseConfiguration(configuration) 20 | .UseIISIntegration() 21 | .UseKestrel() 22 | .UseStartup() 23 | .Build(); 24 | 25 | host.Run(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /samples/Mvc/Mvc.Server/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:54540/", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "launchUrl": "http://localhost:54540/", 15 | "environmentVariables": { 16 | "ASPNETCORE_ENVIRONMENT": "Development" 17 | } 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /samples/Mvc/Mvc.Server/Views/Shared/Authorize.cshtml: -------------------------------------------------------------------------------- 1 | @using AspNet.Security.OpenIdConnect.Primitives 2 | @using Mvc.Server.Models 3 | 4 | @model Tuple 5 | 6 |
7 |

Authorization

8 | 9 |

Do you wanna grant @Model.Item2.DisplayName an access to your resources? (scopes requested: @Model.Item1.Scope)

10 | 11 |
12 | @Html.AntiForgeryToken() 13 | 14 | @foreach (var parameter in Model.Item1.GetParameters()) { 15 | 16 | } 17 | 18 | 19 | 20 |
21 |
22 | -------------------------------------------------------------------------------- /samples/Mvc/Mvc.Server/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @using AspNet.Security.OpenIdConnect.Primitives 2 | @model OpenIdConnectResponse 3 | 4 |
5 |

An OpenID Connect error has occurred

6 |

7 | @Model.Error 8 | @if (!string.IsNullOrEmpty(Model.ErrorDescription)) { 9 | @Model.ErrorDescription 10 | } 11 |

12 |
-------------------------------------------------------------------------------- /samples/Mvc/Mvc.Server/Views/Shared/Logout.cshtml: -------------------------------------------------------------------------------- 1 | @using AspNet.Security.OpenIdConnect.Primitives 2 | @using Mvc.Server.Models 3 | @using System.Security.Claims 4 | 5 | @model Tuple 6 | 7 |
8 |

Log out

9 |

Are you sure you want to sign out?

10 | 11 | @if (Model.Item2 != null && Model.Item2.Identity != null) { 12 |

Connected user: @Model.Item2.Identity.Name

13 | } 14 | 15 |
16 | @Html.AntiForgeryToken() 17 | 18 | @* Flow the logout request *@ 19 | @foreach (var parameter in Model.Item1.GetParameters()) { 20 | 21 | } 22 | 23 | 24 |
25 |
-------------------------------------------------------------------------------- /samples/Mvc/Mvc.Server/Views/Shared/SignIn.cshtml: -------------------------------------------------------------------------------- 1 | @using Microsoft.AspNetCore.Http.Authentication 2 | @model IEnumerable 3 | 4 |
5 |

Authentication

6 |

Sign in using one of these external providers:

7 | 8 | @foreach (var description in Model) { 9 |
10 | 11 | 12 | 13 | 14 |
15 | } 16 |
-------------------------------------------------------------------------------- /samples/Mvc/Mvc.Server/Views/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Mvc.Server (OSOS sample) 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 |

Your application (Mvc.Server)

20 |
21 | 22 | @RenderBody() 23 | 24 | 27 | 28 |
29 | 30 | -------------------------------------------------------------------------------- /samples/Mvc/Mvc.Server/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } -------------------------------------------------------------------------------- /samples/Mvc/Mvc.Server/web.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /samples/Mvc/Mvc.Server/wwwroot/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Mvc/Mvc.Server/wwwroot/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /samples/Mvc/Mvc.Server/wwwroot/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Mvc/Mvc.Server/wwwroot/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /samples/Mvc/Mvc.Server/wwwroot/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Mvc/Mvc.Server/wwwroot/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /samples/Mvc/Mvc.Server/wwwroot/stylesheets/jumbotron-narrow.css: -------------------------------------------------------------------------------- 1 | /* Space out content a bit */ 2 | body { 3 | padding-top: 20px; 4 | padding-bottom: 20px; 5 | } 6 | 7 | /* Everything but the jumbotron gets side spacing for mobile first views */ 8 | .header, 9 | .marketing, 10 | .footer { 11 | padding-right: 15px; 12 | padding-left: 15px; 13 | } 14 | 15 | /* Custom page header */ 16 | .header { 17 | border-bottom: 1px solid #e5e5e5; 18 | } 19 | /* Make the masthead heading the same height as the navigation */ 20 | .header h3 { 21 | padding-bottom: 19px; 22 | margin-top: 0; 23 | margin-bottom: 0; 24 | line-height: 40px; 25 | } 26 | 27 | /* Custom page footer */ 28 | .footer { 29 | padding-top: 19px; 30 | color: #777; 31 | border-top: 1px solid #e5e5e5; 32 | } 33 | 34 | /* Customize container */ 35 | @media (min-width: 768px) { 36 | .container { 37 | max-width: 730px; 38 | } 39 | } 40 | .container-narrow > hr { 41 | margin: 30px 0; 42 | } 43 | 44 | /* Main marketing message and sign up button */ 45 | .jumbotron { 46 | text-align: center; 47 | border-bottom: 1px solid #e5e5e5; 48 | } 49 | .jumbotron .btn { 50 | padding: 14px 24px; 51 | font-size: 21px; 52 | } 53 | 54 | /* Supporting marketing content */ 55 | .marketing { 56 | margin: 40px 0; 57 | } 58 | .marketing p + h4 { 59 | margin-top: 28px; 60 | } 61 | 62 | /* Responsive: Portrait tablets and up */ 63 | @media screen and (min-width: 768px) { 64 | /* Remove the padding we set earlier */ 65 | .header, 66 | .marketing, 67 | .footer { 68 | padding-right: 0; 69 | padding-left: 0; 70 | } 71 | /* Space out the masthead */ 72 | .header { 73 | margin-bottom: 30px; 74 | } 75 | /* Remove the bottom border on the jumbotron for visual effect */ 76 | .jumbotron { 77 | border-bottom: 0; 78 | } 79 | } -------------------------------------------------------------------------------- /samples/Postman/Controllers/AuthorizationController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Security.Claims; 4 | using AspNet.Security.OpenIdConnect.Extensions; 5 | using AspNet.Security.OpenIdConnect.Primitives; 6 | using AspNet.Security.OpenIdConnect.Server; 7 | using Microsoft.AspNetCore.Authentication; 8 | using Microsoft.AspNetCore.Builder; 9 | using Microsoft.AspNetCore.Http.Authentication; 10 | using Microsoft.AspNetCore.Mvc; 11 | using Postman.Helpers; 12 | 13 | namespace Postman.Controllers 14 | { 15 | public class AuthorizationController : Controller 16 | { 17 | [HttpGet("~/connect/authorize")] 18 | public IActionResult Authorize() 19 | { 20 | // Extract the authorization request from the ASP.NET environment. 21 | var request = HttpContext.GetOpenIdConnectRequest(); 22 | 23 | // Note: in a real world application, you'd probably prefer creating a specific view model. 24 | return View("Authorize", request); 25 | } 26 | 27 | [FormValueRequired("submit.Accept")] 28 | [HttpPost("~/connect/authorize")] 29 | [ValidateAntiForgeryToken] 30 | public IActionResult Accept() 31 | { 32 | var request = HttpContext.GetOpenIdConnectRequest(); 33 | 34 | // Create a new ClaimsIdentity containing the claims that 35 | // will be used to create an id_token, a token or a code. 36 | var identity = new ClaimsIdentity( 37 | OpenIdConnectServerDefaults.AuthenticationScheme, 38 | OpenIdConnectConstants.Claims.Name, 39 | OpenIdConnectConstants.Claims.Role); 40 | 41 | identity.AddClaim(OpenIdConnectConstants.Claims.Subject, Guid.NewGuid().ToString(), 42 | OpenIdConnectConstants.Destinations.AccessToken, 43 | OpenIdConnectConstants.Destinations.IdentityToken); 44 | 45 | identity.AddClaim(OpenIdConnectConstants.Claims.Name, "Bob le Bricoleur", 46 | OpenIdConnectConstants.Destinations.AccessToken, 47 | OpenIdConnectConstants.Destinations.IdentityToken); 48 | 49 | // Create a new authentication ticket holding the user identity. 50 | var ticket = new AuthenticationTicket( 51 | new ClaimsPrincipal(identity), 52 | new AuthenticationProperties(), 53 | OpenIdConnectServerDefaults.AuthenticationScheme); 54 | 55 | // Set the list of scopes granted to the client application. 56 | // Note: this sample always grants the "openid", "email" and "profile" scopes 57 | // when they are requested by the client application: a real world application 58 | // would probably display a form allowing to select the scopes to grant. 59 | ticket.SetScopes(new[] { 60 | /* openid: */ OpenIdConnectConstants.Scopes.OpenId, 61 | /* email: */ OpenIdConnectConstants.Scopes.Email, 62 | /* profile: */ OpenIdConnectConstants.Scopes.Profile, 63 | /* offline_access: */ OpenIdConnectConstants.Scopes.OfflineAccess 64 | }.Intersect(request.GetScopes())); 65 | 66 | // Returning a SignInResult will ask ASOS to serialize the specified identity to build appropriate tokens. 67 | // Note: you should always make sure the identities you return contain ClaimTypes.NameIdentifier claim. 68 | return SignIn(ticket.Principal, ticket.Properties, ticket.AuthenticationScheme); 69 | } 70 | 71 | [FormValueRequired("submit.Deny")] 72 | [HttpPost("~/connect/authorize")] 73 | [ValidateAntiForgeryToken] 74 | public IActionResult Deny() 75 | { 76 | // Notify ASOS that the authorization grant has been denied by the resource owner. 77 | // Note: OpenIdConnectServerHandler will automatically take care of redirecting 78 | // the user agent to the client application using the appropriate response_mode. 79 | return Forbid(OpenIdConnectServerDefaults.AuthenticationScheme); 80 | } 81 | } 82 | } -------------------------------------------------------------------------------- /samples/Postman/Controllers/ResourceController.cs: -------------------------------------------------------------------------------- 1 | using System.Security.Claims; 2 | using Microsoft.AspNetCore.Authorization; 3 | using Microsoft.AspNetCore.Mvc; 4 | 5 | namespace Postman.Controllers 6 | { 7 | [Route("api")] 8 | public class ResourceController : Controller 9 | { 10 | [Authorize, HttpGet, Route("message")] 11 | public IActionResult GetMessage() 12 | { 13 | var identity = User.Identity as ClaimsIdentity; 14 | if (identity == null) 15 | { 16 | return BadRequest(); 17 | } 18 | 19 | return Content($"{identity.Name} has been successfully authenticated."); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /samples/Postman/Helpers/FormValueRequiredAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.AspNetCore.Mvc.Abstractions; 3 | using Microsoft.AspNetCore.Mvc.ActionConstraints; 4 | using Microsoft.AspNetCore.Routing; 5 | 6 | namespace Postman.Helpers 7 | { 8 | public sealed class FormValueRequiredAttribute : ActionMethodSelectorAttribute 9 | { 10 | private readonly string _name; 11 | 12 | public FormValueRequiredAttribute(string name) 13 | { 14 | _name = name; 15 | } 16 | 17 | public override bool IsValidForRequest(RouteContext context, ActionDescriptor action) 18 | { 19 | if (string.Equals(context.HttpContext.Request.Method, "GET", StringComparison.OrdinalIgnoreCase) || 20 | string.Equals(context.HttpContext.Request.Method, "HEAD", StringComparison.OrdinalIgnoreCase) || 21 | string.Equals(context.HttpContext.Request.Method, "DELETE", StringComparison.OrdinalIgnoreCase) || 22 | string.Equals(context.HttpContext.Request.Method, "TRACE", StringComparison.OrdinalIgnoreCase)) 23 | { 24 | return false; 25 | } 26 | 27 | if (string.IsNullOrEmpty(context.HttpContext.Request.ContentType)) 28 | { 29 | return false; 30 | } 31 | 32 | if (!context.HttpContext.Request.ContentType.StartsWith("application/x-www-form-urlencoded", StringComparison.OrdinalIgnoreCase)) 33 | { 34 | return false; 35 | } 36 | 37 | return !string.IsNullOrEmpty(context.HttpContext.Request.Form[_name]); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /samples/Postman/Postman.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | net451;netcoreapp1.0 7 | true 8 | Exe 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /samples/Postman/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Hosting; 2 | using Microsoft.Extensions.Configuration; 3 | using Microsoft.Extensions.Logging; 4 | 5 | namespace Postman 6 | { 7 | public static class Program 8 | { 9 | public static void Main(string[] args) 10 | { 11 | var configuration = new ConfigurationBuilder() 12 | .AddEnvironmentVariables() 13 | .AddCommandLine(args) 14 | .Build(); 15 | 16 | var host = new WebHostBuilder() 17 | .ConfigureLogging(options => options.AddConsole()) 18 | .ConfigureLogging(options => options.AddDebug()) 19 | .UseConfiguration(configuration) 20 | .UseIISIntegration() 21 | .UseKestrel() 22 | .UseStartup() 23 | .Build(); 24 | 25 | host.Run(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /samples/Postman/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:6500/", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "launchUrl": "http://localhost:6500/", 15 | "environmentVariables": { 16 | "ASPNETCORE_ENVIRONMENT": "Development" 17 | } 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /samples/Postman/Startup.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Builder; 2 | using Microsoft.Extensions.DependencyInjection; 3 | using Postman.Providers; 4 | 5 | namespace Postman 6 | { 7 | public class Startup 8 | { 9 | public void ConfigureServices(IServiceCollection services) 10 | { 11 | services.AddMvc(); 12 | } 13 | 14 | public void Configure(IApplicationBuilder app) 15 | { 16 | // To test this sample with Postman, use the following settings: 17 | // 18 | // * Authorization URL: http://localhost:6500/connect/authorize 19 | // * Access token URL: http://localhost:6500/connect/token 20 | // * Client ID: postman 21 | // * Client secret: [blank] (not used with public clients) 22 | // * Scope: openid email profile roles 23 | // * Grant type: authorization code 24 | // * Request access token locally: yes 25 | 26 | app.UseDeveloperExceptionPage(); 27 | 28 | app.UseStaticFiles(); 29 | 30 | app.UseOAuthValidation(); 31 | 32 | app.UseOpenIdConnectServer(options => 33 | { 34 | options.Provider = new AuthorizationProvider(); 35 | 36 | // Enable the authorization and token endpoints. 37 | options.AuthorizationEndpointPath = "/connect/authorize"; 38 | options.TokenEndpointPath = "/connect/token"; 39 | options.AllowInsecureHttp = true; 40 | 41 | // Note: to override the default access token format and use JWT, assign AccessTokenHandler: 42 | // 43 | // options.AccessTokenHandler = new JwtSecurityTokenHandler 44 | // { 45 | // InboundClaimTypeMap = new Dictionary(), 46 | // OutboundClaimTypeMap = new Dictionary() 47 | // }; 48 | // 49 | // Note: when using JWT as the access token format, you have to register a signing key. 50 | // 51 | // You can register a new ephemeral key, that is discarded when the application shuts down. 52 | // Tokens signed using this key are automatically invalidated and thus this method 53 | // should only be used during development: 54 | // 55 | // options.SigningCredentials.AddEphemeralKey(); 56 | // 57 | // On production, using a X.509 certificate stored in the machine store is recommended. 58 | // You can generate a self-signed certificate using Pluralsight's self-cert utility: 59 | // https://s3.amazonaws.com/pluralsight-free/keith-brown/samples/SelfCert.zip 60 | // 61 | // options.SigningCredentials.AddCertificate("7D2A741FE34CC2C7369237A5F2078988E17A6A75"); 62 | }); 63 | 64 | app.UseMvc(); 65 | 66 | app.UseWelcomePage(); 67 | } 68 | } 69 | } -------------------------------------------------------------------------------- /samples/Postman/Views/Shared/Authorize.cshtml: -------------------------------------------------------------------------------- 1 | @using AspNet.Security.OpenIdConnect.Primitives 2 | 3 | @model OpenIdConnectRequest 4 | 5 |
6 |

Authorization

7 | 8 |

Do you wanna grant @Model.ClientId an access to your resources? (scopes requested: @Model.Scope)

9 | 10 |
11 | @Html.AntiForgeryToken() 12 | 13 | @foreach (var parameter in Model.GetParameters()) { 14 | 15 | } 16 | 17 | 18 | 19 |
20 |
21 | -------------------------------------------------------------------------------- /samples/Postman/Views/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Postman (OSOS sample) 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 |

Your application (Postman)

20 |
21 | 22 | @RenderBody() 23 | 24 | 27 | 28 |
29 | 30 | -------------------------------------------------------------------------------- /samples/Postman/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } -------------------------------------------------------------------------------- /samples/Postman/web.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /samples/Postman/wwwroot/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Postman/wwwroot/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /samples/Postman/wwwroot/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Postman/wwwroot/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /samples/Postman/wwwroot/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Samples/62184bcf9ad0a785cd43cbec1faf059628c1ccbe/samples/Postman/wwwroot/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /samples/Postman/wwwroot/stylesheets/jumbotron-narrow.css: -------------------------------------------------------------------------------- 1 | /* Space out content a bit */ 2 | body { 3 | padding-top: 20px; 4 | padding-bottom: 20px; 5 | } 6 | 7 | /* Everything but the jumbotron gets side spacing for mobile first views */ 8 | .header, 9 | .marketing, 10 | .footer { 11 | padding-right: 15px; 12 | padding-left: 15px; 13 | } 14 | 15 | /* Custom page header */ 16 | .header { 17 | border-bottom: 1px solid #e5e5e5; 18 | } 19 | /* Make the masthead heading the same height as the navigation */ 20 | .header h3 { 21 | padding-bottom: 19px; 22 | margin-top: 0; 23 | margin-bottom: 0; 24 | line-height: 40px; 25 | } 26 | 27 | /* Custom page footer */ 28 | .footer { 29 | padding-top: 19px; 30 | color: #777; 31 | border-top: 1px solid #e5e5e5; 32 | } 33 | 34 | /* Customize container */ 35 | @media (min-width: 768px) { 36 | .container { 37 | max-width: 730px; 38 | } 39 | } 40 | .container-narrow > hr { 41 | margin: 30px 0; 42 | } 43 | 44 | /* Main marketing message and sign up button */ 45 | .jumbotron { 46 | text-align: center; 47 | border-bottom: 1px solid #e5e5e5; 48 | } 49 | .jumbotron .btn { 50 | padding: 14px 24px; 51 | font-size: 21px; 52 | } 53 | 54 | /* Supporting marketing content */ 55 | .marketing { 56 | margin: 40px 0; 57 | } 58 | .marketing p + h4 { 59 | margin-top: 28px; 60 | } 61 | 62 | /* Responsive: Portrait tablets and up */ 63 | @media screen and (min-width: 768px) { 64 | /* Remove the padding we set earlier */ 65 | .header, 66 | .marketing, 67 | .footer { 68 | padding-right: 0; 69 | padding-left: 0; 70 | } 71 | /* Space out the masthead */ 72 | .header { 73 | margin-bottom: 30px; 74 | } 75 | /* Remove the bottom border on the jumbotron for visual effect */ 76 | .jumbotron { 77 | border-bottom: 0; 78 | } 79 | } -------------------------------------------------------------------------------- /samples/SignalR/HelloSignalR/Connections/SimpleConnection.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using Microsoft.AspNetCore.Http; 3 | using Microsoft.AspNetCore.SignalR; 4 | using Microsoft.Extensions.Logging; 5 | 6 | namespace HelloSignalR.Connections 7 | { 8 | public class SimpleConnection : PersistentConnection 9 | { 10 | protected override async Task OnConnected(HttpRequest request, string connectionId) 11 | { 12 | var identity = request.HttpContext.User.Identity; 13 | var status = identity.IsAuthenticated ? "Authenticated" : "Unauthenticated"; 14 | 15 | Logger.LogInformation($"{status} connection {connectionId} has just connected."); 16 | 17 | await Connection.Send(connectionId, $"Connection is {status}"); 18 | 19 | if (identity.IsAuthenticated) 20 | { 21 | await Connection.Send(connectionId, $"Authenticated username: {identity.Name}"); 22 | } 23 | } 24 | 25 | protected override async Task OnReceived(HttpRequest request, string connectionId, string data) 26 | { 27 | var identity = request.HttpContext.User.Identity; 28 | var status = identity.IsAuthenticated ? "authenticated" : "unauthenticated"; 29 | var name = identity.IsAuthenticated ? identity.Name : "client"; 30 | 31 | await Connection.Send(connectionId, $"Received an {status} message from {name}: {data}"); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /samples/SignalR/HelloSignalR/HelloSignalR.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | net451;netcoreapp1.0 7 | true 8 | Exe 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /samples/SignalR/HelloSignalR/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Hosting; 2 | using Microsoft.Extensions.Configuration; 3 | using Microsoft.Extensions.Logging; 4 | 5 | namespace HelloSignalR 6 | { 7 | public static class Program 8 | { 9 | public static void Main(string[] args) 10 | { 11 | var configuration = new ConfigurationBuilder() 12 | .AddEnvironmentVariables() 13 | .AddCommandLine(args) 14 | .Build(); 15 | 16 | var host = new WebHostBuilder() 17 | .ConfigureLogging(options => options.AddConsole()) 18 | .ConfigureLogging(options => options.AddDebug()) 19 | .UseConfiguration(configuration) 20 | .UseIISIntegration() 21 | .UseKestrel() 22 | .UseStartup() 23 | .Build(); 24 | 25 | host.Run(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /samples/SignalR/HelloSignalR/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:5005/", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /samples/SignalR/HelloSignalR/Providers/AuthorizationProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Security.Claims; 3 | using System.Threading.Tasks; 4 | using AspNet.Security.OpenIdConnect.Extensions; 5 | using AspNet.Security.OpenIdConnect.Primitives; 6 | using AspNet.Security.OpenIdConnect.Server; 7 | 8 | namespace HelloSignalR.Providers 9 | { 10 | public class AuthorizationProvider : OpenIdConnectServerProvider 11 | { 12 | public override Task ValidateTokenRequest(ValidateTokenRequestContext context) 13 | { 14 | // Reject token requests that don't use grant_type=password or grant_type=refresh_token. 15 | if (!context.Request.IsPasswordGrantType() && !context.Request.IsRefreshTokenGrantType()) 16 | { 17 | context.Reject( 18 | error: OpenIdConnectConstants.Errors.UnsupportedGrantType, 19 | description: "Only grant_type=password and refresh_token " + 20 | "requests are accepted by this server."); 21 | 22 | return Task.FromResult(0); 23 | } 24 | 25 | if (string.Equals(context.ClientId, "AspNetContribSample", StringComparison.Ordinal)) 26 | { 27 | // Note: the context is marked as skipped instead of validated because the client 28 | // is not trusted (JavaScript applications cannot keep their credentials secret). 29 | context.Skip(); 30 | } 31 | 32 | else 33 | { 34 | // If the client_id doesn't correspond to the 35 | // intended identifier, reject the request. 36 | context.Reject(OpenIdConnectConstants.Errors.InvalidClient); 37 | } 38 | 39 | return Task.FromResult(0); 40 | } 41 | 42 | public override Task HandleTokenRequest(HandleTokenRequestContext context) 43 | { 44 | // Only handle grant_type=password token requests and let the 45 | // OpenID Connect server middleware handle the other grant types. 46 | if (context.Request.IsPasswordGrantType()) 47 | { 48 | var user = new { Id = "users-123", UserName = "AspNet", Password = "contrib" }; 49 | 50 | if (!string.Equals(context.Request.Username, user.UserName, StringComparison.Ordinal) || 51 | !string.Equals(context.Request.Password, user.Password, StringComparison.Ordinal)) 52 | { 53 | context.Reject( 54 | error: OpenIdConnectConstants.Errors.InvalidGrant, 55 | description: "The specified user credentials are invalid."); 56 | 57 | return Task.FromResult(0); 58 | } 59 | 60 | var identity = new ClaimsIdentity( 61 | context.Options.AuthenticationScheme, 62 | OpenIdConnectConstants.Claims.Name, 63 | OpenIdConnectConstants.Claims.Role); 64 | 65 | identity.AddClaim(OpenIdConnectConstants.Claims.Subject, user.Id, 66 | OpenIdConnectConstants.Destinations.AccessToken, 67 | OpenIdConnectConstants.Destinations.IdentityToken); 68 | 69 | identity.AddClaim(OpenIdConnectConstants.Claims.Name, user.UserName, 70 | OpenIdConnectConstants.Destinations.AccessToken, 71 | OpenIdConnectConstants.Destinations.IdentityToken); 72 | 73 | context.Validate(new ClaimsPrincipal(identity)); 74 | } 75 | 76 | return Task.FromResult(0); 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /samples/SignalR/HelloSignalR/Startup.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using AspNet.Security.OAuth.Validation; 3 | using HelloSignalR.Connections; 4 | using HelloSignalR.Providers; 5 | using Microsoft.AspNetCore.Builder; 6 | using Microsoft.Extensions.DependencyInjection; 7 | 8 | namespace HelloSignalR 9 | { 10 | public class Startup 11 | { 12 | public void ConfigureServices(IServiceCollection services) 13 | { 14 | services.AddAuthentication(); 15 | 16 | services.AddSignalR(); 17 | } 18 | 19 | public void Configure(IApplicationBuilder app) 20 | { 21 | app.UseDefaultFiles(); 22 | 23 | app.UseStaticFiles(); 24 | 25 | // Add a new middleware validating access tokens. 26 | app.UseOAuthValidation(options => 27 | { 28 | options.Events = new OAuthValidationEvents 29 | { 30 | // Note: for SignalR connections, the default Authorization header does not work, 31 | // because the WebSockets JS API doesn't allow setting custom parameters. 32 | // To work around this limitation, the access token is retrieved from the query string. 33 | OnRetrieveToken = context => 34 | { 35 | context.Token = context.Request.Query["access_token"]; 36 | 37 | return Task.FromResult(0); 38 | } 39 | }; 40 | }); 41 | 42 | app.UseSignalR("/signalr"); 43 | 44 | // Add a new middleware issuing access tokens. 45 | app.UseOpenIdConnectServer(options => 46 | { 47 | options.Provider = new AuthorizationProvider(); 48 | 49 | // Enable the token endpoint. 50 | options.TokenEndpointPath = "/connect/token"; 51 | options.AllowInsecureHttp = true; 52 | 53 | // Note: to override the default access token format and use JWT, assign AccessTokenHandler: 54 | // 55 | // options.AccessTokenHandler = new JwtSecurityTokenHandler 56 | // { 57 | // InboundClaimTypeMap = new Dictionary(), 58 | // OutboundClaimTypeMap = new Dictionary() 59 | // }; 60 | // 61 | // Note: when using JWT as the access token format, you have to register a signing key. 62 | // 63 | // You can register a new ephemeral key, that is discarded when the application shuts down. 64 | // Tokens signed using this key are automatically invalidated and thus this method 65 | // should only be used during development: 66 | // 67 | // options.SigningCredentials.AddEphemeralKey(); 68 | // 69 | // On production, using a X.509 certificate stored in the machine store is recommended. 70 | // You can generate a self-signed certificate using Pluralsight's self-cert utility: 71 | // https://s3.amazonaws.com/pluralsight-free/keith-brown/samples/SelfCert.zip 72 | // 73 | // options.SigningCredentials.AddCertificate("7D2A741FE34CC2C7369237A5F2078988E17A6A75"); 74 | }); 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /samples/SignalR/HelloSignalR/web.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /samples/SignalR/HelloSignalR/wwwroot/index.html: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | ASOS SignalR Sample 9 | 55 | 56 | 57 |

AspNet.Security.OpenIdConnect.Server SignalR Sample

58 |
To open console press Ctrl + Shift + I / Cmd + Shift + I / F12 and choose Console tab
59 | 60 | -------------------------------------------------------------------------------- /samples/SignalR/HelloSignalR/wwwroot/styles/reset.css: -------------------------------------------------------------------------------- 1 | html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video { 2 | margin: 0; 3 | padding: 0; 4 | border: 0; 5 | font-size: 100%; 6 | font: inherit; 7 | vertical-align: baseline; 8 | font-family: 'Segoe UI', Frutiger, 'Frutiger Linotype', 'Dejavu Sans', 'Helvetica Neue', Arial, sans-serif; 9 | } 10 | 11 | article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section { 12 | display: block; 13 | } 14 | 15 | body { 16 | line-height: 1; 17 | } 18 | 19 | ol, ul { 20 | list-style: none; 21 | } 22 | 23 | blockquote, q { 24 | quotes: none; 25 | } 26 | 27 | blockquote:before, blockquote:after, q:before, q:after { 28 | content: ''; 29 | content: none; 30 | } 31 | 32 | table { 33 | border-collapse: collapse; 34 | border-spacing: 0; 35 | } 36 | 37 | html { 38 | box-sizing: border-box; 39 | } 40 | 41 | *, *:before, *:after { 42 | box-sizing: inherit; 43 | } 44 | 45 | h1 { 46 | font-weight: 400; 47 | font-size: 24px; 48 | line-height: 17.6px; 49 | } 50 | 51 | h3 { 52 | font-weight: 400; 53 | font-size: 14px; 54 | line-height: 10.2667px; 55 | } 56 | 57 | p { 58 | font-weight: 400; 59 | font-size: 14px; 60 | line-height: 13.3333px; 61 | } 62 | 63 | blockquote { 64 | font-weight: 400; 65 | font-size: 21px; 66 | line-height: 20px; 67 | } 68 | 69 | pre { 70 | font-weight: 400; 71 | font-size: 13px; 72 | line-height: 12.381px; 73 | } 74 | -------------------------------------------------------------------------------- /samples/SignalR/HelloSignalR/wwwroot/styles/sample.css: -------------------------------------------------------------------------------- 1 | @import 'reset.css'; 2 | 3 | body { 4 | padding: 10px; 5 | } 6 | 7 | h1 { 8 | padding-bottom: 12px; 9 | } 10 | 11 | code { 12 | display: inline-block; 13 | background: #ccc; 14 | padding: 7px; 15 | padding-top: 4px; 16 | padding-bottom: 5px; 17 | border-radius: 3px; 18 | } --------------------------------------------------------------------------------