Exemple #1
0
 def handle_github(self, data):
     self.send_response(302)
     c = Client(auth_endpoint='https://github.com/login/oauth/authorize',
             client_id=config['github.client_id'],
             redirect_uri='http://localhost/login/github')
     self.send_header('Location', c.auth_uri())
     self.end_headers()
Exemple #2
0
	def handle_bitly(self, data):
		self.send_response(302)
		c = Client(auth_endpoint="https://bitly.com/oauth/authorize",
				client_id=config["bitly.client_id"],
				redirect_uri="http://localhost:8080/login/bitly")
		self.send_header("Location", c.auth_uri())
		self.end_headers()
Exemple #3
0
	def handle_instagram(self, data):
		self.send_response(302)
		c = Client(auth_endpoint="https://api.instagram.com/oauth/authorize/",
				client_id=config["instagram.client_id"],
				redirect_uri="http://localhost:8080/login/instagram")
		self.send_header("Location", c.auth_uri())
		self.end_headers()
Exemple #4
0
 def handle_instagram(self, data):
     self.send_response(302)
     c = Client(auth_endpoint='https://api.instagram.com/oauth/authorize/',
             client_id=config['instagram.client_id'],
             redirect_uri='http://localhost/login/instagram')
     self.send_header('Location', c.auth_uri())
     self.end_headers()
Exemple #5
0
	def handle_foursquare(self, data):
		self.send_response(302)
		c = Client(auth_endpoint="https://foursquare.com/oauth2/authenticate",
				client_id=config["foursquare.client_id"],
				redirect_uri="http://localhost:8080/login/foursquare")
		self.send_header("Location", c.auth_uri())
		self.end_headers()
Exemple #6
0
 def handle_github(self, data):
     self.send_response(302)
     c = Client(auth_endpoint="https://github.com/login/oauth/authorize",
             client_id=config["github.client_id"],
             redirect_uri="http://localhost/login/github")
     self.send_header("Location", c.auth_uri())
     self.end_headers()
Exemple #7
0
 def handle_stackexchange(self, data):
     self.send_response(302)
     c = Client(auth_endpoint="https://stackexchange.com/oauth",
         client_id=config["stackexchange.client_id"],
         redirect_uri="http://localhost/login/stackexchange")
     self.send_header("Location", c.auth_uri())
     self.end_headers()
Exemple #8
0
 def handle_stackexchange(self, data):
     self.send_response(302)
     c = Client(auth_endpoint='https://stackexchange.com/oauth',
         client_id=config['stackexchange.client_id'],
         redirect_uri='http://localhost/login/stackexchange')
     self.send_header('Location', c.auth_uri())
     self.end_headers()
Exemple #9
0
 def handle_foursquare(self, data):
     self.send_response(302)
     c = Client(auth_endpoint='https://foursquare.com/oauth2/authenticate',
             client_id=config['foursquare.client_id'],
             redirect_uri='http://localhost/login/foursquare')
     self.send_header('Location', c.auth_uri())
     self.end_headers()
Exemple #10
0
 def handle_google(self, data):
     self.send_response(302)
     c = Client(auth_endpoint="https://accounts.google.com/o/oauth2/auth",
         client_id=config["google.client_id"],
         redirect_uri="http://localhost/login/google")
     self.send_header("Location", c.auth_uri(
         scope=config["google.scope"].split(","), access_type="offline"))    
     self.end_headers()
Exemple #11
0
 def handle_deviantart(self, data):
     self.send_response(302)
     c = Client(
         auth_endpoint='https://www.deviantart.com/oauth2/draft15/authorize',
         client_id=config['deviantart.client_id'],
         redirect_uri=config['deviantart.redirect_uri'])
     self.send_header('Location', c.auth_uri())
     self.end_headers()
Exemple #12
0
 def handle_google(self, data):
     self.send_response(302)
     c = Client(auth_endpoint='https://accounts.google.com/o/oauth2/auth',
         client_id=config['google.client_id'],
         redirect_uri='http://localhost/login/google')
     self.send_header('Location', c.auth_uri(
         scope=config['google.scope'].split(','), access_type='offline'))    
     self.end_headers()
Exemple #13
0
 def handle_facebook(self, data):
     self.send_response(302)
     c = Client(auth_endpoint="https://www.facebook.com/dialog/oauth",
             client_id=config["facebook.client_id"],
             redirect_uri="http://localhost/login/facebook")
     self.send_header("Location", c.auth_uri(
         scope=config["facebook.scope"].split(","),
         scope_delim=","))
     self.end_headers()
Exemple #14
0
 def handle_facebook(self, data):
     self.send_response(302)
     c = Client(auth_endpoint='https://www.facebook.com/dialog/oauth',
             client_id=config['facebook.client_id'],
             redirect_uri='http://localhost/login/facebook')
     self.send_header('Location', c.auth_uri(
         scope=config['facebook.scope'].split(','),
         scope_delim=','))
     self.end_headers()
