Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
0ddf709
Remove user functionality added in auth
sami-cseseu Feb 9, 2019
3ef591e
Auth Dynamic test added
sami-cseseu Feb 9, 2019
3d776c7
Auth database test added
sami-cseseu Feb 9, 2019
2f9fcb2
Add modified scalastyle definitions from webapi. Inserted file header…
Feb 12, 2019
739764f
Fixed syntax error from last commit. Fixed compile-time warnings. Fix…
Feb 12, 2019
05ed3c5
Fixed remaining codestyle issues.
Feb 12, 2019
ffe8726
Removed unused 'ErrorLog' property from reportFailure
Feb 12, 2019
42d2895
Updated code comments in Server.scala to new API schema.
Feb 12, 2019
f30db74
Fixed codacys issues with file headers
Feb 13, 2019
5e98523
Addressed naming issues detected by codacy.
Feb 13, 2019
2f2092d
More specific information on running the registry in a Docker container.
Feb 13, 2019
cd6f337
Removed unused ActorSystem from RequestHandlerTest. Testing CI behavi…
Feb 13, 2019
80b6e46
Removed commented out code (explicitly killing the ActorSystem). Re-t…
Feb 13, 2019
1fe23a8
Trigger CI re-build for testing
Feb 13, 2019
a4f6c85
Re-trigger CI build for testing
Feb 13, 2019
fb04030
Re-trigger CI build for testing.
Feb 13, 2019
c8d11a2
Re-trigger CI build for testing
Feb 13, 2019
5c1459c
Re-trigger CI build for testing
Feb 13, 2019
0382a49
Re-trigger CI build for testing (last time).
Feb 13, 2019
52ce6e6
Merge pull request #107 from delphi-hub/feature/codestyle
24santoshr Feb 14, 2019
9780e92
Merge pull request #108 from delphi-hub/feature/dockerDeploymentInfo
24santoshr Feb 14, 2019
0f3799c
Merge pull request #111 from delphi-hub/bugfix/actorSystem
24santoshr Feb 14, 2019
ca5a7dd
Merge branch 'develop' of https://github.com/delphi-hub/delphi-regist…
sami-cseseu Feb 14, 2019
17d5430
type chenged for add user handler
sami-cseseu Feb 14, 2019
a5b0e80
Fixed bug where link state updates have been invalid
Feb 14, 2019
d8df5d8
Added error message that was helpful for testing
Feb 14, 2019
e778e6e
Merge pull request #114 from delphi-hub/bugfix/invalidLinkStates
24santoshr Feb 14, 2019
1dc945d
added remove, getUserWithId and getAllUser also added tests for that
sami-cseseu Feb 14, 2019
6818386
added routes for remove user, get user by id and get all user
sami-cseseu Feb 14, 2019
cc790f4
Added test cases for authentication, add, remove, get user
sami-cseseu Feb 14, 2019
948265f
Fixes code style issues, removes unused functions
sami-cseseu Feb 18, 2019
d87440f
changes addUser return from username to userId
sami-cseseu Feb 18, 2019
05cbc66
Add swagger documentation for new endpoints, missing scaladoc in server.
Feb 19, 2019
b8a817c
Merge pull request #115 from delphi-hub/authTest
johannesduesing Feb 19, 2019
ffe5a98
Added quickstart guid, linux only, missing JWT explanations.
Feb 19, 2019
1add90e
Modified conclusion of quickstart section to referr to Authorization
Feb 21, 2019
b2675db
Merge pull request #118 from delphi-hub/feature/quickstart
24santoshr Feb 21, 2019
4e845f1
Removes secret from get user and get all user endpoint
sami-cseseu Feb 21, 2019
1ed2c50
Swagger documentation updated for user endpoints
sami-cseseu Feb 21, 2019
283a297
Merge branch 'develop' of https://github.com/delphi-hub/delphi-regist…
sami-cseseu Feb 21, 2019
d0168aa
remove secret from user return in open api specification
sami-cseseu Feb 21, 2019
9449e22
Merge pull request #121 from delphi-hub/authTest
johannesduesing Feb 21, 2019
7ccaa0c
Updating bugfix
24santoshr Feb 22, 2019
8614fc7
bugfix/UpdateLinks
24santoshr Feb 23, 2019
f85ffd4
bugfix/UpdateLinks
24santoshr Feb 23, 2019
51dc16a
Removing unnecessary logs
24santoshr Feb 24, 2019
ce3b7fa
Changed some variable and function names for better understanding. Ad…
Feb 26, 2019
651411c
Merge pull request #122 from delphi-hub/feature/checklinks
johannesduesing Feb 26, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 98 additions & 27 deletions OpenAPISpecification.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ paths:
tags:
- Meta
summary: Retreives general configuration information
description: Retrieves an object containing the most important configuration values of the registry. This contains the docker and traefik URIs.
description: >-
Retrieves an object containing the most important configuration values
of the registry. This contains the docker and traefik URIs.
operationId: configurationInfo
responses:
'200':
Expand All @@ -41,51 +43,52 @@ paths:
properties:
DockerHttpApi:
type: string
example: "172.0.2.1:9095"
example: '172.0.2.1:9095'
TraefikProxyUri:
type: string
example: "172.0.2.1:80"
example: '172.0.2.1:80'
/users/authenticate:
post:
tags:
- User Management
summary: Authenticates a user and returns a valid JWT
description: >-
This endpoints validates the username and password that must
be supplied in the Authorization header (using HTTP Basic Authentication).
If valid, a JSON Web Token will be generated and returned, that may be used
to authenticate the user for subsequent requests.
description: >-
This endpoints validates the username and password that must be
supplied in the Authorization header (using HTTP Basic Authentication).
If valid, a JSON Web Token will be generated and returned, that may be
used to authenticate the user for subsequent requests.
operationId: authenticate
parameters:
- in: header
name: Delphi-Authorization
description: >-
Valid JWT that autenticates the calling entity.
description: Valid JWT that autenticates the calling entity.
type: string
required: true
- in: header
name: Authorization
description: >-
HTTP Basic Authentication following the schema 'Basic <User:Password>
where the concatination of username and password is Base64-Encoded.
description: >-
HTTP Basic Authentication following the schema 'Basic
<User:Password> where the concatination of username and password is
Base64-Encoded.
type: string
required: true
responses:
'200':
description: Supplied data is valid, a JWT is returned
description: 'Supplied data is valid, a JWT is returned'
schema:
type: string
example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
example: >-
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
'401':
description: Unauthorized, invalid username / password supplied.
description: 'Unauthorized, invalid username / password supplied.'
/users/add:
post:
tags:
- User Management
summary: Adds a new users for the registry
description: >-
Adds a new user that is passed in the requests entity. The id of the user
will be returned.
Adds a new user that is passed in the requests entity. The id of the
user will be returned.
operationId: addUser
parameters:
- in: body
Expand Down Expand Up @@ -113,13 +116,70 @@ paths:
- Component
responses:
'200':
description: OK, user has been added, id is returned
description: 'OK, user has been added, id is returned'
schema:
type: integer
format: int64
example: 42
'400':
description: Bad request, name already exists
description: 'Bad request, name already exists'
/users:
get:
tags:
- User Management
summary: Gets a list of all registered users
description: >-
Returns a list of all users registered at the registry. Requires caller to have admin privileges.
operationId: allUsers
responses:
'200':
description: "OK, list of users is being returned"
schema:
type: array
items:
$ref: '#/definitions/User'
/users/{Id}:
get:
tags:
- User Management
summary: Gets the user with the specified id
description: >-
Returns the user with the specified id, if that id is present at the registry.
operationId: retrieveUser
parameters:
- in: path
name: Id
required: true
description: Id of the user to retrieve
type: integer
format: int64
responses:
'200':
description: "OK, user is being returned"
schema:
$ref: '#/definitions/User'
'404':
description: "Id not found"
/users/{Id}/remove:
post:
tags:
- User Management
summary: Removes the user with the specified id
description: >-
Removes the user with the specified id, if that id is present at the registry.
operationId: removeUser
parameters:
- in: path
name: Id
required: true
description: Id of the user to remove
type: integer
format: int64
responses:
'200':
description: "OK, user has been removed"
'404':
description: "Id not found"
/instances/register:
post:
tags:
Expand Down Expand Up @@ -657,13 +717,6 @@ paths:
required: true
type: integer
format: int64
- in: body
name: ErrorLog
description: An optional string explaining the failure
required: false
schema:
type: string
example: Something went wrong..
responses:
'200':
description: Report successfully processed.
Expand Down Expand Up @@ -893,6 +946,24 @@ paths:
'500':
description: 'Internal server error, unknown operation result DESCRIPTION'
definitions:
User:
type: object
required:
- userName
- secret
- userType
properties:
id:
type: integer
format: int64
userName:
type: string
example: Ben
userType:
type: string
enum:
- User
- Admin
InstanceLink:
type: object
required:
Expand Down
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,35 @@ The Delphi registry is a server that provides access to all information and oper
* Starting / Stopping / Pausing / Resuming / Deleting instances deployed on the docker host
* Re-Assigning dependencies to instances (e.g. assigning a certain ElasticSearch instance to a Crawler)

