Example #1
0
        public void Init(HttpApplication context)
        {
            context.AuthenticateRequest += (sender, e) =>
            {
                HttpContext httpContext = ((HttpApplication)sender).Context;

                dynamic signedRequest = FacebookRequestHelpers.GetSignedRequest(
                    new HttpContextWrapper(httpContext),
                    rawSignedRequest =>
                {
                    FacebookConfiguration config = GlobalFacebookConfiguration.Configuration;
                    FacebookClient client        = config.ClientProvider.CreateClient();
                    return(client.ParseSignedRequest(rawSignedRequest));
                });

                if (signedRequest != null)
                {
                    string userId = signedRequest.user_id;
                    if (!String.IsNullOrEmpty(userId))
                    {
                        ClaimsPrincipal principal = new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.NameIdentifier, userId) }));
                        Thread.CurrentPrincipal = principal;
                        httpContext.User        = principal;
                    }
                }
            };
        }
Example #2
0
        public static void Register(FacebookConfiguration configuration)
        {
            // Charge les paramètres du fichier web.config à l’aide des clés de paramètres d’application suivantes :
            // Facebook:AppId, Facebook:AppSecret, Facebook:AppNamespace
            configuration.LoadFromAppSettings();

            // Ajout du filtre d’autorisation pour rechercher les demandes et autorisations signées de Facebook
            GlobalFilters.Filters.Add(new MyFacebookAuthorizeFilter(configuration));
        }
Example #3
0
        public static void Register(FacebookConfiguration configuration)
        {
            // Loads the settings from web.config using the following app setting keys:
            // Facebook:AppId, Facebook:AppSecret, Facebook:AppNamespace
            configuration.LoadFromAppSettings();

            // Adding the authorization filter to check for Facebook signed requests and permissions
            GlobalFilters.Filters.Add(new FacebookAuthorizeFilter(configuration));
        }
Example #4
0
 public MyFacebookAuthorizeFilter(FacebookConfiguration config)
     : base(config)
 {
     _config = config;
 }