Ejemplo n.º 1
0
    def put(self, account):
        """
        Create a new identity and map it to an account.

        .. :quickref: GSS; add new GSS identity.

        :param account: the affected account.
        :reqheader X-Rucio-Email: the desired email.
        :status 201: Created.
        :status 401: Invalid Auth Token.
        """
        gsscred = request.environ.get('REMOTE_USER')
        email = request.headers.get('X-Rucio-Email', default=None)

        add_identity(gsscred, 'gss', email=email)
        add_account_identity(
            identity_key=gsscred,
            id_type='gss',
            account=account,
            email=email,
            issuer=request.environ.get('issuer'),
            vo=request.environ.get('vo'),
        )

        return 'Created', 201
Ejemplo n.º 2
0
    def put(self, account):
        """
        Create a new identity and map it to an account.

        .. :quickref: GSS; add new GSS identity.

        :param account: the affected account.
        :reqheader X-Rucio-Email: the desired email.
        :status 201: Created.
        :status 401: Invalid Auth Token.
        :status 500: Internal Error.
        """
        gsscred = request.environ.get('REMOTE_USER')
        email = request.headers.get('X-Rucio-Email', default=None)

        try:
            add_identity(gsscred, 'gss', email=email)
        except Exception as error:
            logging.exception("Internal Error")
            return str(error), 500

        try:
            add_account_identity(gsscred, 'gss', account,
                                 email=email,
                                 issuer=request.environ.get('issuer'),
                                 vo=request.environ.get('vo'))
        except Exception as error:
            logging.exception("Internal Error")
            return str(error), 500

        return 'Created', 201
Ejemplo n.º 3
0
    def PUT(self, account):
        """
        Create a new identity and map it to an account.

        HTTP Success:
            201 Created

        HTTP Error:
            400 Bad Request
            401 Unauthorized
            500 Internal Error

        :param Rucio-Auth-Token: as an 32 character hex string.
        :param Rucio-Username: the desired username.
        :param Rucio-Password: the desired password.
        :param account: the affected account via URL.
        """
        username = ctx.env.get('HTTP_X_RUCIO_USERNAME')
        password = ctx.env.get('HTTP_X_RUCIO_PASSWORD')

        if username is None or password is None:
            raise BadRequest('Username and Password must be set.')

        try:
            add_identity(username, 'userpass', password)
        except Exception, e:
            # TODO: Proper rollback
            raise InternalError(e)
Ejemplo n.º 4
0
    def put(self, account):
        """
        Create a new identity and map it to an account.

        .. :quickref: X509; add new x509 identity.

        :param account: the affected account.
        :reqheader X-Rucio-Email: the desired email.
        :status 201: Created.
        :status 401: Invalid Auth Token.
        :status 500: Internal Error.
        """
        dn = request.environ.get('SSL_CLIENT_S_DN')
        email = request.headers.get('X-Rucio-Email')

        try:
            add_identity(dn, 'x509', email=email)
        except Exception as error:
            print(format_exc())
            return str(error), 500

        try:
            add_account_identity(dn,
                                 'x509',
                                 account,
                                 email=email,
                                 issuer=request.environ.get('issuer'),
                                 vo=request.environ.get('vo'))
        except Exception as error:
            print(format_exc())
            return str(error), 500

        return 'Created', 201
Ejemplo n.º 5
0
    def put(self, account):
        """
        Create a new identity and map it to an account.

        .. :quickref: X509; add new x509 identity.

        :param account: the affected account.
        :reqheader X-Rucio-Email: the desired email.
        :status 201: Created.
        :status 401: Invalid Auth Token.
        :status 500: Internal Error.
        """
        dn = request.environ.get('SSL_CLIENT_S_DN')
        email = request.environ.get('HTTP_X_RUCIO_EMAIL')

        try:
            add_identity(dn, 'x509', email=email)
        except Exception as error:
            return error, 500

        try:
            add_account_identity(dn, 'x509', account,
                                 email=email, issuer=request.environ.get('issuer'))
        except Exception as error:
            return error, 500

        return "Created", 201
