-
Notifications
You must be signed in to change notification settings - Fork 148
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
CREDENTIAL: Use a generic matching algorithm that would work for custom Credentials types #274
Comments
I think @dlongley wanted additional data in the object, and to perform actions based upon it's content. If we can get away with it being a pure filter on attribute names, I'd be totally happy to do that. It's significantly simpler than defining custom algorithms and indirecting from the algorithms up to the interface. |
Would I be correct in saying that we can't define how that callback will work or even include it in this version of the API? If we want the API to perform additional processing on the Would something like this make sense in future: navigator.credentials.get({
"filters": {
"type": [ "ageVerification", "http://linked.data.com/credentialtype1" ],
"isOlderThan18" : [ true ],
"issuer" : [ "http://credentialissuer.com", "http://othertrustedissuer.com" ]
},
"linkedDataQuery" : "...",
"callbacks" : {
"http://linked.data.com/credentialtype1" : "http://posthere.com"
}
}); And be accommodated by this today: navigator.credentials.get({
"filters": {
"types": [ "ageVerification", "linkedDataCredential" ],
"isOlderThan18" : [ true ],
"issuer" : [ "http://credentialissuer.com", "http://othertrustedissuer.com" ]
}
}); i.e. In the future we would update the known properties of the request options and have special processing based on the content of these. Perhaps I misunderstand what @dlongley is trying to achieve. I have asked him to provide an example to clarify in #256. |
Some of what you're describing here is what we've been looking at doing with queries in the Identity Credentials spec. See example 6. I think we can push these kinds of complex queries off to the "LinkedDataIdentity" as proposed in #256. I think we need to separate identity from credentials -- and push these complexities off to the future with the work we're doing. I think all we need in the present form of this API is an "identity selector", essentially. And all that is required for the local/federated identity case is "proof of identity" as a credential, nothing more. For a local identity, that's just a password, for a federated identity it's some kind of token. For the linked data case you don't need to prove your identity, rather, you provide credentials for the types of actions you want to take. |
No currently defined If we do end up needing it, we could certainly extend |
@mikewest agreed. Another option for the filter functionality (filtered properties under the type name): navigator.credentials.get({
"filters": {
"password" : {} //No type-specifc filters
"federated" : {
"federation" : [ "https://facebook.com", "https://accounts.google.com" ]
},
"ageVerification" : {
"isOlderThan18" : [ true ],
"issuer" : [ "http://credentialissuer.com", "http://othertrustedissuer.com" ]
},
"http://linked-data.com/passport#credential" : {
"http://schema.org/country/iso_code" : [ "804", "219" ],
},
}
}); |
Does it make sense for the filtering to be done by the The base This allows custom implementations to define their own algorithms for matching but also allows the pre-defined types to follow the logic you have already put in the spec. Example Note: Excuse my JavaScript, this is not checked, it is a direct copy from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create with some modifications. I am not a Javascript guru. I would imagine these custom // AgeVerificationCredential - subclass of Credential
function AgeVerificationCredential() {
Credential.call(this);
this.type = "ageVerification";
this.isOlderThan18 = false;
}
AgeVerificationCredential.prototype = Object.create(Credential.prototype);
AgeVerificationCredential.prototype.constructor = AgeVerificationCredential ;
AgeVerificationCredential.prototype.filter = function(filters){
//Perform matching logic (as simple or complex as required by this type)
return (!filters) || (filters.isOlderThan18 === this.isOlderThan18);
} ;
//Store a custom credential
navigator.credentials.store(
new AgeVerificationCredential({
"id": "person_12345_age",
"isOlderThan18": true,
})
);
//Get credentials including custom types
navigator.credentials.get({
"filters": {
"password" : {} //No type-specifc filters
"federated" : {
"federation" : [ "https://facebook.com", "https://accounts.google.com" ]
},
"ageVerification" : {
"isOlderThan18" : true,
}
}
}); The WebIDL for the [Constructor(FederatedCredentialData data), Exposed=Window]
interface FederatedCredential : LocallyStoredCredential {
readonly attribute USVString federation;
boolean filter(sequence<USVString> federations);
}; |
Maybe! I think this boils down to pretty much the same thing, you've just exposed it to JavaScript, which might be a really good idea, and might be a terrible idea. :) It's not clear to me that we'll be able to do a good job storing and retrieving arbitrary types of credentials in this model, as we'd need to store not only the credential, but also all the object-related bits that would allow us to map the credential to something created in JavaScript-land (i.e. if I dump That said, nothing in the current draft prevents us from going this route in the future, right? I'd prefer to defer it until we actually need it. :/ |
So if we changed the interface for Browsers that implement the API can choose to store the function body defined on a custom The spec could define the expected behaviour if the browser attempts to initialise an instance of a custom All the spec should say is that as part of the matching algorithm for The two built-in types have pre-defined logic in the
|
At the moment, we have something like an internal implementation of the I think I'd like to understand exactly what @dlongley, et al actually want before doing that. |
(In other words, I think what you're asking for might make sense. I also think that the use cases in the spec neither require this kind of web-visible filter, nor does the API in the spec prevent us from going this route in the future.) |
My argument in favour of adding it now is that I think the benefits (flexibility, extensibility with Javascript - therefor extensibility without an API update) outweigh the negatives (a feature that is not explicitly required by the use cases). I would hope that groups like the Credentials CG and OpenID Foundation (or federated id providers like Twitter and Facebook) would provide js libraries that define a bunch of custom credentials and this allows them to leverage the core API functions Ultimately it's your call but I'd like to get a view from people like the participants in the OpenID Account Chooser WG (@openid) before we close the issue if that's okay with you? From Google I think @ericsachs is the right person to ping and from Microsoft, @selfissued. As far as I can tell there aren't any other browser vendors in that WG (a pity). |
shrug Perhaps I'm overestimating the complexity. What, concretely, would you like to see added to the spec? |
Can I have a stab at it this evening and submit a pull request? If you throw it away that's okay at least I will get some practice with ReSpec 😄 |
|
Thanks |
This issue was moved to w3c/webappsec-credential-management#7 |
The spec defines custom matching algorithms for the different sub-classes of
Credential
. If this could be restructured into a single-generic algorithm it could be used for custom sub-classes ofCredential
.Possible use-case illustrated below but suggests that
options
could be elevated/merged to the parent astypes
is also just a filter ORtype
could be a property ofoptions
.Matching algorithm would be something like:
For each property of
options
eliminate all possible credentials where theCredential
has a property with the same name and the value is not in the set of values provided.The text was updated successfully, but these errors were encountered: