├── .gitignore ├── LICENSE.txt ├── README.md ├── src-client └── facebook-js │ ├── Photon │ ├── Photon-Javascript_SDK.js │ └── Photon-Javascript_SDK.min.js │ ├── app.js │ ├── cloud-app-info.js │ ├── css │ ├── reset.css │ └── styles.css │ └── index.html └── src ├── Asp.Net.MVC ├── .nuget │ ├── NuGet.Config │ ├── NuGet.exe │ └── NuGet.targets ├── ExitGames.Authentication.Service.MVC.sln ├── ExitGames.Authentication.Service.MVC.sln.DotSettings ├── ExitGames.Web.Sample │ ├── App_Start │ │ ├── FilterConfig.cs │ │ └── RouteConfig.cs │ ├── Controllers │ │ └── ClientController.cs │ ├── ExitGames.Web.Sample.csproj │ ├── Global.asax │ ├── Global.asax.cs │ ├── Models │ │ └── Result.cs │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ └── PublishProfiles │ │ │ └── filesystem.pubxml │ ├── Services │ │ ├── ClientAuthenticationService.cs │ │ ├── IClientAuthenticationService.cs │ │ ├── IUserRepository.cs │ │ └── UserRepository.cs │ ├── Settings.StyleCop │ ├── Views │ │ └── Web.config │ ├── Web.Debug.config │ ├── Web.Release.config │ ├── Web.config │ └── packages.config └── Settings.StyleCop └── Asp.Net.WebAPI ├── .nuget ├── NuGet.Config ├── NuGet.exe └── NuGet.targets ├── ExitGames.Authentication.Service.WebAPI.sln ├── ExitGames.Authentication.Service.WebAPI.sln.DotSettings ├── ExitGames.Web.Sample ├── App_Start │ ├── FilterConfig.cs │ └── WebApiConfig.cs ├── Controllers │ └── ClientController.cs ├── ExitGames.Web.Sample.csproj ├── Global.asax ├── Global.asax.cs ├── Models │ └── Result.cs ├── Properties │ ├── AssemblyInfo.cs │ └── PublishProfiles │ │ └── filesystem.pubxml ├── Services │ ├── ClientAuthenticationService.cs │ ├── IClientAuthenticationService.cs │ ├── IUserRepository.cs │ └── UserRepository.cs ├── Settings.StyleCop ├── Views │ └── Web.config ├── Web.Debug.config ├── Web.Release.config ├── Web.config └── packages.config └── Settings.StyleCop /.gitignore: -------------------------------------------------------------------------------- 1 | # Build Folders (you can keep bin if you'd like, to store dlls and pdbs) 2 | [Bb]in/ 3 | [Oo]bj/ 4 | 5 | # mstest test results 6 | TestResults 7 | 8 | ## Ignore Visual Studio temporary files, build results, and 9 | ## files generated by popular Visual Studio add-ons. 10 | 11 | # User-specific files 12 | *.suo 13 | *.user 14 | *.sln.docstates 15 | 16 | # Build results 17 | [Dd]ebug/ 18 | [Rr]elease/ 19 | x64/ 20 | *_i.c 21 | *_p.c 22 | *.ilk 23 | *.meta 24 | *.obj 25 | *.pch 26 | *.pdb 27 | *.pgc 28 | *.pgd 29 | *.rsp 30 | *.sbr 31 | *.tlb 32 | *.tli 33 | *.tlh 34 | *.tmp 35 | *.log 36 | *.vspscc 37 | *.vssscc 38 | .builds 39 | 40 | # Visual C++ cache files 41 | ipch/ 42 | *.aps 43 | *.ncb 44 | *.opensdf 45 | *.sdf 46 | 47 | # Visual Studio profiler 48 | *.psess 49 | *.vsp 50 | *.vspx 51 | 52 | # Guidance Automation Toolkit 53 | *.gpState 54 | 55 | # ReSharper is a .NET coding add-in 56 | _ReSharper* 57 | 58 | # NCrunch 59 | *.ncrunch* 60 | .*crunch*.local.xml 61 | 62 | # Installshield output folder 63 | [Ee]xpress 64 | 65 | # DocProject is a documentation generator add-in 66 | DocProject/buildhelp/ 67 | DocProject/Help/*.HxT 68 | DocProject/Help/*.HxC 69 | DocProject/Help/*.hhc 70 | DocProject/Help/*.hhk 71 | DocProject/Help/*.hhp 72 | DocProject/Help/Html2 73 | DocProject/Help/html 74 | 75 | # Click-Once directory 76 | publish 77 | 78 | # Publish Web Output 79 | *.Publish.xml 80 | 81 | # NuGet Packages Directory 82 | packages 83 | 84 | # Windows Azure Build Output 85 | csx 86 | *.build.csdef 87 | 88 | # Windows Store app package directory 89 | AppPackages/ 90 | 91 | # Others 92 | [Bb]in 93 | [Oo]bj 94 | sql 95 | TestResults 96 | [Tt]est[Rr]esult* 97 | *.Cache 98 | ClientBin 99 | [Ss]tyle[Cc]op.* 100 | ~$* 101 | *.dbmdl 102 | Generated_Code #added for RIA/Silverlight projects 103 | 104 | # Backup & report files from converting an old project file to a newer 105 | # Visual Studio version. Backup files are not needed, because we have git ;-) 106 | _UpgradeReport_Files/ 107 | Backup*/ 108 | UpgradeLog*.XML 109 | src/Asp.Net.WebAPI/deploy/ 110 | src/Asp.Net.MVC/deploy/ 111 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright 2017, Exit Games, Inc. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), 4 | a right to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software 5 | (and to permit persons to whom the Software is furnished to do so), 6 | always provided that the Software is embedded or implemented in an application that uses or has implemented the Exit Games Photon platform. 7 | 8 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO 11 | THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 12 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 13 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 14 | OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Exit Games Photon - Custom Authentication 2 | ========================================= 3 | 4 | This repository provides sample Custom Authentication Service implementations for the Exit Games Photon Cloud SaaS. 5 | 6 | ## Overview 7 | 8 | When using the Exit Games Photon Cloud (Realtime, PUN, Voice, Chat, ...) to develop your application, you have the option of setting up custom authentication providers for your application. This way, you are able to authenticate your users against a number of authentication providers. This includes a custom authentication provider, that you can build and host yourself, so that you can do authentication against e.g. your own user database. This repository provides sample implementations of such a service. 9 | 10 | You also want to have a look at the [documentation](https://doc.photonengine.com/en-us/realtime/current/connection-and-authentication/authentication/custom-authentication) of the feature. 11 | 12 | ## Authenticate Interface 13 | 14 | You can set up an application with a HTTP(s) endpoint as your authentication provider. The URI of this service has to be configured in your application via your [dashboard](https://dashboard.photonengine.com/). This could e.g. be "https://auth.mycoolgame.com/". 15 | The actual data used for the authentication (username, password, ...) has to be passed in by the client and will be forwarded to the authentication provider by the Photon server via HTTP GET. Have a look at the [documentation](https://doc.photonengine.com/en-us/realtime/current/connection-and-authentication/authentication/custom-authentication) for details. 16 | For your production environment you should of course only use SSL connections! 17 | 18 | How you handle the authentication internally is totally up to you. 19 | The result has to be in Json format with the following values: 20 | 21 | ```json 22 | { ResultCode: 1, Message: "optional Auth OK message" } 23 | 24 | { ResultCode: 2, Message: "optional Auth Failed message" } 25 | 26 | { ResultCode: 3, Message: "optional Parameter invalid message" } 27 | ``` 28 | 29 | ## Other Samples 30 | 31 | You might also check out our [forum](https://forum.photonengine.com/) and discuss with others using the feature. 32 | Topics to note: 33 | * [About custom authentication - How to do it in PHP](https://forum.photonengine.com/discussion/2697/about-custom-authentication-how-to-do-it-in-php) 34 | * [Custom Auth and Parse](https://forum.photonengine.com/discussion/comment/12815) 35 | * [Basics of Custom Authentication? Resources?](https://forum.photonengine.com/discussion/2706/basics-of-custom-authentication-resources) 36 | * [Facebook URL for Authentication?](https://forum.photonengine.com/discussion/comment/28855) 37 | * [Any way to get the login message text from custom auth?](https://forum.photonengine.com/discussion/4891/any-way-to-get-the-login-message-text-from-custom-auth) 38 | * [Custom Authentication Auth token pass thru](https://forum.photonengine.com/discussion/5854/custom-authentication-auth-token-pass-thru) 39 | 40 | We will add some more samples, as soon as we find some time :) 41 | -------------------------------------------------------------------------------- /src-client/facebook-js/Photon/Photon-Javascript_SDK.min.js: -------------------------------------------------------------------------------- 1 | var Photon; 2 | (function(e){var a=function(a,c,d){"undefined"===typeof c&&(c="");"undefined"===typeof d&&(d="");this.url=a;this.subprotocol=c;this.keepAliveTimeoutMs=5E3;this._frame="~m~";this._isClosing=this._isConnected=this._isConnecting=!1;this._peerStatusListeners={};this._eventListeners={};this._responseListeners={};this.keepAliveTimer=0;this._logger=new Exitgames.Common.Logger(d&&""!=d?d+": ":"")};a.prototype.isConnecting=function(){return this._isConnecting};a.prototype.isConnected=function(){return this._isConnected};a.prototype.isClosing= 3 | function(){return this._isClosing};a.prototype.connect=function(){var a=this;this._socket=""==this.subprotocol?new WebSocket(this.url):new WebSocket(this.url,this.subprotocol);this._onConnecting();this._socket.onopen=function(){};this._socket.onmessage=function(c){c=a._decode(c.data);a._onMessage(c.toString())};this._socket.onclose=function(c){a._logger.debug("onclose: wasClean =",c.wasClean,", code=",c.code,", reason =",c.reason);a._isConnecting?a._onConnectFailed(c):(1006==c.code&&a._onTimeout(), 4 | a._onDisconnect())};this._socket.onerror=function(c){a._onError(c)}};a.prototype.disconnect=function(){this._isClosing=!0;this._socket.close()};a.prototype.sendOperation=function(a,c){var d={req:a,vals:[]};if(Exitgames.Common.Util.isArray(c))d.vals=c;else if(void 0===c)d.vals=[];else throw Error(this._logger.format("PhotonPeer[sendOperation] - Trying to send non array data:",c));this._send(d);this._logger.debug("PhotonPeer[sendOperation] - Sending request:",d)};a.prototype.addPeerStatusListener=function(a, 5 | c){this._addListener(this._peerStatusListeners,a,c)};a.prototype.addEventListener=function(a,c){this._addListener(this._eventListeners,a.toString(),c)};a.prototype.addResponseListener=function(a,c){this._addListener(this._responseListeners,a.toString(),c)};a.prototype.removePeerStatusListener=function(a,c){this._removeListener(this._peerStatusListeners,a,c)};a.prototype.removeEventListener=function(a,c){this._removeListener(this._eventListeners,a.toString(),c)};a.prototype.removeResponseListener= 6 | function(a,c){this._removeListener(this._responseListeners,a.toString(),c)};a.prototype.removePeerStatusListenersForCode=function(a){this._removeListenersForCode(this._peerStatusListeners,a)};a.prototype.removeEventListenersForCode=function(a){this._removeListenersForCode(this._eventListeners,a.toString())};a.prototype.removeResponseListenersForCode=function(a){this._removeListenersForCode(this._responseListeners,a.toString())};a.prototype.setLogLevel=function(a){this._logger.setLevel(a)};a.prototype.onUnhandledEvent= 7 | function(a){this._logger.warn("PhotonPeer: No handler for event",a,"registered.")};a.prototype.onUnhandledResponse=function(a){this._logger.warn("PhotonPeer: No handler for response",a,"registered.")};a.StatusCodes={connecting:"connecting",connect:"connect",connectFailed:"connectFailed",disconnect:"disconnect",connectClosed:"connectClosed",error:"error",timeout:"timeout"};a.prototype._dispatchEvent=function(a,c){if(!this._dispatch(this._eventListeners,a.toString(),c,"event"))this.onUnhandledEvent(a, 8 | c)};a.prototype._dispatchResponse=function(a,c){if(!this._dispatch(this._responseListeners,a.toString(),c,"response"))this.onUnhandledResponse(a,c)};a.prototype._stringify=function(a){if("[object Object]"==Object.prototype.toString.call(a)){if(!JSON)throw Error("PhotonPeer[_stringify] - Trying to encode as JSON, but JSON.stringify is missing.");return"~j~"+JSON.stringify(a)}return String(a)};a.prototype._encode=function(a){for(var c="",d,a=Exitgames.Common.Util.isArray(a)?a:[a],b=0,i=a.length;b=this.level};a.prototype.getLevel=function(){return this.level};a.prototype.debug=function(c){for(var d=[],b=0;b=this.level&&"undefined"!==typeof console&&void 0!==d)try{var i=console[a.log_types[c]];i||(i=console.log);i&&(i.call?i.call(console,this.format0(d,b)):i(console,this.format0(d,b)))}catch(e){}};a.prototype.format0=function(a,d){return this.prefix+a+" "+d.map(function(a){if(void 0!==a)switch(typeof a){case "object":try{return JSON.stringify(a)}catch(d){return a.toString()+ 22 | "("+d+")"}default:return a.toString()}}).join(" ")};e.Logger=a;var g=function(){};g.indexOf=function(a,d,b){for(var i=a.length,b=0>b?Math.max(0,i+b):b||0;b",b.StateToName(a));this.state=a;this.onStateChange(a)}; 63 | b.prototype.createRoomInternal=function(b){var c={};c[a.Constants.GameProperties.IsOpen]=this.currentRoom.isOpen;c[a.Constants.GameProperties.IsVisible]=this.currentRoom.isVisible;0 "+b.StateToName(a)); 84 | };b.PeerErrorCode={Ok:0,MasterError:1001,MasterConnectFailed:1002,MasterConnectClosed:1003,MasterTimeout:1004,MasterAuthenticationFailed:1101,GameError:2001,GameConnectFailed:2002,GameConnectClosed:2003,GameTimeout:2004,GameAuthenticationFailed:2101};b.State={Error:-1,Uninitialized:0,ConnectingToMasterserver:1,ConnectedToMaster:2,JoinedLobby:3,ConnectingToGameserver:4,ConnectedToGameserver:5,Joined:6,Disconnecting:7,Disconnected:8};b.StateToName=function(a){return Exitgames.Common.Util.enumValueToName(b.State, 85 | a)};a.LoadBalancingClient=b;var i,n=e.PhotonPeer,j=function(a,b,c){n.call(this,b,c,"Master");this.client=a};__extends(j,n);j.prototype.onUnhandledEvent=function(b,c){this.client.onEvent(b,c.vals[a.Constants.ParameterCode.CustomEventContent],c.vals[a.Constants.ParameterCode.ActorNr])};j.prototype.onUnhandledResponse=function(a,b){this.client.onOperationResponse(b.errCode,b.errMsg,a,b.vals)};i=j;a.MasterPeer=i;var m,p=e.PhotonPeer,j=function(a,b,c){p.call(this,b,c,"Game");this.client=a};__extends(j, 86 | p);j.prototype.onUnhandledEvent=function(b,c){this.client.onEvent(b,c.vals[a.Constants.ParameterCode.CustomEventContent],c.vals[a.Constants.ParameterCode.ActorNr])};j.prototype.onUnhandledResponse=function(a,b){this.client.onOperationResponse(b.errCode,b.errMsg,a,b.vals)};j.prototype.raiseEvent=function(b,c,d){if(this.client.isJoinedToRoom()){this._logger.debug("raiseEvent",b,c,d);b=[a.Constants.ParameterCode.Code,b,a.Constants.ParameterCode.Data,c];if(d&&(void 0!=d.receivers&&d.receivers!==a.Constants.ReceiverGroup.Others&& 87 | (b.push(a.Constants.ParameterCode.ReceiverGroup),b.push(d.receivers)),void 0!=d.cache&&d.cache!==a.Constants.EventCaching.DoNotCache&&(b.push(a.Constants.ParameterCode.Cache),b.push(d.cache)),void 0!=d.interestGroup))if(this.checkGroupNumber(d.interestGroup))b.push(a.Constants.ParameterCode.Group),b.push(d.interestGroup);else throw Error("raiseEvent - Group not a number: "+d.interestGroup);this.sendOperation(a.Constants.OperationCode.RaiseEvent,b)}else throw Error("raiseEvent - Not joined!");};j.prototype.changeGroups= 88 | function(b,c){var d=[];null!=b&&void 0!=b&&(this.checkGroupArray(b,"groupsToRemove"),d.push(a.Constants.ParameterCode.Remove),d.push(b));null!=c&&void 0!=c&&(this.checkGroupArray(c,"groupsToAdd"),d.push(a.Constants.ParameterCode.Add),d.push(c));this.sendOperation(a.Constants.OperationCode.ChangeGroups,d)};j.prototype.checkGroupNumber=function(a){return!("number"!=typeof a||isNaN(a)||Infinity===a||-Infinity===a)};j.prototype.checkGroupArray=function(a,b){if(Exitgames.Common.Util.isArray(a))for(var c= 89 | 0;c"; 8 | var DemoAppVersion = this["AppInfo"] && this["AppInfo"]["AppVersion"] ? this["AppInfo"]["AppVersion"] : "1.0"; 9 | var DemoFbAppId = this["AppInfo"] && this["AppInfo"]["FbAppId"]; 10 | 11 | var client = new Photon.LoadBalancing.LoadBalancingClient(DemoMasterAddress, DemoAppId, DemoAppVersion) 12 | // client.onFbToken = function (token) { 13 | // client.setCustomAuthentication("token=" + token, 2); 14 | // client.output("Got fb token. Setting custom fb authentication."); 15 | // client.output("Connect..."); 16 | // client.connect(true); 17 | // }; 18 | 19 | client.onError = function (errorCode, errorMsg) { 20 | this.output("Error " + errorCode + ": " + errorMsg); 21 | }; 22 | client.onStateChange = function (state) { 23 | var LBC = Photon.LoadBalancing.LoadBalancingClient; 24 | this.output("State: " + LBC.StateToName(state)); 25 | }; 26 | client.onJoinRoom = function () { 27 | this.output("Game " + this.myRoom().name + " joined"); 28 | }; 29 | client.onActorJoin = function (actor) { 30 | this.output("actor " + actor.actorNr + " joined"); 31 | }; 32 | client.onActorLeave = function (actor) { 33 | this.output("actor " + actor.actorNr + " left"); 34 | }; 35 | client.output = function (str, color) { 36 | var out = document.getElementById("output"); 37 | var escaped = str.replace(/&/, "&").replace(//, ">").replace(/"/, """); 38 | out.innerHTML = out.innerHTML + escaped + "
"; 39 | }; 40 | 41 | window.onload = function () { 42 | client.output("Init: " + DemoMasterAddress + " / " + DemoAppId + " / " + DemoAppVersion); 43 | //client.output("Connect: " + DemoMasterAddress + " / " + DemoAppId + " / " + DemoAppVersion); 44 | //client.connect(); 45 | }; 46 | 47 | 48 | //@ sourceMappingURL=app.js.map 49 | // new comment version //# sourceMappingURL=app.js.map 50 | -------------------------------------------------------------------------------- /src-client/facebook-js/cloud-app-info.js: -------------------------------------------------------------------------------- 1 |  2 | var AppInfo = { 3 | MasterAddress: "app.exitgamescloud.com", 4 | AppId: "your-photon-cloud-app-id", 5 | AppVersion: "1.0", 6 | FbAppId: "your-facebook-app-id", 7 | } 8 | 9 | -------------------------------------------------------------------------------- /src-client/facebook-js/css/reset.css: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a modified version of the HTML5 Boilerplate CSS. 3 | * 4 | * What follows is the result of much research on cross-browser styling. 5 | * Credit left inline and big thanks to Nicolas Gallagher, Jonathan Neal, 6 | * Kroc Camen, and the H5BP dev community and team. 7 | * 8 | * Detailed information about this CSS: h5bp.com/css 9 | * 10 | * ==|== normalize ========================================================== 11 | */ 12 | 13 | 14 | /* ============================================================================= 15 | HTML5 display definitions 16 | ========================================================================== */ 17 | 18 | article, aside, details, figcaption, figure, footer, header, hgroup, nav, section { display: block; } 19 | audio, canvas, video { display: inline-block; *display: inline; *zoom: 1; } 20 | audio:not([controls]) { display: none; } 21 | [hidden] { display: none; } 22 | 23 | 24 | /* ============================================================================= 25 | Base 26 | ========================================================================== */ 27 | 28 | /* 29 | * 1. Correct text resizing oddly in IE6/7 when body font-size is set using em units 30 | * 2. Prevent iOS text size adjust on device orientation change, without disabling user zoom: h5bp.com/g 31 | */ 32 | 33 | html { font-size: 100%; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; } 34 | 35 | html, button, input, select, textarea { font-family: sans-serif; color: #222; } 36 | 37 | body { margin: 0; font-size: 1em; line-height: 1.4; } 38 | 39 | 40 | /* ============================================================================= 41 | Links 42 | ========================================================================== */ 43 | 44 | a { color: #00e; } 45 | a:visited { color: #551a8b; } 46 | a:hover { color: #06e; } 47 | a:focus { outline: thin dotted; } 48 | 49 | /* Improve readability when focused and hovered in all browsers: h5bp.com/h */ 50 | a:hover, a:active { outline: 0; } 51 | 52 | 53 | /* ============================================================================= 54 | Typography 55 | ========================================================================== */ 56 | 57 | abbr[title] { border-bottom: 1px dotted; } 58 | 59 | b, strong { font-weight: bold; } 60 | 61 | blockquote { margin: 1em 40px; } 62 | 63 | dfn { font-style: italic; } 64 | 65 | hr { display: block; height: 1px; border: 0; border-top: 1px solid #ccc; margin: 1em 0; padding: 0; } 66 | 67 | ins { background: #ff9; color: #000; text-decoration: none; } 68 | 69 | mark { background: #ff0; color: #000; font-style: italic; font-weight: bold; } 70 | 71 | /* Redeclare monospace font family: h5bp.com/j */ 72 | pre, code, kbd, samp { font-family: monospace, serif; _font-family: 'courier new', monospace; font-size: 1em; } 73 | 74 | /* Improve readability of pre-formatted text in all browsers */ 75 | pre { white-space: pre; white-space: pre-wrap; word-wrap: break-word; } 76 | 77 | q { quotes: none; } 78 | q:before, q:after { content: ""; content: none; } 79 | 80 | small { font-size: 85%; } 81 | 82 | /* Position subscript and superscript content without affecting line-height: h5bp.com/k */ 83 | sub, sup { font-size: 75%; line-height: 0; position: relative; vertical-align: baseline; } 84 | sup { top: -0.5em; } 85 | sub { bottom: -0.25em; } 86 | 87 | 88 | /* ============================================================================= 89 | Lists 90 | ========================================================================== */ 91 | 92 | ul, ol { margin: 1em 0; padding: 0 0 0 40px; } 93 | dd { margin: 0 0 0 40px; } 94 | nav ul, nav ol { list-style: none; list-style-image: none; margin: 0; padding: 0; } 95 | 96 | 97 | /* ============================================================================= 98 | Embedded content 99 | ========================================================================== */ 100 | 101 | /* 102 | * 1. Improve image quality when scaled in IE7: h5bp.com/d 103 | * 2. Remove the gap between images and borders on image containers: h5bp.com/i/440 104 | */ 105 | 106 | img { border: 0; -ms-interpolation-mode: bicubic; vertical-align: middle; } 107 | 108 | /* 109 | * Correct overflow not hidden in IE9 110 | */ 111 | 112 | svg:not(:root) { overflow: hidden; } 113 | 114 | 115 | /* ============================================================================= 116 | Figures 117 | ========================================================================== */ 118 | 119 | figure { margin: 0; } 120 | 121 | 122 | /* ============================================================================= 123 | Forms 124 | ========================================================================== */ 125 | 126 | form { margin: 0; } 127 | fieldset { border: 0; margin: 0; padding: 0; } 128 | 129 | /* Indicate that 'label' will shift focus to the associated form element */ 130 | label { cursor: pointer; } 131 | 132 | /* 133 | * 1. Correct color not inheriting in IE6/7/8/9 134 | * 2. Correct alignment displayed oddly in IE6/7 135 | */ 136 | 137 | legend { border: 0; *margin-left: -7px; padding: 0; white-space: normal; } 138 | 139 | /* 140 | * 1. Correct font-size not inheriting in all browsers 141 | * 2. Remove margins in FF3/4 S5 Chrome 142 | * 3. Define consistent vertical alignment display in all browsers 143 | */ 144 | 145 | button, input, select, textarea { font-size: 100%; margin: 0; vertical-align: baseline; *vertical-align: middle; } 146 | 147 | /* 148 | * 1. Define line-height as normal to match FF3/4 (set using !important in the UA stylesheet) 149 | */ 150 | 151 | button, input { line-height: normal; } 152 | 153 | /* 154 | * 1. Display hand cursor for clickable form elements 155 | * 2. Allow styling of clickable form elements in iOS 156 | * 3. Correct inner spacing displayed oddly in IE7 (doesn't effect IE6) 157 | */ 158 | 159 | button, input[type="button"], input[type="reset"], input[type="submit"] { cursor: pointer; -webkit-appearance: button; *overflow: visible; } 160 | 161 | /* 162 | * Re-set default cursor for disabled elements 163 | */ 164 | 165 | button[disabled], input[disabled] { cursor: default; } 166 | 167 | /* 168 | * Consistent box sizing and appearance 169 | */ 170 | 171 | input[type="checkbox"], input[type="radio"] { box-sizing: border-box; padding: 0; *width: 13px; *height: 13px; } 172 | input[type="search"] { -webkit-appearance: textfield; -moz-box-sizing: content-box; -webkit-box-sizing: content-box; box-sizing: content-box; } 173 | input[type="search"]::-webkit-search-decoration, input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; } 174 | 175 | /* 176 | * Remove inner padding and border in FF3/4: h5bp.com/l 177 | */ 178 | 179 | button::-moz-focus-inner, input::-moz-focus-inner { border: 0; padding: 0; } 180 | 181 | /* 182 | * 1. Remove default vertical scrollbar in IE6/7/8/9 183 | * 2. Allow only vertical resizing 184 | */ 185 | 186 | textarea { overflow: auto; vertical-align: top; resize: vertical; } 187 | 188 | /* Colors for form validity */ 189 | input:valid, textarea:valid { } 190 | input:invalid, textarea:invalid { background-color: #f0dddd; } 191 | 192 | 193 | /* ============================================================================= 194 | Tables 195 | ========================================================================== */ 196 | 197 | table { border-collapse: collapse; border-spacing: 0; } 198 | td { vertical-align: top; } 199 | 200 | 201 | /* ============================================================================= 202 | Chrome Frame Prompt 203 | ========================================================================== */ 204 | 205 | .chromeframe { margin: 0.2em 0; background: #ccc; color: black; padding: 0.2em 0; } 206 | 207 | 208 | /* ==|== non-semantic helper classes ======================================== 209 | Please define your styles before this section. 210 | ========================================================================== */ 211 | 212 | /* For image replacement */ 213 | .ir { display: block; border: 0; text-indent: -999em; overflow: hidden; background-color: transparent; background-repeat: no-repeat; text-align: left; direction: ltr; *line-height: 0; } 214 | .ir br { display: none; } 215 | 216 | /* Hide from both screenreaders and browsers: h5bp.com/u */ 217 | .hidden { display: none !important; visibility: hidden; } 218 | 219 | /* Hide only visually, but have it available for screenreaders: h5bp.com/v */ 220 | .visuallyhidden { border: 0; clip: rect(0 0 0 0); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; width: 1px; } 221 | 222 | /* Extends the .visuallyhidden class to allow the element to be focusable when navigated to via the keyboard: h5bp.com/p */ 223 | .visuallyhidden.focusable:active, .visuallyhidden.focusable:focus { clip: auto; height: auto; margin: 0; overflow: visible; position: static; width: auto; } 224 | 225 | /* Hide visually and from screenreaders, but maintain layout */ 226 | .invisible { visibility: hidden; } 227 | 228 | /* Contain floats: h5bp.com/q */ 229 | .clearfix:before, .clearfix:after { content: ""; display: table; } 230 | .clearfix:after { clear: both; } 231 | .clearfix { *zoom: 1; } 232 | 233 | 234 | 235 | /* ==|== print styles ======================================================= 236 | Print styles. 237 | Inlined to avoid required HTTP connection: h5bp.com/r 238 | ========================================================================== */ 239 | 240 | @media print { 241 | * { background: transparent !important; color: black !important; box-shadow:none !important; text-shadow: none !important; filter:none !important; -ms-filter: none !important; } /* Black prints faster: h5bp.com/s */ 242 | a, a:visited { text-decoration: underline; } 243 | a[href]:after { content: " (" attr(href) ")"; } 244 | abbr[title]:after { content: " (" attr(title) ")"; } 245 | .ir a:after, a[href^="javascript:"]:after, a[href^="#"]:after { content: ""; } /* Don't show links for images, or javascript/internal links */ 246 | pre, blockquote { border: 1px solid #999; page-break-inside: avoid; } 247 | thead { display: table-header-group; } /* h5bp.com/t */ 248 | tr, img { page-break-inside: avoid; } 249 | img { max-width: 100% !important; } 250 | @page { margin: 0.5cm; } 251 | p, h2, h3 { orphans: 3; widows: 3; } 252 | h2, h3 { page-break-after: avoid; } 253 | } 254 | -------------------------------------------------------------------------------- /src-client/facebook-js/css/styles.css: -------------------------------------------------------------------------------- 1 | body { 2 | background: #eee; 3 | text-align: center; 4 | padding: 0 25px; 5 | } 6 | 7 | #main { 8 | width: 500px; 9 | margin: auto; 10 | text-align: left; 11 | background: white; 12 | padding: 50px 60px; 13 | border: solid #ddd; 14 | border-width: 0 1px 1px 1px; 15 | } 16 | 17 | #main h1 { 18 | margin-top: 0; 19 | font-size: 35px; 20 | } 21 | 22 | #main ul { 23 | padding-left: 20px; 24 | } 25 | 26 | #main .error { 27 | border: 1px solid red; 28 | background: #FDEFF0; 29 | padding: 20px; 30 | } 31 | 32 | #main .success { 33 | margin-top: 25px; 34 | } 35 | 36 | #main .success code { 37 | font-size: 12px; 38 | color: green; 39 | line-height: 13px; 40 | } 41 | -------------------------------------------------------------------------------- /src-client/facebook-js/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | My App 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 |

