remove dashboard script
This commit is contained in:
23
README.md
23
README.md
@@ -185,26 +185,3 @@ To make sure the app can share data, producers need to be set up. There is an in
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Configuring the dashboard
|
|
||||||
### Accessing the dashboard from your local machine
|
|
||||||
|
|
||||||
Since we use dispatcher v2, which dispatches on hostname, we'll have to update `/etc/hosts`.
|
|
||||||
Add an entry similar to the following. Ensure the first part of the domain starts with `dashboard`.:
|
|
||||||
|
|
||||||
```
|
|
||||||
127.0.0.1 dashboard.localhost
|
|
||||||
```
|
|
||||||
|
|
||||||
### Creating new users
|
|
||||||
For now, we use specific logins for the dashboard users. Each environment has its own passwords.
|
|
||||||
|
|
||||||
To add a user, make sure to have [mu-cli](https://github.com/mu-semtech/mu-cli) installed first.
|
|
||||||
Then in `docker-compose.override.yml`
|
|
||||||
```
|
|
||||||
dashboard-login:
|
|
||||||
environment:
|
|
||||||
MU_APPLICATION_SALT: 'a_random_string_with_sufficient_entropy_hence_not_this_one'
|
|
||||||
```
|
|
||||||
You can now generate a user by running `mu script project-scripts generate-dashboard-login` and following the steps.
|
|
||||||
Restart `migrations` and it should insert the new user into the database.
|
|
||||||
@@ -48,21 +48,6 @@
|
|||||||
"mounts": {
|
"mounts": {
|
||||||
"app": "/data/app/"
|
"app": "/data/app/"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
"documentation": {
|
|
||||||
"command": "generate-dashboard-login",
|
|
||||||
"description": "generate a login account for the jobs dashboard",
|
|
||||||
"arguments": []
|
|
||||||
},
|
|
||||||
"environment": {
|
|
||||||
"image": "ruby",
|
|
||||||
"interactive": true,
|
|
||||||
"script": "generate-dashboard-login/run.sh"
|
|
||||||
},
|
|
||||||
"mounts": {
|
|
||||||
"app": "/project/"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,80 +0,0 @@
|
|||||||
#!/usr/bin/env ruby
|
|
||||||
require 'bundler/inline'
|
|
||||||
require 'yaml'
|
|
||||||
require 'securerandom'
|
|
||||||
require 'date'
|
|
||||||
|
|
||||||
$stdout.sync = true
|
|
||||||
print "installing dependencies..."
|
|
||||||
gemfile do
|
|
||||||
source 'https://rubygems.org'
|
|
||||||
gem 'bcrypt'
|
|
||||||
end
|
|
||||||
puts "done"
|
|
||||||
|
|
||||||
salt = ""
|
|
||||||
begin
|
|
||||||
File.open("/project/docker-compose.override.yml") do |file|
|
|
||||||
config = YAML.load(file)
|
|
||||||
salt = config.dig("services", "dashboard-login", "environment", "MU_APPLICATION_SALT")
|
|
||||||
throw "invalid salt" unless salt
|
|
||||||
end
|
|
||||||
rescue
|
|
||||||
puts "Tried to locate login salt in docker-compose.override.yml, but couldn't find it."
|
|
||||||
puts "Please make sure a salt is configured:"
|
|
||||||
puts <<EOF
|
|
||||||
login:
|
|
||||||
restart: "no"
|
|
||||||
environment:
|
|
||||||
MU_APPLICATION_SALT: "#{SecureRandom.hex}"
|
|
||||||
EOF
|
|
||||||
end
|
|
||||||
|
|
||||||
puts "this script will generate a new user account"
|
|
||||||
print "username: "
|
|
||||||
STDOUT.flush
|
|
||||||
account_name = STDIN.gets.chomp
|
|
||||||
|
|
||||||
print "password: "
|
|
||||||
STDOUT.flush
|
|
||||||
password = STDIN.gets.chomp
|
|
||||||
|
|
||||||
account_salt = SecureRandom.hex
|
|
||||||
person_uuid = SecureRandom.uuid
|
|
||||||
account_uuid = SecureRandom.uuid
|
|
||||||
domain = "data.gift"
|
|
||||||
hashed_password = BCrypt::Password.create(password + salt + account_salt)
|
|
||||||
now = DateTime.now.xmlschema
|
|
||||||
query = %(
|
|
||||||
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
|
|
||||||
PREFIX people: <http://#{domain}/people/>
|
|
||||||
PREFIX accounts: <http://#{domain}/accounts/>
|
|
||||||
PREFIX dcterms: <http://purl.org/dc/terms/>
|
|
||||||
PREFIX mu: <http://mu.semte.ch/vocabularies/core/>
|
|
||||||
PREFIX ext: <http://mu.semte.ch/vocabularies/ext/>
|
|
||||||
PREFIX account: <http://mu.semte.ch/vocabularies/account/>
|
|
||||||
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
|
|
||||||
INSERT DATA {
|
|
||||||
GRAPH <http://mu.semte.ch/application> {
|
|
||||||
people:#{person_uuid} a foaf:Person ;
|
|
||||||
foaf:name "#{account_name}";
|
|
||||||
foaf:account accounts:#{account_uuid};
|
|
||||||
mu:uuid "#{person_uuid}";
|
|
||||||
dcterms:created "#{now}"^^xsd:datetime;
|
|
||||||
dcterms:modified "#{now}"^^xsd:datetime.
|
|
||||||
accounts:#{account_uuid} a foaf:OnlineAccount;
|
|
||||||
foaf:accountName "#{account_name}";
|
|
||||||
mu:uuid "#{account_uuid}";
|
|
||||||
account:password """#{hashed_password}""";
|
|
||||||
account:salt "#{account_salt}";
|
|
||||||
account:status <http://mu.semte.ch/vocabularies/account/status/active>;
|
|
||||||
dcterms:created "#{now}"^^xsd:datetime;
|
|
||||||
ext:sessionRole "dashboard-user";
|
|
||||||
dcterms:modified "#{now}"^^xsd:datetime.
|
|
||||||
}}
|
|
||||||
)
|
|
||||||
|
|
||||||
timestamp = DateTime.now.strftime("%Y%m%d%H%M%L")
|
|
||||||
filename = "#{timestamp}-create-user-#{account_name.gsub(" ", "-")}.sparql"
|
|
||||||
File.write("/project/config/migrations/local/#{filename}", query)
|
|
||||||
puts "generated migration ./config/migrations/local/#{filename} for #{account_name.inspect} : #{password.inspect}"
|
|
||||||
Reference in New Issue
Block a user