Ejemplo n.º 6
0
    def put(self, account):
        """
        Create a new identity and map it to an account.

        .. :quickref: GSS; add new GSS identity.

        :param account: the affected account.
        :reqheader X-Rucio-Email: the desired email.
        :status 201: Created.
        :status 401: Invalid Auth Token.
        :status 500: Internal Error.
        """
        gsscred = request.environ.get('REMOTE_USER')
        email = request.environ.get('HTTP_X_RUCIO_EMAIL')

        try:
            add_identity(gsscred, 'gss', email=email)
        except Exception as error:
            return error, 500

        try:
            add_account_identity(gsscred, 'gss', account,
                                 email=email, issuer=request.environ.get('issuer'))
        except Exception as error:
            return error, 500

        return "Created", 201
Ejemplo n.º 7
0
    def put(self, account):
        """
        Create a new identity and map it to an account.

        .. :quickref: UserPass; add new userpass identity.

        :reqheader X-Rucio-Username: the desired username.
        :reqheader X-Rucio-Password: the desired password.
        :reqheader X-Rucio-Email: the desired email.
        :param account: the affected account.
        :status 201: Created.
        :status 400: Missing username or password.
        :status 401: Invalid Auth Token.
        :status 500: Internal Error.
        """
        username = request.environ.get('HTTP_X_RUCIO_USERNAME')
        password = request.environ.get('HTTP_X_RUCIO_PASSWORD')
        email = request.environ.get('HTTP_X_RUCIO_EMAIL')

        if username is None or password is None:
            return 'Username and Password must be set.', 400

        try:
            add_identity(username, 'userpass', email, password)
        except Exception as error:
            return error, 500

        try:
            add_account_identity(username, 'userpass', account,
                                 email=email, password=password,
                                 issuer=request.environ.get('issuer'))
        except Exception as error:
            return error, 500

        return "Created", 201
Ejemplo n.º 8
0
    def PUT(self, account):
        """
        Create a new identity and map it to an account.

        HTTP Success:
            201 Created

        HTTP Error:
            400 Bad Request
            401 Unauthorized
            500 Internal Error

        :param Rucio-Auth-Token: as an 32 character hex string.
        :param Rucio-Username: the desired username.
        :param Rucio-Password: the desired password.
        :param account: the affected account via URL.
        """
        username = ctx.env.get('HTTP_X_RUCIO_USERNAME')
        password = ctx.env.get('HTTP_X_RUCIO_PASSWORD')

        if username is None or password is None:
            raise BadRequest('Username and Password must be set.')

        try:
            add_identity(username, 'userpass', password)
        except Exception, error:
            raise InternalError(error)
Ejemplo n.º 9
0
    def put(self, account):
        """
        Create a new identity and map it to an account.

        .. :quickref: X509; add new x509 identity.

        :param account: the affected account.
        :reqheader X-Rucio-Email: the desired email.
        :status 201: Created.
        :status 401: Invalid Auth Token.
        """
        dn = request.environ.get('SSL_CLIENT_S_DN')
        email = request.headers.get('X-Rucio-Email', default=None)

        add_identity(dn, 'x509', email=email)
        add_account_identity(
            identity_key=dn,
            id_type='x509',
            account=account,
            email=email,
            issuer=request.environ.get('issuer'),
            vo=request.environ.get('vo'),
        )

        return 'Created', 201
Ejemplo n.º 10
0
    def put(self, account):
        """
        Create a new identity and map it to an account.

        .. :quickref: UserPass; add new userpass identity.

        :reqheader X-Rucio-Username: the desired username.
        :reqheader X-Rucio-Password: the desired password.
        :reqheader X-Rucio-Email: the desired email.
        :param account: the affected account.
        :status 201: Created.
        :status 400: Missing username or password.
        :status 401: Invalid Auth Token.
        """
        username = request.headers.get('X-Rucio-Username', default=None)
        password = request.headers.get('X-Rucio-Password', default=None)
        email = request.headers.get('X-Rucio-Email', default=None)

        if not username or not password:
            return 'Username and Password must be set.', 400

        add_identity(username, 'userpass', email, password)

        add_account_identity(
            identity_key=username,
            id_type='userpass',
            account=account,
            email=email,
            password=password,
            issuer=request.environ.get('issuer'),
            vo=request.environ.get('vo'),
        )

        return 'Created', 201