Exemple #15
0
def get_oauth2_starter_url(provider_name, csrf_token):
    """returns redirect url for the oauth2 protocol for a given provider"""
    from sanction.client import Client

    providers = get_enabled_login_providers()
    params = providers[provider_name]
    client_id = getattr(askbot_settings, provider_name.replace("-", "_").upper() + "_KEY")
    redirect_uri = site_url(reverse("user_complete_oauth2_signin"))
    client = Client(auth_endpoint=params["auth_endpoint"], client_id=client_id, redirect_uri=redirect_uri)
    return client.auth_uri(state=csrf_token, **params.get("extra_auth_params", {}))
Exemple #16
0
    def test_get_auth_uri(self):
        c = Client(auth_endpoint = auth_endpoint,
            client_id = client_id)
        uri = c.auth_uri()

        o = urlparse(uri)
        self.assertEquals(o.netloc, "example.com")
        d = dict(parse_qsl(o.query))

        self.assertEquals(d["response_type"], "code")
        self.assertEquals(d["client_id"], client_id)
Exemple #17
0
def get_oauth2_starter_url(provider_name, csrf_token):
    """returns redirect url for the oauth2 protocol for a given provider"""
    from sanction.client import Client

    providers = get_enabled_login_providers()
    params = providers[provider_name]
    client_id = getattr(askbot_settings, provider_name.upper() + '_KEY')
    redirect_uri = site_url(reverse('user_complete_oauth2_signin'))
    client = Client(auth_endpoint=params['auth_endpoint'],
                    client_id=client_id,
                    redirect_uri=redirect_uri)
    return client.auth_uri(state=csrf_token)
Exemple #18
0
def get_oauth2_starter_url(provider_name):
    """returns redirect url for the oauth2 protocol for a given provider"""
    from sanction.client import Client
    providers = get_enabled_login_providers()
    params = providers[provider_name]
    client_id = getattr(askbot_settings, provider_name.upper() + '_KEY')
    redirect_uri = askbot_settings.APP_URL + reverse('user_complete_oauth2_signin')
    client = Client(
        auth_endpoint=params['auth_endpoint'],
        client_id=client_id,
        redirect_uri=redirect_uri
    )
    return client.auth_uri()
Exemple #19
0
def get_oauth2_starter_url(provider_name, csrf_token):
    """returns redirect url for the oauth2 protocol for a given provider"""
    from sanction.client import Client

    providers = get_enabled_login_providers()
    params = providers[provider_name]
    client_id = getattr(askbot_settings, format_setting_name(provider_name) + '_KEY')
    redirect_uri = site_url(reverse('user_complete_oauth2_signin'))
    client = Client(
        auth_endpoint=params['auth_endpoint'],
        client_id=client_id,
        redirect_uri=redirect_uri
    )
    return client.auth_uri(state=csrf_token, **params.get('extra_auth_params', {}))
Exemple #20
0
def get_oauth2_starter_url(provider_name, csrf_token):
    """returns redirect url for the oauth2 protocol for a given provider"""
    from sanction.client import Client

    providers = get_enabled_login_providers()
    params = providers[provider_name]
    client_id = getattr(askbot_settings, provider_name.upper() + '_KEY')
    redirect_uri = site_url(reverse('user_complete_oauth2_signin'))
    #qq = redirect_uri.split(':')
    #nurl = qq[0]+':'+qq[1]+qq[2][qq[2].find('/'):]
    #redirect_uri=nurl
    client = Client(
        auth_endpoint=params['auth_endpoint'],
        client_id=client_id,
        redirect_uri=redirect_uri
    )
    return client.auth_uri(state=csrf_token)
Exemple #21
0
def _redirect(request, provider):
    p = settings.SANCTION_PROVIDERS[provider]
    c = SanctionClient(auth_endpoint=p['auth_endpoint'],
        client_id=p['client_id'], redirect_uri=p['redirect_uri'])

    kwargs = p.get('auth_params', {})
    response = redirect(c.auth_uri(p['scope'] if 'scope' in p else None, **kwargs))

    # inject the state query param
    if getattr(settings, 'SANCTION_USE_CSRF', True):
        CsrfViewMiddleware().process_view(request, response, [], {})
        url = list(urlparse(response['location']))
        urlp = dict(parse_qsl(url[4]))
        urlp.update({'state': csrf.get_token(request)})
        url[4] = urlencode(urlp)
        response['location'] = urlunparse(url)

    return response
Exemple #22
0
def _redirect(request, provider):
    p = settings.SANCTION_PROVIDERS[provider]
    c = SanctionClient(auth_endpoint=p['auth_endpoint'],
                       client_id=p['client_id'],
                       redirect_uri=p['redirect_uri'])

    kwargs = p.get('auth_params', {})
    response = redirect(
        c.auth_uri(p['scope'] if 'scope' in p else None, **kwargs))

    # inject the state query param
    if getattr(settings, 'SANCTION_USE_CSRF', True):
        CsrfViewMiddleware().process_view(request, response, [], {})
        url = list(urlparse(response['location']))
        urlp = dict(parse_qsl(url[4]))
        urlp.update({'state': csrf.get_token(request)})
        url[4] = urlencode(urlp)
        response['location'] = urlunparse(url)

    return response
Exemple #23
0
def login():
    client = Client(auth_endpoint='https://api.sandbox.slcedu.org/api/oauth/authorize',
        client_id=client_id, redirect_uri='http://slcgoals.cloudapp.net/callback')
    return redirect(client.auth_uri())