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

NIP-97 Login with Nostr #1042

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

NIP-97 Login with Nostr #1042

wants to merge 4 commits into from

Conversation

Semisol
Copy link
Collaborator

@Semisol Semisol commented Feb 12, 2024

This spec proposes a simple login flow to allow easy authentication to services like nostr.build without having to deal with DM verification or other confusing flows.

@vitorpamplona
Copy link
Collaborator

Looks good, as long as the server doesn't use the identifier as the session cookie.

created_at check (must be < 5 minutes from the request) could also be performed.

@Semisol
Copy link
Collaborator Author

Semisol commented Feb 12, 2024

Looks good, as long as the server doesn't use the identifier as the session cookie.

created_at check (must be < 5 minutes from the request) could also be performed.

The identifier is associated with the session cookie in some way, but it shouldn't be it.
The created_at check is a part of NIP-98 and services can also determine when to expire a login string.

@alexgleason
Copy link
Member

alexgleason commented Feb 12, 2024

Why not use NIP-98?

EDIT: I see NIP-98 is already a part of this. I don't understand what this is solving.

@fiatjaf
Copy link
Member

fiatjaf commented Feb 12, 2024

I don't get this at all. What happens when you click? Who is going to handle that link?
I think it's better to let websites come up with their own login process using NIP-98.
Maybe recommend a common pattern on that NIP.

Copy link
Collaborator

@vitorpamplona vitorpamplona left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some nitpicks.

@Semisol
Copy link
Collaborator Author

Semisol commented Feb 14, 2024

I don't get this at all. What happens when you click? Who is going to handle that link? I think it's better to let websites come up with their own login process using NIP-98. Maybe recommend a common pattern on that NIP.

not everyone has an extension. the point of this is if you don't have an extension, you could just scan a QR code/click a link and prove you control an npub without inputting your nsec everywhere.

@fiatjaf
Copy link
Member

fiatjaf commented Feb 14, 2024

What about NIP-46?

@mikedilger
Copy link
Contributor

not everyone has an extension. the point of this is if you don't have an extension, you could just scan a QR code/click a link and prove you control an npub without inputting your nsec everywhere.

I missed the part where you prove anything. Is that part of this NIP? How does clicking a link prove anything? Maybe it is just missing a sentence where this is explained.

@jb55
Copy link
Contributor

jb55 commented Feb 15, 2024

cc @danieldaquino for review since you introduced a similar flow for damus purple

@Egge21M
Copy link
Contributor

Egge21M commented Feb 15, 2024

not everyone has an extension. the point of this is if you don't have an extension, you could just scan a QR code/click a link and prove you control an npub without inputting your nsec everywhere.

I missed the part where you prove anything. Is that part of this NIP? How does clicking a link prove anything? Maybe it is just missing a sentence where this is explained.

The request has a nip-98 header

@Semisol Semisol changed the title NIP-97 Nostr Login NIP-97 Login with Nostr Feb 17, 2024
@Semisol
Copy link
Collaborator Author

Semisol commented Feb 17, 2024

not everyone has an extension. the point of this is if you don't have an extension, you could just scan a QR code/click a link and prove you control an npub without inputting your nsec everywhere.

I missed the part where you prove anything. Is that part of this NIP? How does clicking a link prove anything? Maybe it is just missing a sentence where this is explained.

your client sends a POST request that is authenticated with your public key (NIP-98) with an identifier in the login link

@Semisol
Copy link
Collaborator Author

Semisol commented Feb 18, 2024

What about NIP-46?

@fiatjaf This is for use cases where you don't need signing access and only need to prove your ownership of a key.

Copy link

@danieldaquino danieldaquino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like this spec, and I think it will be very useful.

Only thing I would add to it is an optional redirect_url field to the JSON response from the server, but otherwise it looks good to me.

@vitorpamplona
Copy link
Collaborator

@Semisol do you have any server where this was implemented already? I need to test Amethyst's implementation of this.

@fishcakeday
Copy link

@Semisol do you have any server where this was implemented already? I need to test Amethyst's implementation of this.

I'll implement one on nostr.build in the next couple of days.