My App

20 | 21 |

Using Photon Custom Authentication for Facebook

22 | 23 |

Read the documentation and start building your JavaScript app:

24 | 25 |

Custom Authentication - General Overview (doc)

26 |

Custom Authentication for Facebook (doc)

27 | 28 |

Photon Javascript SDK (doc)

29 | 30 |

Facebook Login Button (doc):

31 | 32 | 33 |

34 |
35 | 36 |
37 | 38 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /src/Asp.Net.MVC/.nuget/NuGet.Config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/Asp.Net.MVC/.nuget/NuGet.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exitgames/photon.custom-authentication/a9c58ad3dc98d82fb4d1549e755af4c1e64a58e5/src/Asp.Net.MVC/.nuget/NuGet.exe -------------------------------------------------------------------------------- /src/Asp.Net.MVC/.nuget/NuGet.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $(MSBuildProjectDirectory)\..\ 5 | 6 | 7 | false 8 | 9 | 10 | false 11 | 12 | 13 | true 14 | 15 | 16 | false 17 | 18 | 19 | 20 | 21 | 22 | 26 | 27 | 28 | 29 | 30 | $([System.IO.Path]::Combine($(SolutionDir), ".nuget")) 31 | $([System.IO.Path]::Combine($(ProjectDir), "packages.config")) 32 | 33 | 34 | 35 | 36 | $(SolutionDir).nuget 37 | packages.config 38 | 39 | 40 | 41 | 42 | $(NuGetToolsPath)\NuGet.exe 43 | @(PackageSource) 44 | 45 | "$(NuGetExePath)" 46 | mono --runtime=v4.0.30319 $(NuGetExePath) 47 | 48 | $(TargetDir.Trim('\\')) 49 | 50 | -RequireConsent 51 | -NonInteractive 52 | 53 | 54 | $(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir "$(SolutionDir) " 55 | $(NuGetCommand) pack "$(ProjectPath)" -Properties Configuration=$(Configuration) $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols 56 | 57 | 58 | 59 | RestorePackages; 60 | $(BuildDependsOn); 61 | 62 | 63 | 64 | 65 | $(BuildDependsOn); 66 | BuildPackage; 67 | 68 | 69 | 70 | 71 | 72 | 73 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 88 | 89 | 92 | 93 | 94 | 95 | 97 | 98 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 130 | 131 | 132 | 133 | -------------------------------------------------------------------------------- /src/Asp.Net.MVC/ExitGames.Authentication.Service.MVC.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2012 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExitGames.Web.Sample", "ExitGames.Web.Sample\ExitGames.Web.Sample.csproj", "{979C8378-AD6A-46FE-BBB2-99749741E8A9}" 5 | EndProject 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{54B7C3A4-CD87-41AF-9B4C-3692F57A680A}" 7 | ProjectSection(SolutionItems) = preProject 8 | .nuget\NuGet.Config = .nuget\NuGet.Config 9 | .nuget\NuGet.exe = .nuget\NuGet.exe 10 | .nuget\NuGet.targets = .nuget\NuGet.targets 11 | EndProjectSection 12 | EndProject 13 | Global 14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 15 | Debug|Any CPU = Debug|Any CPU 16 | Release|Any CPU = Release|Any CPU 17 | EndGlobalSection 18 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 19 | {979C8378-AD6A-46FE-BBB2-99749741E8A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 20 | {979C8378-AD6A-46FE-BBB2-99749741E8A9}.Debug|Any CPU.Build.0 = Debug|Any CPU 21 | {979C8378-AD6A-46FE-BBB2-99749741E8A9}.Release|Any CPU.ActiveCfg = Release|Any CPU 22 | {979C8378-AD6A-46FE-BBB2-99749741E8A9}.Release|Any CPU.Build.0 = Release|Any CPU 23 | EndGlobalSection 24 | GlobalSection(SolutionProperties) = preSolution 25 | HideSolutionNode = FALSE 26 | EndGlobalSection 27 | EndGlobal 28 | -------------------------------------------------------------------------------- /src/Asp.Net.MVC/ExitGames.Authentication.Service.MVC.sln.DotSettings: -------------------------------------------------------------------------------- 1 |  2 | 140 3 | True -------------------------------------------------------------------------------- /src/Asp.Net.MVC/ExitGames.Web.Sample/App_Start/FilterConfig.cs: -------------------------------------------------------------------------------- 1 | namespace ExitGames.Web.Sample 2 | { 3 | using System.Web.Mvc; 4 | 5 | public class FilterConfig 6 | { 7 | public static void RegisterGlobalFilters(GlobalFilterCollection filters) 8 | { 9 | filters.Add(new HandleErrorAttribute()); 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /src/Asp.Net.MVC/ExitGames.Web.Sample/App_Start/RouteConfig.cs: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Exit Games GmbH. All rights reserved. 4 | // 5 | // 6 | // Defines the RouteConfig type. 7 | // 8 | // -------------------------------------------------------------------------------------------------------------------- 9 | 10 | namespace ExitGames.Web.Sample 11 | { 12 | using System.Web.Mvc; 13 | using System.Web.Routing; 14 | 15 | public class RouteConfig 16 | { 17 | public static void RegisterRoutes(RouteCollection routes) 18 | { 19 | routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 20 | 21 | routes.MapRoute( 22 | "Authenticate2", 23 | "api/{controller}/{action}/{userName}/{token}"); 24 | routes.MapRoute( 25 | "Authenticate", 26 | "{controller}/{action}/{userName}/{token}"); 27 | 28 | routes.MapRoute( 29 | name: "Default2", 30 | url: "api/{controller}/{action}/{id}", 31 | defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }); 32 | routes.MapRoute( 33 | name: "Default", 34 | url: "{controller}/{action}/{id}", 35 | defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }); 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /src/Asp.Net.MVC/ExitGames.Web.Sample/Controllers/ClientController.cs: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Exit Games GmbH. All rights reserved. 4 | // 5 | // 6 | // Defines the ClientController type. 7 | // 8 | // -------------------------------------------------------------------------------------------------------------------- 9 | 10 | namespace ExitGames.Web.Sample.Controllers 11 | { 12 | using System.Web.Mvc; 13 | 14 | using ExitGames.Web.Sample.Models; 15 | using ExitGames.Web.Sample.Services; 16 | 17 | // TODO be sure to use SSL in production 18 | //[RequireHttps] 19 | public class ClientController : Controller 20 | { 21 | public ClientController() 22 | : this(null) 23 | { 24 | } 25 | 26 | public ClientController(IClientAuthenticationService authenticationService) 27 | { 28 | this.AuthenticationService = authenticationService ?? new ClientAuthenticationService(); 29 | } 30 | 31 | public IClientAuthenticationService AuthenticationService { get; private set; } 32 | 33 | //// Example calls with results according to current routing setup: 34 | //// http://dev-customauth.exitgames.com/client/authenticate/yes/yes -> 1 35 | //// http://dev-customauth.exitgames.com/client/authenticate/yes/no -> 2 36 | //// http://dev-customauth.exitgames.com/client/authenticate?username=yes&token=yes -> 1 37 | //// http://dev-customauth.exitgames.com/client/authenticate?username=yes&token=no -> 2 38 | //// http://dev-customauth.exitgames.com/client/authenticate -> 3 Parameter invalid 39 | 40 | /// 41 | /// Authenticates a user with the given credentials. 42 | /// 43 | /// Name of user to authenticate. 44 | /// Token to authenticate user with. 45 | /// Result of authentication. 46 | public ActionResult Authenticate(string userName, string token) 47 | { 48 | if (string.IsNullOrWhiteSpace(userName) || string.IsNullOrWhiteSpace(token)) 49 | { 50 | var resultErrorInput = new Result { ResultCode = 3, Message = "Parameter invalid" }; 51 | JsonResult resultErrorInputJson = this.Json(resultErrorInput, JsonRequestBehavior.AllowGet); 52 | return resultErrorInputJson; 53 | } 54 | 55 | bool authenticated = this.AuthenticationService.Authenticate(userName, token); 56 | if (authenticated) 57 | { 58 | // authentication ok 59 | var resultOk = new Result { ResultCode = 1 }; 60 | JsonResult resultOkJson = this.Json(resultOk, JsonRequestBehavior.AllowGet); 61 | return resultOkJson; 62 | } 63 | 64 | // authentication failed 65 | var resultError = new Result 66 | { 67 | ResultCode = 2, 68 | ////Message = "whatever reason" // optional 69 | }; 70 | JsonResult resultErrorJson = this.Json(resultError, JsonRequestBehavior.AllowGet); 71 | return resultErrorJson; 72 | } 73 | } 74 | } -------------------------------------------------------------------------------- /src/Asp.Net.MVC/ExitGames.Web.Sample/ExitGames.Web.Sample.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | 8 | 9 | 2.0 10 | {979C8378-AD6A-46FE-BBB2-99749741E8A9} 11 | {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} 12 | Library 13 | Properties 14 | ExitGames.Web.Sample 15 | ExitGames.Web.Sample 16 | v4.5 17 | false 18 | true 19 | 20 | 21 | 22 | 23 | ..\ 24 | true 25 | 4fd9565f 26 | 27 | 28 | true 29 | full 30 | false 31 | bin\ 32 | DEBUG;TRACE 33 | prompt 34 | 4 35 | 36 | 37 | pdbonly 38 | true 39 | bin\ 40 | TRACE 41 | prompt 42 | 4 43 | 44 | 45 | 46 | ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll 47 | True 48 | 49 | 50 | ..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll 51 | True 52 | 53 | 54 | 55 | 56 | ..\packages\Microsoft.Net.Http.2.2.29\lib\net40\System.Net.Http.dll 57 | True 58 | 59 | 60 | ..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Extensions.dll 61 | True 62 | 63 | 64 | ..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Primitives.dll 65 | True 66 | 67 | 68 | 69 | 70 | 71 | ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.Helpers.dll 72 | True 73 | 74 | 75 | ..\packages\Microsoft.AspNet.Mvc.5.2.3\lib\net45\System.Web.Mvc.dll 76 | True 77 | 78 | 79 | ..\packages\Microsoft.AspNet.Razor.3.2.3\lib\net45\System.Web.Razor.dll 80 | True 81 | 82 | 83 | 84 | 85 | ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.dll 86 | True 87 | 88 | 89 | ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Deployment.dll 90 | True 91 | 92 | 93 | ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Razor.dll 94 | True 95 | 96 | 97 | 98 | 99 | 100 | Global.asax 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | Web.config 116 | 117 | 118 | Web.config 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | Designer 128 | 129 | 130 | 131 | 132 | 133 | 134 | 10.0 135 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | True 148 | True 149 | 2533 150 | / 151 | http://localhost:5555/ 152 | False 153 | False 154 | 155 | 156 | False 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 173 | -------------------------------------------------------------------------------- /src/Asp.Net.MVC/ExitGames.Web.Sample/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Codebehind="Global.asax.cs" Inherits="ExitGames.Web.Sample.MvcApplication" Language="C#" %> 2 | -------------------------------------------------------------------------------- /src/Asp.Net.MVC/ExitGames.Web.Sample/Global.asax.cs: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Exit Games GmbH. All rights reserved. 4 | // 5 | // 6 | // Defines the MvcApplication type. 7 | // 8 | // -------------------------------------------------------------------------------------------------------------------- 9 | 10 | namespace ExitGames.Web.Sample 11 | { 12 | using System.Web.Mvc; 13 | using System.Web.Routing; 14 | 15 | // Note: For instructions on enabling IIS6 or IIS7 classic mode, 16 | // visit http://go.microsoft.com/?LinkId=9394801 17 | public class MvcApplication : System.Web.HttpApplication 18 | { 19 | protected void Application_Start() 20 | { 21 | AreaRegistration.RegisterAllAreas(); 22 | 23 | FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); 24 | RouteConfig.RegisterRoutes(RouteTable.Routes); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /src/Asp.Net.MVC/ExitGames.Web.Sample/Models/Result.cs: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Exit Games GmbH. All rights reserved. 4 | // 5 | // 6 | // Defines the Result type. 7 | // 8 | // -------------------------------------------------------------------------------------------------------------------- 9 | 10 | namespace ExitGames.Web.Sample.Models 11 | { 12 | public class Result 13 | { 14 | public int ResultCode { get; set; } 15 | 16 | public string Message { get; set; } 17 | } 18 | } -------------------------------------------------------------------------------- /src/Asp.Net.MVC/ExitGames.Web.Sample/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ExitGames.Web.Sample")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Exit Games GmbH")] 12 | [assembly: AssemblyProduct("ExitGames.Web.Sample")] 13 | [assembly: AssemblyCopyright("Copyright © 2013")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("09f38e70-c3e4-458e-b93e-590bf0fa13ae")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /src/Asp.Net.MVC/ExitGames.Web.Sample/Properties/PublishProfiles/filesystem.pubxml: -------------------------------------------------------------------------------- 1 |  2 | 6 | 7 | 8 | FileSystem 9 | Debug 10 | Any CPU 11 | 12 | False 13 | ..\deploy 14 | True 15 | 16 | -------------------------------------------------------------------------------- /src/Asp.Net.MVC/ExitGames.Web.Sample/Services/ClientAuthenticationService.cs: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Exit Games GmbH. All rights reserved. 4 | // 5 | // 6 | // Defines the ClientAuthenticationService type. 7 | // 8 | // -------------------------------------------------------------------------------------------------------------------- 9 | 10 | namespace ExitGames.Web.Sample.Services 11 | { 12 | public class ClientAuthenticationService : IClientAuthenticationService 13 | { 14 | private readonly IUserRepository userRepository; 15 | 16 | public ClientAuthenticationService() 17 | : this(null) 18 | { 19 | } 20 | 21 | public ClientAuthenticationService(IUserRepository repository) 22 | { 23 | this.userRepository = repository ?? new UserRepository(); 24 | } 25 | 26 | public bool Authenticate(string userName, string token) 27 | { 28 | // TODO use repository to get user and authenticate 29 | if (userName == token) 30 | { 31 | return true; 32 | } 33 | 34 | return false; 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /src/Asp.Net.MVC/ExitGames.Web.Sample/Services/IClientAuthenticationService.cs: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Exit Games GmbH. All rights reserved. 4 | // 5 | // 6 | // Defines the IClientAuthenticationService type. 7 | // 8 | // -------------------------------------------------------------------------------------------------------------------- 9 | 10 | namespace ExitGames.Web.Sample.Services 11 | { 12 | public interface IClientAuthenticationService 13 | { 14 | bool Authenticate(string userName, string token); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/Asp.Net.MVC/ExitGames.Web.Sample/Services/IUserRepository.cs: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Exit Games GmbH. All rights reserved. 4 | // 5 | // 6 | // Defines the IUserRepository type. 7 | // 8 | // -------------------------------------------------------------------------------------------------------------------- 9 | 10 | namespace ExitGames.Web.Sample.Services 11 | { 12 | public interface IUserRepository 13 | { 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/Asp.Net.MVC/ExitGames.Web.Sample/Services/UserRepository.cs: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Exit Games GmbH. All rights reserved. 4 | // 5 | // 6 | // Defines the UserRepository type. 7 | // 8 | // -------------------------------------------------------------------------------------------------------------------- 9 | 10 | namespace ExitGames.Web.Sample.Services 11 | { 12 | public class UserRepository : IUserRepository 13 | { 14 | } 15 | } -------------------------------------------------------------------------------- /src/Asp.Net.MVC/ExitGames.Web.Sample/Settings.StyleCop: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/Asp.Net.MVC/ExitGames.Web.Sample/Views/Web.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 |
7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 39 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /src/Asp.Net.MVC/ExitGames.Web.Sample/Web.Debug.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | -------------------------------------------------------------------------------- /src/Asp.Net.MVC/ExitGames.Web.Sample/Web.Release.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | -------------------------------------------------------------------------------- /src/Asp.Net.MVC/ExitGames.Web.Sample/Web.config: -------------------------------------------------------------------------------- 1 |  2 | 6 | 7 | 8 | 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 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /src/Asp.Net.MVC/ExitGames.Web.Sample/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/Asp.Net.MVC/Settings.StyleCop: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Exit Games GmbH 6 | Copyright (c) Exit Games GmbH. All rights reserved. 7 | 8 | 9 | 10 | 11 | False 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/Asp.Net.WebAPI/.nuget/NuGet.Config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/Asp.Net.WebAPI/.nuget/NuGet.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exitgames/photon.custom-authentication/a9c58ad3dc98d82fb4d1549e755af4c1e64a58e5/src/Asp.Net.WebAPI/.nuget/NuGet.exe -------------------------------------------------------------------------------- /src/Asp.Net.WebAPI/.nuget/NuGet.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $(MSBuildProjectDirectory)\..\ 5 | 6 | 7 | false 8 | 9 | 10 | false 11 | 12 | 13 | true 14 | 15 | 16 | false 17 | 18 | 19 | 20 | 21 | 22 | 26 | 27 | 28 | 29 | 30 | $([System.IO.Path]::Combine($(SolutionDir), ".nuget")) 31 | $([System.IO.Path]::Combine($(ProjectDir), "packages.config")) 32 | 33 | 34 | 35 | 36 | $(SolutionDir).nuget 37 | packages.config 38 | 39 | 40 | 41 | 42 | $(NuGetToolsPath)\NuGet.exe 43 | @(PackageSource) 44 | 45 | "$(NuGetExePath)" 46 | mono --runtime=v4.0.30319 $(NuGetExePath) 47 | 48 | $(TargetDir.Trim('\\')) 49 | 50 | -RequireConsent 51 | -NonInteractive 52 | 53 | 54 | $(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir "$(SolutionDir) " 55 | $(NuGetCommand) pack "$(ProjectPath)" -Properties Configuration=$(Configuration) $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols 56 | 57 | 58 | 59 | RestorePackages; 60 | $(BuildDependsOn); 61 | 62 | 63 | 64 | 65 | $(BuildDependsOn); 66 | BuildPackage; 67 | 68 | 69 | 70 | 71 | 72 | 73 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 88 | 89 | 92 | 93 | 94 | 95 | 97 | 98 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 130 | 131 | 132 | 133 | -------------------------------------------------------------------------------- /src/Asp.Net.WebAPI/ExitGames.Authentication.Service.WebAPI.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2012 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExitGames.Web.Sample", "ExitGames.Web.Sample\ExitGames.Web.Sample.csproj", "{533F2A24-1ABC-4D8A-AFAF-D3C82AEBC0FA}" 5 | EndProject 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{D5F7A609-5724-45CF-8B01-0F62157AF355}" 7 | ProjectSection(SolutionItems) = preProject 8 | .nuget\NuGet.Config = .nuget\NuGet.Config 9 | .nuget\NuGet.exe = .nuget\NuGet.exe 10 | .nuget\NuGet.targets = .nuget\NuGet.targets 11 | EndProjectSection 12 | EndProject 13 | Global 14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 15 | Debug|Any CPU = Debug|Any CPU 16 | Release|Any CPU = Release|Any CPU 17 | EndGlobalSection 18 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 19 | {533F2A24-1ABC-4D8A-AFAF-D3C82AEBC0FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 20 | {533F2A24-1ABC-4D8A-AFAF-D3C82AEBC0FA}.Debug|Any CPU.Build.0 = Debug|Any CPU 21 | {533F2A24-1ABC-4D8A-AFAF-D3C82AEBC0FA}.Release|Any CPU.ActiveCfg = Release|Any CPU 22 | {533F2A24-1ABC-4D8A-AFAF-D3C82AEBC0FA}.Release|Any CPU.Build.0 = Release|Any CPU 23 | EndGlobalSection 24 | GlobalSection(SolutionProperties) = preSolution 25 | HideSolutionNode = FALSE 26 | EndGlobalSection 27 | EndGlobal 28 | -------------------------------------------------------------------------------- /src/Asp.Net.WebAPI/ExitGames.Authentication.Service.WebAPI.sln.DotSettings: -------------------------------------------------------------------------------- 1 |  2 | 140 3 | True -------------------------------------------------------------------------------- /src/Asp.Net.WebAPI/ExitGames.Web.Sample/App_Start/FilterConfig.cs: -------------------------------------------------------------------------------- 1 | namespace ExitGames.Web.Sample 2 | { 3 | using System.Web.Mvc; 4 | 5 | public class FilterConfig 6 | { 7 | public static void RegisterGlobalFilters(GlobalFilterCollection filters) 8 | { 9 | filters.Add(new HandleErrorAttribute()); 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /src/Asp.Net.WebAPI/ExitGames.Web.Sample/App_Start/WebApiConfig.cs: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Exit Games GmbH. All rights reserved. 4 | // 5 | // 6 | // Defines the WebApiConfig type. 7 | // 8 | // -------------------------------------------------------------------------------------------------------------------- 9 | 10 | namespace ExitGames.Web.Sample 11 | { 12 | using System.Linq; 13 | using System.Web.Http; 14 | 15 | public static class WebApiConfig 16 | { 17 | public static void Register(HttpConfiguration config) 18 | { 19 | config.Routes.MapHttpRoute( 20 | name: "Authenticate", 21 | routeTemplate: "api/client/authenticate/{userName}/{token}", 22 | defaults: new { controller = "Client", action = "Authenticate" }); 23 | config.Routes.MapHttpRoute( 24 | name: "Authenticate2", 25 | routeTemplate: "client/authenticate/{userName}/{token}", 26 | defaults: new { controller = "Client", action = "Authenticate" }); 27 | 28 | config.Routes.MapHttpRoute( 29 | name: "DefaultApi", 30 | routeTemplate: "api/{controller}/{id}", 31 | defaults: new { id = RouteParameter.Optional }); 32 | config.Routes.MapHttpRoute( 33 | name: "DefaultApi2", 34 | routeTemplate: "{controller}/{id}", 35 | defaults: new { id = RouteParameter.Optional }); 36 | 37 | // return JSON by default - to get XML add the "text/xml" accept header at the client request 38 | var appXmlType = config.Formatters.XmlFormatter.SupportedMediaTypes.FirstOrDefault(t => t.MediaType == "application/xml"); 39 | config.Formatters.XmlFormatter.SupportedMediaTypes.Remove(appXmlType); 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /src/Asp.Net.WebAPI/ExitGames.Web.Sample/Controllers/ClientController.cs: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Exit Games GmbH. All rights reserved. 4 | // 5 | // 6 | // Defines the ClientController type. 7 | // 8 | // -------------------------------------------------------------------------------------------------------------------- 9 | 10 | namespace ExitGames.Web.Sample.Controllers 11 | { 12 | using System.Web.Http; 13 | 14 | using ExitGames.Web.Sample.Models; 15 | using ExitGames.Web.Sample.Services; 16 | 17 | // TODO be sure to use SSL in production 18 | //[RequireHttps] 19 | public class ClientController : ApiController 20 | { 21 | public ClientController() 22 | : this(null) 23 | { 24 | } 25 | 26 | public ClientController(IClientAuthenticationService authenticationService) 27 | { 28 | this.AuthenticationService = authenticationService ?? new ClientAuthenticationService(); 29 | } 30 | 31 | public IClientAuthenticationService AuthenticationService { get; private set; } 32 | 33 | //// Example calls with results according to current routing setup: 34 | //// http://dev-customauth.exitgames.com/api/client/authenticate/yes/yes -> 1 35 | //// http://dev-customauth.exitgames.com/api/client/authenticate/yes/no -> 2 36 | //// http://dev-customauth.exitgames.com/api/client/authenticate?username=yes&token=yes -> 1 37 | //// http://dev-customauth.exitgames.com/api/client/authenticate?username=yes&token=no -> 2 38 | //// http://dev-customauth.exitgames.com/api/client/authenticate -> 3 Parameter invalid (404 for WebAPI) 39 | //// http://dev-customauth.exitgames.com/api/client/authenticate?username=&token= -> 3 Parameter invalid (OK for WebAPI) 40 | 41 | /// 42 | /// Authenticates a user with the given credentials. 43 | /// 44 | /// Name of user to authenticate. 45 | /// Token to authenticate user with. 46 | /// Result of authentication. 47 | [AcceptVerbs("GET")] 48 | public Result Authenticate(string userName, string token) 49 | { 50 | if (string.IsNullOrWhiteSpace(userName) || string.IsNullOrWhiteSpace(token)) 51 | { 52 | var resultErrorInput = new Result { ResultCode = 3, Message = "Parameter invalid" }; 53 | return resultErrorInput; 54 | } 55 | 56 | bool authenticated = this.AuthenticationService.Authenticate(userName, token); 57 | if (authenticated) 58 | { 59 | // authentication ok 60 | var resultOk = new Result { ResultCode = 1 }; 61 | return resultOk; 62 | } 63 | 64 | // authentication failed 65 | var resultError = new Result 66 | { 67 | ResultCode = 2, 68 | ////Message = "whatever reason" // optional 69 | }; 70 | return resultError; 71 | } 72 | } 73 | } -------------------------------------------------------------------------------- /src/Asp.Net.WebAPI/ExitGames.Web.Sample/ExitGames.Web.Sample.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | 8 | 9 | 2.0 10 | {533F2A24-1ABC-4D8A-AFAF-D3C82AEBC0FA} 11 | {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} 12 | Library 13 | Properties 14 | ExitGames.Web.Sample 15 | ExitGames.Web.Sample 16 | v4.5 17 | false 18 | true 19 | 20 | 21 | 22 | 23 | ..\ 24 | true 25 | 26 | 27 | true 28 | full 29 | false 30 | bin\ 31 | DEBUG;TRACE 32 | prompt 33 | 4 34 | 35 | 36 | pdbonly 37 | true 38 | bin\ 39 | TRACE 40 | prompt 41 | 4 42 | 43 | 44 | 45 | ..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll 46 | True 47 | 48 | 49 | 50 | ..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll 51 | True 52 | 53 | 54 | 55 | ..\packages\Microsoft.AspNet.WebApi.Core.5.2.3\lib\net45\System.Web.Http.dll 56 | True 57 | 58 | 59 | ..\packages\Microsoft.AspNet.WebApi.WebHost.5.2.3\lib\net45\System.Web.Http.WebHost.dll 60 | True 61 | 62 | 63 | ..\packages\Microsoft.AspNet.Mvc.5.2.3\lib\net45\System.Web.Mvc.dll 64 | True 65 | 66 | 67 | ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.dll 68 | True 69 | 70 | 71 | ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Razor.dll 72 | True 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | Global.asax 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | Web.config 100 | 101 | 102 | Web.config 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 10.0 117 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | True 130 | True 131 | 4591 132 | / 133 | http://localhost:5556/ 134 | False 135 | False 136 | 137 | 138 | False 139 | 140 | 141 | 142 | 143 | 144 | 150 | -------------------------------------------------------------------------------- /src/Asp.Net.WebAPI/ExitGames.Web.Sample/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Codebehind="Global.asax.cs" Inherits="ExitGames.Web.Sample.MvcApplication" Language="C#" %> 2 | -------------------------------------------------------------------------------- /src/Asp.Net.WebAPI/ExitGames.Web.Sample/Global.asax.cs: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Exit Games GmbH. All rights reserved. 4 | // 5 | // 6 | // Defines the MvcApplication type. 7 | // 8 | // -------------------------------------------------------------------------------------------------------------------- 9 | 10 | namespace ExitGames.Web.Sample 11 | { 12 | using System.Web.Http; 13 | using System.Web.Mvc; 14 | 15 | // Note: For instructions on enabling IIS6 or IIS7 classic mode, 16 | // visit http://go.microsoft.com/?LinkId=9394801 17 | public class MvcApplication : System.Web.HttpApplication 18 | { 19 | protected void Application_Start() 20 | { 21 | //AreaRegistration.RegisterAllAreas(); 22 | 23 | WebApiConfig.Register(GlobalConfiguration.Configuration); 24 | FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /src/Asp.Net.WebAPI/ExitGames.Web.Sample/Models/Result.cs: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Exit Games GmbH. All rights reserved. 4 | // 5 | // 6 | // Defines the Result type. 7 | // 8 | // -------------------------------------------------------------------------------------------------------------------- 9 | 10 | namespace ExitGames.Web.Sample.Models 11 | { 12 | public class Result 13 | { 14 | public int ResultCode { get; set; } 15 | 16 | public string Message { get; set; } 17 | } 18 | } -------------------------------------------------------------------------------- /src/Asp.Net.WebAPI/ExitGames.Web.Sample/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ExitGames.Web.Sample")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Exit Games GmbH")] 12 | [assembly: AssemblyProduct("ExitGames.Web.Sample")] 13 | [assembly: AssemblyCopyright("Copyright © 2013")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("d2cfdb90-8762-4aec-854a-27dd39210a26")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /src/Asp.Net.WebAPI/ExitGames.Web.Sample/Properties/PublishProfiles/filesystem.pubxml: -------------------------------------------------------------------------------- 1 |  2 | 6 | 7 | 8 | FileSystem 9 | Debug 10 | Any CPU 11 | 12 | False 13 | ..\deploy 14 | True 15 | 16 | -------------------------------------------------------------------------------- /src/Asp.Net.WebAPI/ExitGames.Web.Sample/Services/ClientAuthenticationService.cs: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Exit Games GmbH. All rights reserved. 4 | // 5 | // 6 | // Defines the ClientAuthenticationService type. 7 | // 8 | // -------------------------------------------------------------------------------------------------------------------- 9 | 10 | namespace ExitGames.Web.Sample.Services 11 | { 12 | public class ClientAuthenticationService : IClientAuthenticationService 13 | { 14 | private readonly IUserRepository userRepository; 15 | 16 | public ClientAuthenticationService() 17 | : this(null) 18 | { 19 | } 20 | 21 | public ClientAuthenticationService(IUserRepository repository) 22 | { 23 | this.userRepository = repository ?? new UserRepository(); 24 | } 25 | 26 | public bool Authenticate(string userName, string token) 27 | { 28 | // TODO use repository to get user and authenticate 29 | if (userName == token) 30 | { 31 | return true; 32 | } 33 | 34 | return false; 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /src/Asp.Net.WebAPI/ExitGames.Web.Sample/Services/IClientAuthenticationService.cs: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Exit Games GmbH. All rights reserved. 4 | // 5 | // 6 | // Defines the IClientAuthenticationService type. 7 | // 8 | // -------------------------------------------------------------------------------------------------------------------- 9 | 10 | namespace ExitGames.Web.Sample.Services 11 | { 12 | public interface IClientAuthenticationService 13 | { 14 | bool Authenticate(string userName, string token); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/Asp.Net.WebAPI/ExitGames.Web.Sample/Services/IUserRepository.cs: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Exit Games GmbH. All rights reserved. 4 | // 5 | // 6 | // Defines the IUserRepository type. 7 | // 8 | // -------------------------------------------------------------------------------------------------------------------- 9 | 10 | namespace ExitGames.Web.Sample.Services 11 | { 12 | public interface IUserRepository 13 | { 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/Asp.Net.WebAPI/ExitGames.Web.Sample/Services/UserRepository.cs: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Exit Games GmbH. All rights reserved. 4 | // 5 | // 6 | // Defines the UserRepository type. 7 | // 8 | // -------------------------------------------------------------------------------------------------------------------- 9 | 10 | namespace ExitGames.Web.Sample.Services 11 | { 12 | public class UserRepository : IUserRepository 13 | { 14 | } 15 | } -------------------------------------------------------------------------------- /src/Asp.Net.WebAPI/ExitGames.Web.Sample/Settings.StyleCop: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/Asp.Net.WebAPI/ExitGames.Web.Sample/Views/Web.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 |
7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 39 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /src/Asp.Net.WebAPI/ExitGames.Web.Sample/Web.Debug.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | -------------------------------------------------------------------------------- /src/Asp.Net.WebAPI/ExitGames.Web.Sample/Web.Release.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | -------------------------------------------------------------------------------- /src/Asp.Net.WebAPI/ExitGames.Web.Sample/Web.config: -------------------------------------------------------------------------------- 1 |  2 | 6 | 7 | 8 | 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 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /src/Asp.Net.WebAPI/ExitGames.Web.Sample/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/Asp.Net.WebAPI/Settings.StyleCop: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Exit Games GmbH 6 | Copyright (c) Exit Games GmbH. All rights reserved. 7 | 8 | 9 | 10 | 11 | False 12 | 13 | 14 | 15 | 16 | 17 | 18 | --------------------------------------------------------------------------------