Skip to content

Conversation

@restanrm
Copy link
Contributor

  • read the CONTRIBUTING guidelines
  • raised a GitHub issue or discussed it on the projects chat beforehand
  • added unit tests
  • [] added integration tests
  • updated documentation if needed
  • updated CHANGELOG.md

should close #327

Copy link
Collaborator

@kradalby kradalby left a comment

Choose a reason for hiding this comment

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

Some comments, did you update the changelog? 🤔

namespaces.go Outdated
name = normalizeNamespaceRegex.ReplaceAllString(name, "-")

for _, elt := range strings.Split(name, ".") {
if len(elt) > 63 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is good, I think I would have forgotten this.

It makes me thing tho, do we need an option to only use the username or the name before @? I suspect that with emails, we can easily get too long names here?

reallylongfirstname.middlename.longlastname@reallylongdomainname.com

This will throw an error, but not sure if we will display it to users, and users might not have a clue whats going on.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes this is also something that I thought about without reaching a result. I could add a check at some place where we return the hostname if it's too long. In the RFC 1123 we can read the following:

Host software MUST handle host names of up to 63 characters and
SHOULD handle host names of up to 255 characters.

If we throw an error like this we should add some comments on resolution or keep the domain_map config around to solve this kind of issues.

Copy link
Collaborator

Choose a reason for hiding this comment

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

hmm, the combinations of options here is a bit of a can of worms:

  • Add too long ones into domain-only namespace
  • strip domain and use just username
  • what if username is still too long

I suggest keeping it a bit simple to begin with, and actually, I wonder if people dont really need to have the domain from the email in the namespace (as they are all likely the same).

Maybe we should have a oidc.strip_email_domain which is true by default, so by default, username is used, and if people intend to have different email addresses, you turn that off and get the whole thing.

So by default:
alice@enterprise.com -> alice
bob@enterprise.com -> bob

But you can turn that off:
alice@enterprise.com -> alice.enterprice-com (or what it will become)
bob@collaboratingcompany.com -> bob.collaboratingcompany-com

Host software MUST handle host names of up to 63 characters and
SHOULD handle host names of up to 255 characters.

As for 63 vs 255, I suggest we saw that 255 is an error and 63 is a warning.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The potential issue that I can see with the strip_email_domain as default is that if some users want to login with different email provider it's possible to have an issue. It can even become a security issue (impersonating admin account). I don't know OIDC well enough to see if it can be an issue. But I guess with a tool like dex (login aggregator), it seems possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My reference to RFC 1123 seems incomplete. RFC 2181 says the following:

The DNS itself places only one restriction on the particular labels
that can be used to identify resource records. That one restriction
relates to the length of the label and the full name. The length of
any one label is limited to between 1 and 63 octets. A full domain
name is limited to 255 octets (including the separators).

It seems to be the last RFC describing host names. The wikipedia page have the same information: https://en.wikipedia.org/wiki/Domain_Name_System

@restanrm
Copy link
Contributor Author

With this came to my mind that hostname validation is not done. @kradalby should we normalize the hostname received from the nodes ?

Copy link
Collaborator

@kradalby kradalby left a comment

Choose a reason for hiding this comment

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

With this came to my mind that hostname validation is not done. @kradalby should we normalize the hostname received from the nodes ?

Yes, but lets make an issue, so this can be tracked separately.

CHANGELOG.md Outdated
- Add API Key support
- Enable remote control of `headscale` via CLI [docs](docs/remote-cli.md)
- Enable HTTP API (beta, subject to change)
- OIDC login will map user to an associated namespace.
Copy link
Collaborator

Choose a reason for hiding this comment

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

When we have landed on how this work, we should elaborate here, and in the example config

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I remove changelog modifications ?

Copy link
Collaborator

@kradalby kradalby left a comment

Choose a reason for hiding this comment

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

I'll have a suggestion for the Changelog when I get to the airport, but all looks good now :)

)

const (
maxHostnameLength = 255
Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually, I just thought, is it the entire url that has the max? Or the segments between . ?

I just had a memory about some kubernetes namespace stuff.

This is mostly to raise this, I'm happy about it as is for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The Fully Qualified Domain Name has a maximum length of 255 and the labels (segments in between) have a maximum length of 63

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah yes of course

Copy link
Collaborator

@kradalby kradalby left a comment

Choose a reason for hiding this comment

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

Lets do this and I'll approve :)

kradalby and others added 3 commits February 24, 2022 11:40
Co-authored-by: Kristoffer Dalby <kradalby@kradalby.no>
Co-authored-by: Kristoffer Dalby <kradalby@kradalby.no>
kradalby
kradalby previously approved these changes Feb 24, 2022
@restanrm
Copy link
Contributor Author

Integrations tests seems to have a random component. One update on changelog was ok, the other was not…

@kradalby
Copy link
Collaborator

Integrations tests seems to have a random component. One update on changelog was ok, the other was not…

Sadly it's not random, but race conditions/sync issues in headscale.

I am continuously working on them, and have an draft with a couple of improvements. But for now, just rerunning it is the way 😖

@kradalby
Copy link
Collaborator

When #357 is in, can you resolve the conflicts? I think there will be some more, so you can wait for that one.

@restanrm
Copy link
Contributor Author

When #357 is in, can you resolve the conflicts? I think there will be some more, so you can wait for that one.

Ok, I'll wait for #357

@kradalby
Copy link
Collaborator

Ok, I'll wait for #357

Merged now.

@kradalby kradalby merged commit b1bd17f into juanfont:main Feb 25, 2022
@restanrm restanrm deleted the feat-oidc-login-as-namespace branch February 25, 2022 17:19
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.

Replace oidc.domain_map with email to namespace

2 participants