Ejemplo n.º 11
0
    def PUT(self, account):
        """
        Create a new identity and map it to an account.

        HTTP Success:
            201 Created

        HTTP Error:
            400 Bad Request
            401 Unauthorized
            500 Internal Error

        :param Rucio-Auth-Token: as an 32 character hex string.
        :param SSLStdEnv: Apache mod_ssl SSL Standard Env Variables.
        :param Rucio-Email: the desired email.
        :param account: the affected account via URL.
        """
        dn = ctx.env.get('SSL_CLIENT_S_DN')
        email = ctx.env.get('HTTP_X_RUCIO_EMAIL')

        try:
            add_identity(dn, 'x509', email=email)
        except Exception as error:
            raise InternalError(error)

        try:
            add_account_identity(dn,
                                 'x509',
                                 account,
                                 email=email,
                                 issuer=ctx.env.get('issuer'))
        except Exception as error:
            raise InternalError(error)

        raise Created()
Ejemplo n.º 12
0
    def PUT(self, account):
        """
        Create a new identity and map it to an account.

        HTTP Success:
            201 Created

        HTTP Error:
            400 Bad Request
            401 Unauthorized
            500 Internal Error

        :param Rucio-Auth-Token: as an 32 character hex string.
        :param SavedCredentials: Apache mod_auth_kerb SavedCredentials.
        :param Rucio-Email: the desired email.
        :param account: the affected account via URL.
        """
        gsscred = ctx.env.get('REMOTE_USER')
        email = ctx.env.get('HTTP_X_RUCIO_EMAIL')

        try:
            add_identity(gsscred, 'gss', email=email)
        except Exception as error:
            raise InternalError(error)

        try:
            add_account_identity(gsscred,
                                 'gss',
                                 account,
                                 email=email,
                                 issuer=ctx.env.get('issuer'))
        except Exception as error:
            raise InternalError(error)

        raise Created()
Ejemplo n.º 13
0
    def put(self, account):
        """
        Create a new identity and map it to an account.

        .. :quickref: GSS; add new GSS identity.

        :param account: the affected account.
        :status 201: Created.
        :status 401: Invalid Auth Token.
        :status 500: Internal Error.
        """
        gsscred = request.environ.get('REMOTE_USER')
        try:
            add_identity(gsscred, 'gss', email=None)
        except Exception, error:
            return error, 500
Ejemplo n.º 14
0
    def put(self, account):
        """
        Create a new identity and map it to an account.

        .. :quickref: X509; add new x509 identity.

        :param account: the affected account.
        :status 201: Created.
        :status 401: Invalid Auth Token.
        :status 500: Internal Error.
        """
        dn = request.environ.get('SSL_CLIENT_S_DN')
        try:
            add_identity(dn, 'x509', email=None)
        except Exception, error:
            return error, 500
Ejemplo n.º 15
0
    def put(self, account):
        """
        ---
        summary: Create X509 identity
        description: Creates a new X509 identity and maps it to an account.
        tags:
          - Identity
        parameters:
        - name: account
          in: path
          description: The account for the identity.
          schema:
            type: string
          style: simple
        - name: X-Rucio-Email
          in: query
          description: The email for the identity.
          schema:
            type: string
          style: simple
          required: false
        responses:
          201:
            description: OK
            content:
              application/json:
                schema:
                  type: string
                  enum: ['Created']
          401:
            description: Invalid Auth Token
        """
        dn = request.environ.get('SSL_CLIENT_S_DN')
        email = request.headers.get('X-Rucio-Email', default=None)

        add_identity(dn, 'x509', email=email)
        add_account_identity(
            identity_key=dn,
            id_type='x509',
            account=account,
            email=email,
            issuer=request.environ.get('issuer'),
            vo=request.environ.get('vo'),
        )

        return 'Created', 201
Ejemplo n.º 16
0
    def put(self, account):
        """
        Create a new identity and map it to an account.

        .. :quickref: UserPass; add new userpass identity.

        :reqheader X-Rucio-Username: the desired username.
        :reqheader X-Rucio-Password: the desired password.
        :reqheader X-Rucio-Email: the desired email.
        :param account: the affected account.
        :status 201: Created.
        :status 400: Missing username or password.
        :status 401: Invalid Auth Token.
        :status 500: Internal Error.
        """
        username = request.headers.get('X-Rucio-Username')
        password = request.headers.get('X-Rucio-Password')
        email = request.headers.get('X-Rucio-Email')

        if not username or not password:
            return 'Username and Password must be set.', 400

        try:
            add_identity(username, 'userpass', email, password)
        except Exception as error:
            print(format_exc())
            return str(error), 500

        try:
            add_account_identity(username,
                                 'userpass',
                                 account,
                                 email=email,
                                 password=password,
                                 issuer=request.environ.get('issuer'),
                                 vo=request.environ.get('vo'))
        except Exception as error:
            print(format_exc())
            return str(error), 500

        return 'Created', 201
Ejemplo n.º 17
0
    def PUT(self, account):
        """
        Create a new identity and map it to an account.

        HTTP Success:
            201 Created

        HTTP Error:
            400 Bad Request
            401 Unauthorized
            500 Internal Error

        :param Rucio-Auth-Token: as an 32 character hex string.
        :param SSLStdEnv: Apache mod_ssl SSL Standard Env Variables.
        :param account: the affected account via URL.
        """
        dn = ctx.env.get('SSL_CLIENT_S_DN')
        try:
            add_identity(dn, 'x509', email=None)
        except Exception, error:
            raise InternalError(error)
Ejemplo n.º 18
0
    def PUT(self, account):
        """
        Create a new identity and map it to an account.

        HTTP Success:
            201 Created

        HTTP Error:
            400 Bad Request
            401 Unauthorized
            500 Internal Error

        :param Rucio-Auth-Token: as an 32 character hex string.
        :param SavedCredentials: Apache mod_auth_kerb SavedCredentials.
        :param account: the affected account via URL.
        """
        gsscred = ctx.env.get('REMOTE_USER')
        try:
            add_identity(gsscred, 'gss', email=None)
        except Exception, error:
            raise InternalError(error)
Ejemplo n.º 19
0
    def PUT(self, account):
        """
        Create a new identity and map it to an account.

        HTTP Success:
            201 Created

        HTTP Error:
            400 Bad Request
            401 Unauthorized
            500 Internal Error

        :param Rucio-Auth-Token: as an 32 character hex string.
        :param SSLStdEnv: Apache mod_ssl SSL Standard Env Variables.
        :param account: the affected account via URL.
        """
        dn = ctx.env.get('SSL_CLIENT_S_DN')
        try:
            add_identity(dn, 'x509')
        except Exception, e:
            # TODO: Proper rollback
            raise InternalError(e)
Ejemplo n.º 20
0
    def PUT(self, account):
        """
        Create a new identity and map it to an account.

        HTTP Success:
            201 Created

        HTTP Error:
            400 Bad Request
            401 Unauthorized
            500 Internal Error

        :param Rucio-Auth-Token: as an 32 character hex string.
        :param SavedCredentials: Apache mod_auth_kerb SavedCredentials.
        :param account: the affected account via URL.
        """
        gsscred = ctx.env.get('REMOTE_USER')
        try:
            add_identity(gsscred, 'gss')
        except Exception, e:
            # TODO: Proper rollback
            raise InternalError(e)
Ejemplo n.º 21
0
    def put(self, account):
        """
        ---
        summary: Create UserPass identity
        description: Creates a new UserPass identity and maps it to an account.
        tags:
          - Identity
        parameters:
        - name: account
          in: path
          description: The account for the identity.
          schema:
            type: string
          style: simple
        - name: X-Rucio-Username
          in: query
          description: Username for the identity.
          schema:
            type: string
          style: simple
          required: true
        - name: X-Rucio-Password
          in: query
          description: The password for the identity.
          schema:
            type: string
          style: simple
          required: true
        - name: X-Rucio-Email
          in: query
          description: The email for the identity.
          schema:
            type: string
          style: simple
          required: false
        responses:
          201:
            description: OK
            content:
              application/json:
                schema:
                  type: string
                  enum: ['Created']
          401:
            description: Invalid Auth Token
          400:
            description: Missing username or password.
        """
        username = request.headers.get('X-Rucio-Username', default=None)
        password = request.headers.get('X-Rucio-Password', default=None)
        email = request.headers.get('X-Rucio-Email', default=None)

        if not username or not password:
            return 'Username and Password must be set.', 400

        add_identity(username, 'userpass', email, password)

        add_account_identity(
            identity_key=username,
            id_type='userpass',
            account=account,
            email=email,
            password=password,
            issuer=request.environ.get('issuer'),
            vo=request.environ.get('vo'),
        )

        return 'Created', 201