## Quick Setup (Linux)
Potentially there two different machines involved in the registry setup, the Docker host machine (*Docker Host*) and the machine the registry is hosted at (*Registry Host*). However, you can also use the same machine for hosting both applications.

On the *Docker Host*, execute the following steps:

1) Clone this repository to your machine
2) Execute the setup script ```Setup/Delphi_install.sh```
3) Deploy [ElasticSearch](https://www.elastic.co/de/products/elasticsearch) by executing ```docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:6.6.0```
4) Expose your Docker HTTP api on port 9095
* Execute ```sudo nano /lib/systemd/system/docker.service```
* Change the line that starts with ```ExecStart``` to look like this: ```ExecStart=/usr/bin/dockerd -H fd:// -H=tcp://0.0.0.0:9095```
* Save your changes and execute ```systemctl daemon-reload``` and ```sudo service docker restart```
5) Note down the IP address of your machine in the LAN ( execute ```ifconfig``` )


On the *Registry Host*, execute the following steps:

1) Clone this repository to your local machine
2) Note down the IP address of your machine in the LAN ( execute ```ifconfig``` )
3) Edit the configuration file located at ```src/main/scala/de/upb/cs/swt/delphi/instanceregistry/Configuration.scala```
* Set ```traefikUri``` to ```http://<DOCKER-HOST-IP-HERE>:80```
* Set ```defaultElasticSearchInstanceHost``` to ```http://<DOCKER-HOST-IP-HERE>```
* Set ```uriInLocalNetwork``` to ```http://<REGISTRY-HOST-IP-HERE>:8087```
* Set ```dockerUri``` to ```http://<DOCKER-HOST-IP-HERE>:9095```
* Set ```jwtSecretKey``` to a secret password not known to anybody else
4) Save your changes. Navigate to the root folder of the repository and execute the application by calling ```sbt run```

