Esempio n. 1
0
        public OAuthContext(string realm, OAuthOptions options)
        {
            Realm = realm;

            // Store options
            Options = options;

            // Create services
            Services = new OAuthServicesContext(
                options.UserService,
                options.ClientStore,
                options.RefreshTokenStore,
                new JwtTokenService(options.SymmetricKey));
        }
Esempio n. 2
0
        public static void ConfigureEndpoint(string realm, string path, OAuthOptions options)
        {
            if (!_contexts.ContainsKey(realm))
            {
                if (_contexts.TryAdd(realm, new OAuthContext(realm, options)))
                {
                    GlobalConfiguration.Configuration.Routes.MapHttpRoute(
                        "OAuth_" + realm,
                        path.TrimStart('~', '/'),
                        new
                    {
                        controller = "OAuth",
                        action     = "Token",
                        realm
                    });

                    return;
                }
            }

            throw new Exception($"An endpoint for the realm \"{realm}\" has already been configured.");
        }
Esempio n. 3
0
 public static void ConfigureEndpoint(string path, OAuthOptions config)
 {
     ConfigureEndpoint(DefaultRealm, path, config);
 }
Esempio n. 4
0
 public static void ConfigureEndpoint(OAuthOptions config)
 {
     ConfigureEndpoint(DefaultRealm, DefaultEndpointPath, config);
 }