-
Notifications
You must be signed in to change notification settings - Fork 3
Conversation
69f7c05
to
535f07b
Compare
|
||
export const serviceLoginFactory = (agent: Agent) => (serviceUrl: string, serviceDid: string, did: string, cb?: Callback<string>) => (dispatch: Dispatch) => callbackify( | ||
async () => { | ||
const makeLoginCredentialPayload = (challenge: string) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should create this closure outside serviceLoginFactory
closure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left them inside the serviceAuthenticationFactory
because they depends on some variables that are received by the parent function. Do you think I should move them outside and send the needed params? I'm talking about did
and serviceDid
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can curry them
} | ||
} | ||
|
||
const verifyServiceDid = (message: Message): Credential => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
return axios.post(`${serviceUrl}/request-auth`, { did }) | ||
.then(res => res.status === 200 && res.data) | ||
.then(data => data.challenge) | ||
.then(makeLoginCredentialPayload) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think we should use credential model here or just a signed jwt? I think using just a jwt to respond here makes it simpler and it has the same effect, signing the challenge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I partially agree on that. It's true that it will become simpler to create just a signed JWT instead of a VC, but take in account that daf-w3c
already has an action handler to build those VCs, and if we want to sign a JWT we should build an action handler to do that within daf-did-jwt
because it is not created yet, or use directly did-jwt
package with no agent involved, we just need to obtain the signer
from it.
I think is cleaner to create a daf-did-jwt
action handler inside rif-id-daf
package
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In another hand, if we change the type of the JWT we should change the auth package as well, it is expecting the challenge inside a W3C VC
https://github.com/rsksmart/rif-identity-services/blob/cc4b183b9dc3d60e958be1da87afeafb87aba9ad/rif-id-jwt-auth/src/index.js#L76-L78
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should build an action handler to do that within
daf-did-jwt
that's a bummer...
I think is cleaner to create a daf-did-jwt action handler inside rif-id-daf package
I would rise an issue in uPort project to see if they are interested in merging this, what do you think?
we should change the auth package as well
IMHO it worths it
Anyway, before taking any desicion let's think a little bit better on this interface. I guess a good extension in the future will include some credentials in this step
- User requests access
- Services sends a token and a selective disclosure request
- User fills request with declarative details and/or presentations + challange
- Service grants access and gives credential to user, probably including metadata taken from the request response.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on what we already agreed, let's do the following:
- User requests access
- Service sends a challenge
- Users signs a VP with the received challenge in the VP metadata. The user should include the needed VC inside that VP, if the service does not require any VC, it should send an empty array
- Service validates the challenge and performs the needed business validations with the received VCs
- If all the validations pass, the service creates a VC and sends it JWT representation to the user
- User uses the received VC to authenticate each request to the service
Remarks:
- Why the user needs to include VCs in the authentication process? Because the service may need to verify some business logic before granting access, for instance, that the user is older than 18 years old
- Why the user will authenticate with the received VC and not with a ad hoc VP for each request? Because there is not added value by doing that and it needs an extra signing step with no sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created a new issue in rif-identity-services
import { ActionSignW3cVc } from 'daf-w3c' | ||
import { addServiceToken } from '../reducers/authentication' | ||
|
||
export const serviceLoginFactory = (agent: Agent) => (serviceUrl: string, serviceDid: string, did: string, cb?: Callback<string>) => (dispatch: Dispatch) => callbackify( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use the name “authenticate” instead of “login”, it describes better what this is doing. What do you think about this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep! Sounds better
|
||
await serviceLogin(serviceUrl, notServiceDid, identity.did)(store.dispatch).catch(e => { | ||
expect(e.message).toEqual('The issuer of the auth credential is not the expected did') | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let’s test the state after the error is thrown. It should be same than before throwing. Adding issue to add it in this one and in the other operations tests
535f07b
to
a47d1b1
Compare
…llback after succesful login
123f73f
to
6c097d6
Compare
The base of the PR is #46 to make it easier to compare the changes, will be changed once that PR is merged