Compare commits

..

13 Commits

Author SHA1 Message Date
shatoboar
57472fb84f fix(README.md) Codacy style 2022-06-28 13:58:51 +02:00
shatoboar
2ddf24c7eb move contribution docs to the official docs repo 2022-06-28 13:46:11 +02:00
shatoboar
841fa44072 feat(README.md) add section about contributing to the project 2022-06-28 13:38:59 +02:00
shatoboar
2c2790603e feat(contribution.md) project setup 2022-06-22 17:21:36 +02:00
shatoboar
f31f8a76fb Move contribution.md to docs folder 2022-06-22 15:50:43 +02:00
shatoboar
b052e74fe7 Code guide for new contributors
Description for daemon, CLI and UI
2022-06-22 15:50:15 +02:00
shatoboar
89f9c498f1 Update (architecture.md) 2022-06-22 15:45:51 +02:00
Maycon Santos
f883a10535 Rollback dash board image location 2022-06-21 19:01:50 +02:00
Maycon Santos
8ec7f1cd96 Update dashboard docker image 2022-06-21 18:17:38 +02:00
mlsmaycon
aae84e40e2 Update slack invitations link 2022-06-21 11:01:10 +02:00
Misha Bragin
5623735234 Update docs to reflect released access control 2022-06-20 22:34:16 +02:00
Maycon Santos
f9f2d7c7ef Check if new account ID is already being used (#364) 2022-06-20 18:20:43 +02:00
Maycon Santos
35c7cae267 Add homebrew bin path on Apple Silicon (#365)
This was causing issues on new models
2022-06-20 11:34:24 +02:00
9 changed files with 91 additions and 23 deletions

1
.gitignore vendored
View File

@@ -1,4 +1,5 @@
.idea
.run
*.iml
dist/
bin/

View File

@@ -1,6 +1,6 @@
<p align="center">
<strong>:hatching_chick: New release! Beta Update May 2022</strong>.
<a href="https://github.com/netbirdio/netbird/releases/tag/v0.6.0">
<strong>:hatching_chick: New release! Seamless Access Controls</strong>.
<a href="https://github.com/netbirdio/netbird/releases/tag/v0.7.0">
Learn more
</a>
</p>
@@ -15,7 +15,7 @@
</a>
<a href="https://www.codacy.com/gh/netbirdio/netbird/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=netbirdio/netbird&amp;utm_campaign=Badge_Grade"><img src="https://app.codacy.com/project/badge/Grade/e3013d046aec44cdb7462c8673b00976"/></a>
<br>
<a href="https://join.slack.com/t/wiretrustee/shared_invite/zt-vrahf41g-ik1v7fV8du6t0RwxSrJ96A">
<a href="https://join.slack.com/t/netbirdio/shared_invite/zt-vrahf41g-ik1v7fV8du6t0RwxSrJ96A">
<img src="https://img.shields.io/badge/slack-@wiretrustee-red.svg?logo=slack"/>
</a>
</p>
@@ -28,7 +28,7 @@
<br/>
See <a href="https://netbird.io/docs/">Documentation</a>
<br/>
Join our <a href="https://join.slack.com/t/wiretrustee/shared_invite/zt-vrahf41g-ik1v7fV8du6t0RwxSrJ96A">Slack channel</a>
Join our <a href="https://join.slack.com/t/netbirdio/shared_invite/zt-vrahf41g-ik1v7fV8du6t0RwxSrJ96A">Slack channel</a>
<br/>
</strong>
@@ -52,9 +52,9 @@ NetBird creates an overlay peer-to-peer network connecting machines automaticall
- \[x] SSO and MFA support.
- \[x] Multicloud and hybrid-cloud support.
- \[x] Kernel WireGuard usage when possible.
- \[x] Access Controls - groups & rules.
**Coming soon:**
- \[ ] Access Controls - groups & rules.
- \[ ] Private DNS.
- \[ ] Mobile clients.
- \[ ] Network Activity Monitoring.
@@ -105,3 +105,33 @@ We use open-source technologies like [WireGuard®](https://www.wireguard.com/),
### Legal
[WireGuard](https://wireguard.com/) is a registered trademark of Jason A. Donenfeld.
### Contribution
**You have a working Go environment**
Clone the project into your preferred path. We recommend just cloning into the GOPATH.
```bash
mkdir -p $GOPATH/src/github.com/netbirdio
cd $GOPATH/src/github.com/netbirdio
git clone git@github.com:netbirdio/netbird.git
cd netbird
go build ./...
```
**Sidenote**
*`libayatana-appindicator3-dev` might be needed for developing
the client-ui [ui](https://github.com/netbirdio/netbird/tree/main/client/ui) on debian based distros.*<br>
**Sidenote**
*The command won't produce a binary, but only check for working builds.
If you want to produce a binary, you need to `cd` into the specific subproject and use `go build`.*
**To run the tests run**
```bash
go test -exec sudo ./...
```
The tests need to be executed with sudo permissions, as our integration tests need to create network interfaces.
For further information about contributing to the Netbird project, please refer to our [documentation](https://netbird.io/docs/development/contributing).

View File

@@ -1,2 +1,6 @@
### Architecture
TODO
**Our docs have moved to a separate [repository](https://netbird.io/docs).** <br>
To get more insight into netbird's architecture refer to this [documentation](https://netbird.io/docs/overview/architecture).

View File

@@ -58,4 +58,4 @@ services:
volumes:
$MGMT_VOLUMENAME:
$SIGNAL_VOLUMENAME:
$LETSENCRYPT_VOLUMENAME:
$LETSENCRYPT_VOLUMENAME:

View File

@@ -100,12 +100,6 @@ type UserInfo struct {
Role string `json:"role"`
}
// NewAccount creates a new Account with a generated ID and generated default setup keys
func NewAccount(userId, domain string) *Account {
accountId := xid.New().String()
return newAccountWithId(accountId, userId, domain)
}
func (a *Account) Copy() *Account {
peers := map[string]*Peer{}
for id, peer := range a.Peers {
@@ -198,6 +192,27 @@ func BuildManager(
}
// newAccount creates a new Account with a generated ID and generated default setup keys.
// If ID is already in use (due to collision) we try one more time before returning error
func (am *DefaultAccountManager) newAccount(userID, domain string) (*Account, error) {
for i := 0; i < 2; i++ {
accountId := xid.New().String()
_, err := am.Store.GetAccount(accountId)
statusErr, _ := status.FromError(err)
if err == nil {
log.Warnf("an account with ID already exists, retrying...")
continue
} else if statusErr.Code() == codes.NotFound {
return newAccountWithId(accountId, userID, domain), nil
} else {
return nil, err
}
}
return nil, status.Errorf(codes.Internal, "error while creating new account")
}
func (am *DefaultAccountManager) warmupIDPCache() error {
userData, err := am.idpManager.GetAllAccounts()
if err != nil {
@@ -368,7 +383,7 @@ func mergeLocalAndQueryUser(queried idp.UserData, local User) *UserInfo {
}
}
func (am *DefaultAccountManager) loadFromCache(ctx context.Context, accountID interface{}) (interface{}, error) {
func (am *DefaultAccountManager) loadFromCache(_ context.Context, accountID interface{}) (interface{}, error) {
return am.idpManager.GetAccount(fmt.Sprintf("%v", accountID))
}
@@ -458,8 +473,17 @@ func (am *DefaultAccountManager) updateAccountDomainAttributes(
primaryDomain bool,
) error {
account.IsDomainPrimaryAccount = primaryDomain
account.Domain = strings.ToLower(claims.Domain)
account.DomainCategory = claims.DomainCategory
lowerDomain := strings.ToLower(claims.Domain)
userObj := account.Users[claims.UserId]
if account.Domain != lowerDomain && userObj.Role == UserRoleAdmin {
account.Domain = lowerDomain
}
// prevent updating category for different domain until admin logs in
if account.Domain == lowerDomain {
account.DomainCategory = claims.DomainCategory
}
err := am.Store.SaveAccount(account)
if err != nil {
return status.Errorf(codes.Internal, "failed saving updated account")
@@ -523,7 +547,10 @@ func (am *DefaultAccountManager) handleNewUserAccount(
return nil, status.Errorf(codes.Internal, "failed saving updated account")
}
} else {
account = NewAccount(claims.UserId, lowerDomain)
account, err = am.newAccount(claims.UserId, lowerDomain)
if err != nil {
return nil, err
}
err = am.updateAccountDomainAttributes(account, claims, true)
if err != nil {
return nil, err

View File

@@ -96,7 +96,8 @@ func TestNewAccount(t *testing.T) {
domain := "netbird.io"
userId := "account_creator"
account := NewAccount(userId, domain)
accountID := "account_id"
account := newAccountWithId(accountID, userId, domain)
verifyNewAccountHasDefaultFields(t, account, userId, domain, []string{userId})
}

View File

@@ -33,7 +33,7 @@ func TestNewStore(t *testing.T) {
func TestSaveAccount(t *testing.T) {
store := newStore(t)
account := NewAccount("testuser", "")
account := newAccountWithId("account_id", "testuser", "")
setupKey := GenerateDefaultSetupKey()
account.SetupKeys[setupKey.Key] = setupKey
account.Peers["testpeer"] = &Peer{
@@ -72,7 +72,7 @@ func TestSaveAccount(t *testing.T) {
func TestStore(t *testing.T) {
store := newStore(t)
account := NewAccount("testuser", "")
account := newAccountWithId("account_id", "testuser", "")
account.Peers["testpeer"] = &Peer{
Key: "peerkey",
SetupKey: "peerkeysetupkey",

View File

@@ -59,7 +59,10 @@ func (am *DefaultAccountManager) GetOrCreateAccountByUser(userId, domain string)
account, err := am.Store.GetUserAccount(userId)
if err != nil {
if s, ok := status.FromError(err); ok && s.Code() == codes.NotFound {
account = NewAccount(userId, lowerDomain)
account, err = am.newAccount(userId, lowerDomain)
if err != nil {
return nil, err
}
err = am.Store.SaveAccount(account)
if err != nil {
return nil, status.Errorf(codes.Internal, "failed creating account")
@@ -70,7 +73,9 @@ func (am *DefaultAccountManager) GetOrCreateAccountByUser(userId, domain string)
}
}
if account.Domain != lowerDomain {
userObj := account.Users[userId]
if account.Domain != lowerDomain && userObj.Role == UserRoleAdmin {
account.Domain = lowerDomain
err = am.Store.SaveAccount(account)
if err != nil {

View File

@@ -1,6 +1,6 @@
#!/bin/sh
export PATH=$PATH:/usr/local/bin
export PATH=$PATH:/usr/local/bin:/opt/homebrew/bin
# check if wiretrustee is installed
WT_BIN=$(which wiretrustee)