@fabianfabian
Copy link

This looks good I will implement it also.

@fabianfabian
Copy link

@TheRebelOfBabylon
Copy link

TheRebelOfBabylon commented Apr 13, 2024

For testing: https://media.utxo.nl/nip97test/nip97login.php

@fabianfabian I don't think your server properly enforces NIP-98. It expects the event to have a u tag containing only the URL without the query parameters and then the i query parameter is in a separate tag. But if you look at the spec for NIP-98, the u tag should include the entire absolute request URL including query parameters.

@fabianfabian
Copy link

For testing: https://media.utxo.nl/nip97test/nip97login.php

@fabianfabian I don't think your server properly enforces NIP-98. It expects the event to have a u tag containing only the URL without the query parameters and then the i query parameter is in a separate tag. But if you look at the spec for NIP-98, the u tag should include the entire absolute request URL including query parameters.

I'm checking the i tag for the challenge but I see the spec doesn't describe it like that, not sure what happened there probably I read it too quick, I'll update the test code later, this is the current test code: https://gist.github.com/fabianfabian/0c68d75aeb84860dcd7fc2995ec98af6

@TheRebelOfBabylon
Copy link

I've also implemented a server for testing but only accessible via REST API: https://git.rebelofbabylon.com/api/v1/login

fabianfabian added a commit to nostur-com/nostur-ios-public that referenced this pull request Apr 14, 2024
challenge should be in url query string not in tag (nostr-protocol/nips#1042 (comment))
@jb55
Copy link
Contributor

jb55 commented Apr 29, 2024

I really like this spec, and I think it will be very useful.

Only thing I would add to it is an optional redirect_url field to the JSON response from the server, but otherwise it looks good to me.

agreed, this is pretty important.

Copy link
Contributor

@jb55 jb55 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great!

@melvincarvalho

This comment was marked as spam.

@Semisol

This comment was marked as outdated.

@melvincarvalho

This comment was marked as spam.

@melvincarvalho

This comment was marked as spam.

@fabianfabian
Copy link

fabianfabian commented Jul 4, 2024

@Semisol do you have any server where this was implemented already? I need to test Amethyst's implementation of this.

I'll implement one on nostr.build in the next couple of days.

@fishcakeday is this available on nostr.build? I want to try it out

@jb55
Copy link
Contributor

jb55 commented Jul 5, 2024

Security concerns: Domain compromise could impact login systems, potentially harming Nostr's reputation. Motivation and security surface would benefit from further elaboration.

Existing efforts: Consider ongoing Nostr integration with Oauth/OIDC for new authentication methods.

Suggestion: Future auth NIPs should include a comparison section:

  • Comparison with existing auth methods, e.g. nostrlogin, nip98, nwc, nsecbunker, there's more ongoing oauth and oidc integrations ive seen too
  • Advantages offered
  • Use cases
  • Adoption status

Concept NACK: Needs clearer explanation and/or broader adoption to justify implementation (IMHO).

Just my 2 cents.

The main usecase we had is that we wanted to explicitly give memberships to npubs to have the ability to display stars on profiles and to give them a purple member number, I see this as more of a thing for niche thing for specifically verifying that a user controls a key to an npub, not as a generic login mechanism, although its true its likely this will be abused for that.

I think pushing npubs as a login mechanism is a bit sketchy, because once your key leaks you basically have doors wide open into all the websites you visit. Maybe we should make this explicit in the NIP that this should be probably just be used as a two factor mechanism or for niche use cases like verifying a user controls a key to an npub? Not as a main login mechanism.

@Semisol
Copy link
Collaborator Author

Semisol commented Jul 5, 2024

I think pushing npubs as a login mechanism is a bit sketchy, because once your key leaks you basically have doors wide open into all the websites you visit. Maybe we should make this explicit in the NIP that this should be probably just be used as a two factor mechanism or for niche use cases like verifying a user controls a key to an npub? Not as a main login mechanism.

Not even as two factor. The intent for this NIP was to allow easy login to services already linked to your nostr account, like relays, media hosts or NIP-05 providers.

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

Successfully merging this pull request may close these issues.