Пример #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));
        }
Пример #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.");
        }
Пример #3
0
 public static void ConfigureEndpoint(string path, OAuthOptions config)
 {
     ConfigureEndpoint(DefaultRealm, path, config);
 }
Пример #4
0
 public static void ConfigureEndpoint(OAuthOptions config)
 {
     ConfigureEndpoint(DefaultRealm, DefaultEndpointPath, config);
 }