コード例 #1
0
    def get(self, request):
        """Handles GET requests for the /token/ endpoint."""
        try:
            service = request.query_params["service"]
        except KeyError:
            raise ParseError(detail="No service name provided.")
        scope = request.query_params.get("scope", "")

        authorization_service = AuthorizationService(self.request.user, service, scope)
        data = authorization_service.generate_token()
        return Response(data=data)
コード例 #2
0
ファイル: registry_api.py プロジェクト: ekohl/pulp_container
    def get(self, request):
        """Handles GET requests for the /token/ endpoint."""
        account = request.query_params.get("account", self.ANONYMOUS_USER)
        try:
            service = request.query_params["service"]
        except KeyError:
            raise ParseError(detail="No service name provided.")
        scope = request.query_params.get("scope", self.EMPTY_ACCESS_SCOPE)

        if account != self.ANONYMOUS_USER:
            if not request.user.is_authenticated:
                raise ParseError(detail="Authentication failed.")
            if account != request.user.username:
                raise ParseError(detail="Username mismatch.")

        data = AuthorizationService().generate_token(account, service, scope)
        return Response(data=data)
コード例 #3
0
from aiohttp import web

from pulpcore.content import app
from pulp_container.app.authorization import AuthorizationService
from pulp_container.app.registry import Registry

registry = Registry()

app.add_routes([web.get('/v2/', registry.serve_v2)])
app.add_routes([web.get('/v2/_catalog', registry.list_repositories)])
app.add_routes([
    web.get(r'/v2/{path:.+}/blobs/sha256:{digest:.+}', registry.get_by_digest)
])
app.add_routes([
    web.get(r'/v2/{path:.+}/manifests/sha256:{digest:.+}',
            registry.get_by_digest)
])
app.add_routes(
    [web.get(r'/v2/{path:.+}/manifests/{tag_name}', registry.get_tag)])
app.add_routes([web.get(r'/v2/{path:.+}/tags/list', registry.tags_list)])

authorization_service = AuthorizationService()

app.add_routes([web.get('/token', authorization_service.generate_token)])