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

Turn w3id.org into a did web resolver with htaccess rewrite #25

Open
OR13 opened this issue Mar 14, 2021 · 6 comments
Open

Turn w3id.org into a did web resolver with htaccess rewrite #25

OR13 opened this issue Mar 14, 2021 · 6 comments

Comments

@OR13
Copy link
Collaborator

OR13 commented Mar 14, 2021

Header set Access-Control-Allow-Origin *
Header set Access-Control-Allow-Headers DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified$
Options +FollowSymLinks
RewriteEngine on

# DID web via redirect

# RewriteRule ^did:web:(.+)$ https://did-web.web.app/api/v1/identifiers/did:web:$1 [R=302,L]

# http://localhost:8080/did:web:vc.did.ai 

RewriteRule ^did:web:([a-zA-Z0-9/.\\-_]+)$ https://$1/.well-known/did.json [R=302,L]

# http://localhost:8080/did:web:did.actor:alice

RewriteRule ^did:web:([A-Z|a-z\.]+)(?::)([a-zA-Z0-9/.\-:\\_]+)$ https://$1/$2/did.json [R=302,L]

# http://localhost:8080/did:web:did.actor:alice:1

RewriteRule ^did:web:([A-Z|a-z\.]+)(?::)([a-zA-Z0-9/.\-:\\_]+)(?::)([a-zA-Z0-9/.\-:\\_]+)$ https://$1/$2/$3/did.json [R=302,L]

# DID web via url rewrite 

# http://localhost:8080/did:web:did.actor:supply-chain:manufacturer:stacy

RewriteRule ^did:web:([A-Z|a-z\.]+)(?::)([a-zA-Z0-9/.\-:\\_]+)(?::)([a-zA-Z0-9/.\-:\\_]+)(?::)([a-zA-Z0-9/.\-:\\_]+)$ https://$1/$2/$3/$4/did.json [R=302,L]

If someone who is better with htaccess and regex can clean this up, we don't need a did web resolver any more.

@OR13
Copy link
Collaborator Author

OR13 commented Mar 14, 2021

demo here: transmute-industries/verifiable-data#17

@OR13 OR13 changed the title Turn w3id.org into a did we resolver with htaccess rewrite Turn w3id.org into a did web resolver with htaccess rewrite Mar 14, 2021
@gribneau
Copy link
Contributor

The simplicity is admirable.

By clean up, do you mean reduce the number of statements?

... https://$1/$2/did.json [R=302,L]
... https://$1/$2/$3/did.json [R=302,L]
... https://$1/$2/$3/$4/did.json [R=302,L]

@OR13
Copy link
Collaborator Author

OR13 commented Mar 22, 2021

@gribneau yes, currently being forced to write a rule for very level of nesting because I can't figure out how to use htaccess rules to replace ":" with "/" in a recursive regex.

@gribneau
Copy link
Contributor

I don't think we can do a global or recursive string replace in the context of a rewrite rule.

Something like mod_lua might be a cleaner path.

@OR13
Copy link
Collaborator Author

OR13 commented Mar 25, 2021

I asked on the w3id.org repo, even the regex opens them up for redos and other attacks but perhaps there are features they know of which might help.

another alternative would be to limit the nesting depth in the spec, which might be a good idea for security reasons anyway...

ping @dmitrizagidulin @awoie

@kdenhartog
Copy link
Contributor

Interesting - using w3id.org as a resolver creates a nice herd privacy effect. I like where you're going with this, but not sure I know how to help with your issue around making this recursive at this point.

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

No branches or pull requests

3 participants