-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow setting static plaintext passwords
- Loading branch information
Showing
10 changed files
with
236 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ | |
- [Validating](#validating) | ||
- [Synchronizing](#synchronizing) | ||
- [Confirming synchronization](#confirming-synchronization) | ||
- [Static Password](#static-passwords) | ||
- [Limitations](#limitations) | ||
- [Sending the login info email to the new users](#sending-the-login-info-email-to-the-new-users) | ||
- [API requests quota](#api-requests-quota) | ||
|
@@ -63,6 +64,7 @@ After creating one, it needs to be registered as an API client and have enabled | |
* `https://www.googleapis.com/auth/admin.directory.group.member.readonly` | ||
* `https://www.googleapis.com/auth/admin.directory.resource.calendar` | ||
* `https://www.googleapis.com/auth/admin.directory.resource.calendar.readonly` | ||
* `https://www.googleapis.com/auth/admin.directory.userschema` | ||
* `https://www.googleapis.com/auth/apps.groups.settings` | ||
* `https://www.googleapis.com/auth/apps.licensing` | ||
|
||
|
@@ -216,6 +218,43 @@ $ gman \ | |
|
||
Run the same command again with `-confirm` to perform the changes. | ||
|
||
### Static Passwords | ||
|
||
GMan can be used to manage dummy/testing accounts with predefined passwords. Note that you should never | ||
put real passwords in cleartext anywhere near GMan, but if you have public passwords, e.g. for workshops | ||
and demonstrations, this feature can be handy. | ||
|
||
To make use of this, set a cleartext password for a user in your `users.yaml`: | ||
|
||
```yaml | ||
organization: myorganization | ||
users: | ||
- givenName: Josef | ||
familyName: K | ||
primaryEmail: [email protected] | ||
orgUnitPath: /Developers | ||
password: i-am-not-secure-at-all | ||
``` | ||
|
||
You must then opt-in to this feature by running GMan with `-insecure-passwords`: | ||
|
||
```bash | ||
$ gman \ | ||
-private-key MYKEY.json \ | ||
-impersonated-email [email protected] \ | ||
-users-config myconfig.yaml \ | ||
-groups-config myconfig.yaml \ | ||
-orgunits-config myconfig.yaml \ | ||
-insecure-passwords | ||
2020/06/25 18:55:54 ✓ Configuration is valid. | ||
2020/06/25 18:55:54 ► Updating organization myorganization... | ||
... | ||
``` | ||
|
||
GMan will now set the configured password and store its SHA256 hash as a custom schema field on the user. | ||
On the next run, GMan will compare the hash with the configured password and update the user in GSuite | ||
only if needed. | ||
|
||
## Limitations | ||
|
||
### Sending the login info email to the new users | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
Copyright 2021 The Kubermatic Kubernetes Platform contributors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package glib | ||
|
||
import ( | ||
"context" | ||
|
||
directoryv1 "google.golang.org/api/admin/directory/v1" | ||
) | ||
|
||
func (ds *DirectoryService) GetSchema(ctx context.Context, name string) (*directoryv1.Schema, error) { | ||
return ds.Schemas.Get("my_customer", name).Context(ctx).Do() | ||
} | ||
|
||
func (ds *DirectoryService) CreateSchema(ctx context.Context, schema *directoryv1.Schema) (*directoryv1.Schema, error) { | ||
return ds.Schemas.Insert("my_customer", schema).Context(ctx).Do() | ||
} | ||
|
||
func (ds *DirectoryService) UpdateSchema(ctx context.Context, oldSchema *directoryv1.Schema, newSchema *directoryv1.Schema) (*directoryv1.Schema, error) { | ||
return ds.Schemas.Update("my_customer", oldSchema.SchemaId, newSchema).Context(ctx).Do() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
Copyright 2021 The Kubermatic Kubernetes Platform contributors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package sync | ||
|
||
import ( | ||
"context" | ||
"log" | ||
|
||
directoryv1 "google.golang.org/api/admin/directory/v1" | ||
"google.golang.org/api/googleapi" | ||
|
||
"github.com/kubermatic-labs/gman/pkg/config" | ||
"github.com/kubermatic-labs/gman/pkg/glib" | ||
) | ||
|
||
func SyncSchema( | ||
ctx context.Context, | ||
directorySrv *glib.DirectoryService, | ||
confirm bool, | ||
) error { | ||
log.Println("⇄ Syncing schema…") | ||
|
||
if !confirm { | ||
return nil | ||
} | ||
|
||
desiredSchema := &directoryv1.Schema{ | ||
DisplayName: "GMan", | ||
SchemaName: config.SchemaName, | ||
Fields: []*directoryv1.SchemaFieldSpec{ | ||
{ | ||
FieldName: config.PasswordHashCustomField, | ||
FieldType: "STRING", | ||
ReadAccessType: "ADMINS_AND_SELF", | ||
Indexed: googleapi.Bool(false), | ||
}, | ||
}, | ||
} | ||
|
||
schema, err := directorySrv.GetSchema(ctx, config.SchemaName) | ||
|
||
if err != nil { | ||
_, err = directorySrv.CreateSchema(ctx, desiredSchema) | ||
} else { | ||
_, err = directorySrv.UpdateSchema(ctx, schema, desiredSchema) | ||
} | ||
|
||
return err | ||
} |
Oops, something went wrong.