/// <summary>
		/// Requests the specified provider to start the authentication by directing users to an external website
		/// </summary>
		/// <param name="returnUrl">
		/// The return url after user is authenticated. 
		/// </param>
		/// <param name="state">
		/// Additional state to be passed on the return url.
		/// </param>
		public void RequestAuthentication(string returnUrl, StateDictionary state = null) {
		    state = state ?? new StateDictionary();

			// convert returnUrl to an absolute path
			Uri uri;
			if (!string.IsNullOrEmpty(returnUrl)) {
				uri = UriHelper.ConvertToAbsoluteUri(returnUrl, this.requestContext);
			}
			else {
				uri = this.requestContext.Request.GetPublicFacingUrl();
			}

			// attach the provider parameter so that we know which provider initiated 
			// the login when user is redirected back to this page
			// Guard against XSRF attack by injecting session id into the redirect url and response cookie.
			// Upon returning from the external provider, we'll compare the session id value in the query 
			// string and the cookie. If they don't match, we'll reject the request.
			string sessionId = Guid.NewGuid().ToString("N");
            state.Add(ProviderQueryStringName, this.authenticationProvider.ProviderName);
            state.Add(SessionIdQueryStringName, sessionId);

			// The cookie value will be the current username secured against the session id we just created.
			byte[] encryptedCookieBytes = MachineKeyUtil.Protect(Encoding.UTF8.GetBytes(GetUsername(this.requestContext)), AntiXsrfPurposeString, "Token: " + sessionId);

			var xsrfCookie = new HttpCookie(SessionIdCookieName, HttpServerUtility.UrlTokenEncode(encryptedCookieBytes)) {
				HttpOnly = true
			};
			if (FormsAuthentication.RequireSSL) {
				xsrfCookie.Secure = true;
			}
			this.requestContext.Response.Cookies.Add(xsrfCookie);

			// issue the redirect to the external auth provider
			this.authenticationProvider.RequestAuthentication(this.requestContext, uri, state);
		}
Exemple #2
0
 /// <summary>
 /// ステートと子要素のPresenterを紐づける。
 /// あるステートに状態遷移した時、結びつけられた子要素のPresenterが呼び出される。
 /// </summary>
 private void BindState()
 {
     StateDictionary.Add(GroupState.Title, titlePresenter);
     StateDictionary.Add(GroupState.Lobby, lobbyPresenter);
     StateDictionary.Add(GroupState.Game, gamePresenter);
 }
Exemple #3
0
        private static StateDictionary CreateState(object target)
        {
            StateDictionary ret = new StateDictionary();

            IChildObject child = target as IChildObject;

            if (child != null)
            {
                ret.Add("parent", child.Parent);
            }

            return ret;
        }
        /// <summary>
        /// Registers an action to a state.
        /// </summary>
        /// <param name="state">The target state.</param>
        /// <param name="action">The action to be invoked.</param>
        /// <param name="direction">The directional constraint.</param>
        /// <param name="condition">The conditional constraint.</param>
        public void AddStateAction(S state, Action action, TransitionDirection direction = TransitionDirection.Enter, TransitionCondition condition = TransitionCondition.Always)
        {
            ActionInfo actionInfo = new ActionInfo(action);

            stateActions.Add(state, actionInfo, direction, condition);
        }
Exemple #5
0
 private void BindState()
 {
     StateDictionary.Add(GameState.Ready, readyPresenter);
     StateDictionary.Add(GameState.Play, playPresenter);
     StateDictionary.Add(GameState.Result, resultPresenter);
 }
 /// <summary>
 /// ステートと子要素のPresenterを紐づける。
 /// あるステートに状態遷移した時、結びつけられた子要素のPresenterが呼び出される。
 /// </summary>
 private void BindState()
 {
     StateDictionary.Add(LobbyState.JoinRoom, joinRoomPresenter);
     StateDictionary.Add(LobbyState.EditPlayerName, editPlayerNamePresenter);
     StateDictionary.Add(LobbyState.CreateRoom, createRoomPresenter);
 }