The setup of the registry is now complete. You should now be able to connect to the registry component at ```http://<REGISTRY-HOST-IP-HERE>:8087```. You can verify your setup by calling ```curl <REGISTRY-HOST-IP-HERE>:8087/configuration```, which should lead to a ```401 Unauthorized``` response. To find out more about how to authorize yourself, please have look at the **Authorization** section of this document.

## Requirements
In order to compile or execute the instance registry, you must have the latest version of the *Scala Build Tool* (SBT) installed. You can get it [here](https://www.scala-sbt.org/).

Expand Down Expand Up @@ -133,6 +162,8 @@ There are two ways of running the registry application. You can either run the a
### Run the registry directly
If you want to execute the registry directly on your local machine, simply go to the root folder of the repository and execute ```sbt run```. The application will stream all logging output to the terminal. You can terminate any time by pressing *RETURN*.
### Run the registry in Docker
Before creating an Docker image from the registry, make sure that all the network settings in the configuration file are set correctly in regards to the Docker networking infrastructure. Especially the settings ```dockerUri``` and ```uriInLocalNetwork``` are important. On Linux Docker Containers can connect to their host using the default Docker network gateway (```172.17.0.2```), on OSX the host has a defined DNS name (```host.docker.internal```).

For Windows users, to build a docker image containing the registry, go to the root folder of the repository and execute ```sbt docker:publishLocal```. This will build the application, create a docker image named ```delphi-registry:1.0.0-SNAPSHOT```, and register the image at your local docker registry.<br />
For Linux users, the installation script mentioned in **Requirements** section will create docker image for registry named ```delphi-registry:1.0.0-SNAPSHOT```, and registers the image at your local docker registry.

Expand Down
117 changes: 117 additions & 0 deletions project/scalastyle-config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
<scalastyle>
<name>Scalastyle standard configuration</name>
<check level="warning" class="org.scalastyle.file.FileTabChecker" enabled="true"></check>
<check level="warning" class="org.scalastyle.file.FileLengthChecker" enabled="true">
<parameters>
<parameter name="maxFileLength"><![CDATA[800]]></parameter>
</parameters>
</check>
<check level="warning" class="org.scalastyle.file.HeaderMatchesChecker" enabled="true">
<parameters>
<parameter name="header"><![CDATA[// Copyright (C) 2018 The Delphi Team.
// See the LICENCE file distributed with this work for additional
// information regarding copyright ownership.
//
// 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.]]></parameter>
</parameters>
</check>
<check level="warning" class="org.scalastyle.scalariform.SpacesAfterPlusChecker" enabled="true"></check>
<check level="warning" class="org.scalastyle.file.WhitespaceEndOfLineChecker" enabled="true"></check>
<check level="warning" class="org.scalastyle.scalariform.SpacesBeforePlusChecker" enabled="true"></check>
<check level="warning" class="org.scalastyle.file.FileLineLengthChecker" enabled="true">
<parameters>
<parameter name="maxLineLength"><![CDATA[160]]></parameter>
<parameter name="tabSize"><![CDATA[4]]></parameter>
</parameters>
</check>
<check level="warning" class="org.scalastyle.scalariform.ClassNamesChecker" enabled="true">
<parameters>
<parameter name="regex"><![CDATA[[A-Z][A-Za-z]*]]></parameter>
</parameters>
</check>
<check level="warning" class="org.scalastyle.scalariform.ObjectNamesChecker" enabled="true">
<parameters>
<parameter name="regex"><![CDATA[[A-Z][A-Za-z]*]]></parameter>
</parameters>
</check>
<check level="warning" class="org.scalastyle.scalariform.PackageObjectNamesChecker" enabled="true">
<parameters>
<parameter name="regex"><![CDATA[^[a-z][A-Za-z]*$]]></parameter>
</parameters>
</check>
<check level="warning" class="org.scalastyle.scalariform.EqualsHashCodeChecker" enabled="true"></check>
<check level="warning" class="org.scalastyle.scalariform.IllegalImportsChecker" enabled="true">
<parameters>
<parameter name="illegalImports"><![CDATA[sun._,java.awt._]]></parameter>
</parameters>
</check>
<check level="warning" class="org.scalastyle.scalariform.ParameterNumberChecker" enabled="true">
<parameters>
<parameter name="maxParameters"><![CDATA[8]]></parameter>
</parameters>
</check>
<check level="warning" class="org.scalastyle.scalariform.MagicNumberChecker" enabled="false">
<parameters>
<parameter name="ignore"><![CDATA[-1,0,1,2,3]]></parameter>
</parameters>
</check>
<check level="warning" class="org.scalastyle.scalariform.NoWhitespaceBeforeLeftBracketChecker" enabled="true"></check>
<check level="warning" class="org.scalastyle.scalariform.NoWhitespaceAfterLeftBracketChecker" enabled="true"></check>
<check level="warning" class="org.scalastyle.scalariform.ReturnChecker" enabled="true"></check>
<check level="warning" class="org.scalastyle.scalariform.NullChecker" enabled="true"></check>
<check level="warning" class="org.scalastyle.scalariform.NoCloneChecker" enabled="true"></check>
<check level="warning" class="org.scalastyle.scalariform.NoFinalizeChecker" enabled="true"></check>
<check level="warning" class="org.scalastyle.scalariform.CovariantEqualsChecker" enabled="true"></check>
<check level="warning" class="org.scalastyle.scalariform.StructuralTypeChecker" enabled="true"></check>
<check level="warning" class="org.scalastyle.file.RegexChecker" enabled="true">
<parameters>
<parameter name="regex"><![CDATA[println]]></parameter>
</parameters>
</check>
<check level="warning" class="org.scalastyle.scalariform.NumberOfTypesChecker" enabled="true">
<parameters>
<parameter name="maxTypes"><![CDATA[30]]></parameter>
</parameters>
</check>
<check level="warning" class="org.scalastyle.scalariform.CyclomaticComplexityChecker" enabled="true">
<parameters>
<parameter name="maximum"><![CDATA[10]]></parameter>
</parameters>
</check>
<check level="warning" class="org.scalastyle.scalariform.UppercaseLChecker" enabled="true"></check>
<check level="warning" class="org.scalastyle.scalariform.SimplifyBooleanExpressionChecker" enabled="true"></check>
<check level="warning" class="org.scalastyle.scalariform.IfBraceChecker" enabled="true">
<parameters>
<parameter name="singleLineAllowed"><![CDATA[true]]></parameter>
<parameter name="doubleLineAllowed"><![CDATA[false]]></parameter>
</parameters>
</check>
<check level="warning" class="org.scalastyle.scalariform.MethodLengthChecker" enabled="true">
<parameters>
<parameter name="maxLength"><![CDATA[50]]></parameter>
</parameters>
</check>
<check level="warning" class="org.scalastyle.scalariform.MethodNamesChecker" enabled="true">
<parameters>
<parameter name="regex"><![CDATA[^[a-z][A-Za-z0-9]*$]]></parameter>
</parameters>
</check>
<check level="warning" class="org.scalastyle.scalariform.NumberOfMethodsInTypeChecker" enabled="true">
<parameters>
<parameter name="maxMethods"><![CDATA[50]]></parameter>
</parameters>
</check>
<check level="warning" class="org.scalastyle.scalariform.PublicMethodsHaveTypeChecker" enabled="true"></check>
<check level="warning" class="org.scalastyle.file.NewLineAtEofChecker" enabled="true"></check>
<check level="warning" class="org.scalastyle.file.NoNewLineAtEofChecker" enabled="false"></check>
</scalastyle>
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
// Copyright (C) 2018 The Delphi Team.
// See the LICENCE file distributed with this work for additional
// information regarding copyright ownership.
//
// 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 de.upb.cs.swt.delphi.instanceregistry

import akka.actor.{ActorSystem, ExtendedActorSystem}
import akka.event.{BusLogging, LoggingAdapter}

trait AppLogging {
def log(implicit system: ActorSystem): LoggingAdapter = new BusLogging(system.eventStream, this.getClass.getName, this.getClass, system.asInstanceOf[ExtendedActorSystem].logFilter)
def log(implicit system: ActorSystem): LoggingAdapter = new BusLogging(
system.eventStream,
this.getClass.getName,
this.getClass,
system.asInstanceOf[ExtendedActorSystem].logFilter)
}
Loading