Commit 5fc0a98c authored by Sofia Papagiannaki's avatar Sofia Papagiannaki
Browse files

astakos oa2: Restrict redirect URI length during client registration.

Apply the check in the oauth2-client-add snf-manage command.

Refs: #4804
parent f119503c
......@@ -39,6 +39,7 @@ from import CommandError
from import SynnefoCommand
from astakos.oa2.models import Client, RedirectUrl
from astakos.oa2 import settings
class Command(SynnefoCommand):
......@@ -74,7 +75,16 @@ class Command(SynnefoCommand):
if len(args) != 1:
raise CommandError("Invalid number of arguments")
if not options['urls']:
urls = filter(lambda u: len(u) <
if len(options['urls']) != len(urls):
self.stdout.write('The following urls are over the allowed limit '
'and are going to be ignored: %s\n' %
','.join(set(options['urls']) - set(urls)))
if not urls:
raise CommandError("There should be at least one redirect URI")
identifier = args[0].decode('utf8')
......@@ -84,7 +94,7 @@ class Command(SynnefoCommand):
type=options['type'], is_trusted=options['is_trusted'])
c.redirecturl_set.bulk_create((RedirectUrl(client=c, url=url) for
url in options['urls']))
url in urls))
except BaseException, e:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment