Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Auth API #102

Open
ghost opened this issue Jun 23, 2016 · 9 comments
Open

Refactor Auth API #102

ghost opened this issue Jun 23, 2016 · 9 comments
Labels

Comments

@ghost
Copy link

ghost commented Jun 23, 2016

We need to refactor the auth API so as to:

  1. Provide a simple, synchronous API
  2. Avoid using closures/callbacks for simple computations
  3. Avoid depending on any HTTP framework (remove any reference to http.request, keep only required bits of data)
  4. Provide an 'AwsServiceName' to the signing requests, as this may be included depending on the service.

The planned API is as follows:

auth: {
    client: {
        generateV4Headers: function (query, method, uri, payload, secretKey) -> { headersDict, errorObject },
    },
    server: {
        prepareV2: function (QueryString, Headers) -> { authParamsObject, errorObject },
        prepareV4: function (QueryString, Headers) -> { authParamsObject, errorObject },
        checkV2Signature: function(authParamsObject, secretKeyValue) -> bool,
        checkV4Signature: function(authParamsObject, secretKeyValue) -> bool,
    },
}

This is the general feeling. The Client would use the client API, and the server could use the server API in two steps:

  1. prepare auth params for actual auth
  2. retrieve auth information from whatever storage is used
  3. compute and check signature using results from step 1+2

Admitedly, the current API is missing a potential options object, or at least an AWSServiceName to use.

@ghost ghost added the refactor label Jun 23, 2016
@ghost ghost self-assigned this Jul 7, 2016
@jmunoznaranjo
Copy link
Contributor

Looks good 👍 . Maybe you want to consider a different name for prepareVX as it suggests (to me at least) that a signature is being created instead of verified. I suggest extractVX or extractVXParams.

@ghost
Copy link
Author

ghost commented Jul 7, 2016

Actually, in my current work, I actually defined only two functions in the server API:
extractParams and checkSignature, and those functions use the params.version to switch on the right version.

I could possibly also export checkSignatureV4 and checkSignatureV2, as well as the associated extractParams, but not in the first step. I hope to be able to put out the first set of PRs tuesday :)

@LaurenSpiegel
Copy link
Contributor

As noted in https://github.com/scality/Arsenal/pull/119/files/3267fd091deac5d00f951bacf278362fca28f86d#r72753763 ,
if the generate4Headers function is really going to be multi-purpose we can't hard code the signedHeaders. Instead the host header and any x-amz- or x-scal- should be included in the signedheaders and the signature.

@rahulreddy
Copy link
Collaborator

Piggybacking on @LaurenSpiegel 's comment we should make it generic in the sense it should not set any headers to the request object, it should just return a generic object with the headers that can be set.

@LaurenSpiegel
Copy link
Contributor

To be clear, there are 2 issues that are separate:

  1. My original issue: The signed headers should not be a defined string. It should be created by concatenating host with all of the x-amz and x-scal headers from the request headers.
  2. Rahul's issue -- don't mess with the request object directly.

@ghost
Copy link
Author

ghost commented Aug 24, 2016

@rahulreddy @LaurenSpiegel Should we create a dedicated issue for the generateV4Headers's signed header topic ? Not modifying the request object is already part of my aim for this task.

@LaurenSpiegel
Copy link
Contributor

@DavidPineauScality, I already fixed the signed headers issue so that the encrypted bucket creation tool would work. 18d657b

@ghost
Copy link
Author

ghost commented Aug 25, 2016

Ok perfect, thanks. I guess a huge rebase is waiting for me again...

On Wed, Aug 24, 2016 at 6:22 PM, Lauren Spiegel [email protected]
wrote:

@DavidPineauScality https://github.com/DavidPineauScality, I already
fixed the signed headers issue so that the encrypted bucket creation tool
would work. 18d657b
18d657b


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#102 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ANpZZ6UU6s8p33E7nsN7_jCeKfmEb41Yks5qjG_XgaJpZM4I85rs
.

David Pineau
Scality R&D Engineer

http://bit.ly/2aKbaTu

@ghost
Copy link
Author

ghost commented Sep 30, 2016

Following the work done in the associated PR, Only one thing is left remaining to completely wrap up this rework:

Use the new API to remove slowly the doAuth from the relevant components, and then remove the doAuth utility function altogether.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants