Commit Graph

79 Commits

Author SHA1 Message Date
Yannick Schaus
150ced7012
[auth] Don't allow creating API tokens with no name (#1969)
Fixes https://github.com/openhab/openhab-webui/issues/674.

Remove unnecessary checks and fix exception message.
Add Norwegian messages for auth pages.

Signed-off-by: Yannick Schaus <github@schaus.net>
2020-12-20 12:48:46 +01:00
Yannick Schaus
cc7edadd96
Auth messages translations (RC2) (#1957)
This contains an update to the messages for the login,
change password, create API token pages from Crowdin
in ISO-8859 format.

Contains a completed German translation update, and
the following new completed languages:
- Czech
- Finnish
- Hungarian
- Portuguese (Brazil)
- Swedish
- Ukrainian

Dutch, French, Italian are unchanged from RC1.

Signed-off-by: Yannick Schaus <github@schaus.net>
2020-12-17 20:37:15 +01:00
Yannick Schaus
eb176e14d2
Translated messages for auth pages (#1930)
This is the PR with the messages.properties files in
Dutch, German (partial) and Italian extracted from
#1929 and converted to the proper ISO-8859 encoding.

Signed-off-by: Yannick Schaus <github@schaus.net>
2020-12-13 21:09:13 +01:00
Yannick Schaus
67bdfa3ad6
Auth pages i18n (#1913)
This implements localized messages for the authorize, change
password and create API token pages using a resource bundle.

Messages in English & French are included.

Signed-off-by: Yannick Schaus <github@schaus.net>
2020-12-12 22:42:56 +01:00
Wouter Born
d5e7fe3ab3
Update LastNPE EEAs to 2.2.1 (#1821)
Signed-off-by: Wouter Born <github@maindrain.net>
2020-11-17 16:29:09 +01:00
Wouter Born
0281c10036
[infrastructure] add external null-annotations (#1775)
Add EEAs and fix null analysis errors.

Related to:

* #888
* openhab/openhab-addons#8848

Signed-off-by: Wouter Born <github@maindrain.net>
2020-11-03 21:33:48 +01:00
Yannick Schaus
8b52cab5ef
[REST Auth] API tokens & openhab:users console command (#1735)
This adds API tokens as a new credential type. Their format is:
`oh.<name>.<random chars>`

The "oh." prefix is used to tell them apart from a JWT access token,
because they're both used as a Bearer authorization scheme, but there
is no semantic value attached to any of the other parts.

They are stored hashed in the user's profile, and can be listed, added
or removed managed with the new `openhab:users` console command.

Currently the scopes are still not checked, but ultimately they could
be, for instance a scope of e.g. `user admin.items` would mean that the
API token can be used to perform user operations like retrieving info
or sending a command, _and_ managing the items, but nothing else -
even if the user has more permissions because of their role (which
will of course still be checked).

Tokens are normally passed in the Authorization header with the Bearer
scheme, or the X-OPENHAB-TOKEN header, like access tokens.
As a special exception, API tokens can also be used with the Basic
authorization scheme, **even if the allowBasicAuth** option is not
enabled in the "API Security" service, because there's no additional
security risk in allowing that. In that case, the token should be
passed as the username and the password MUST be empty.

In short, this means that all these curl commands will work:
- `curl -H 'Authorization: Bearer <token>' http://localhost:8080/rest/inbox`
- `curl -H 'X-OPENHAB-TOKEN: <token>' http://localhost:8080/rest/inbox`
- `curl -u '<token>[:]' http://localhost:8080/rest/inbox`
- `curl http://<token>@localhost:8080/rest/inbox`

2 REST API operations were adding to the AuthResource, to allow
authenticated users to list their tokens or remove (revoke) one.
Self-service for creating a token or changing the password is more
sensitive so these should be handled with a servlet and pages devoid
of any JavaScript instead of REST API calls, therefore for now they'll
have to be done with the console.

This also fixes regressions introduced with #1713 - the operations
annotated with @RolesAllowed({ Role.USER }) only were not authorized
for administrators anymore.

* Generate a unique salt for each token

Reusing the password salt is bad practice, and changing the
password changes the salt as well which makes all tokens
invalid.

Put the salt in the same field as the hash (concatenated
with a separator) to avoid modifying the JSON DB schema.

* Fix API token authentication, make scope available to security context

The X-OPENHAB-TOKEN header now has priority over the Authorization
header to credentials, if both are set.

* Add self-service pages to change password & create new API token

Signed-off-by: Yannick Schaus <github@schaus.net>
2020-10-25 12:04:40 +01:00
Yannick Schaus
e1771c3b74
Add dark mode support in authorize page (#1600)
Closes https://github.com/openhab/openhab-webui/issues/309.
This only honors the scheme as reported by the `prefers-color-scheme` CSS media feature, i.e. local overrides for the main UI are not taken into account.
Tweak submit button styles to mimic the main UI's desktop theme.

Signed-off-by: Yannick Schaus <github@schaus.net>
2020-08-21 11:13:49 +02:00
Christoph Weitkamp
8808f04c30
Removed dependency on 'org.apache.commons.io' (#1441)
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
2020-05-21 15:17:00 +02:00
Wouter Born
61e17ce39e
Upgrade SAT and Spotless, apply Spotless and enable check (#1446)
* Update SAT and Spotless dependencies
* Apply Spotless and enable check

Signed-off-by: Wouter Born <github@maindrain.net>
2020-04-26 11:15:24 +02:00
Wouter Born
ed4b5ff94b
Reconfigure and apply Spotless (#1442)
Adds a configuration for feature.xml files which will be necessary for https://github.com/openhab/static-code-analysis/pull/375

Also applies the results of running Spotless

Signed-off-by: Wouter Born <github@maindrain.net>
2020-04-23 17:17:12 +02:00
Christoph Weitkamp
e17046ea3f
Removed dependency on 'org.apache.commons.httpclient' (#1436)
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
2020-04-20 22:31:46 +02:00
Yannick Schaus
fe4e276b68
Implementation of a JWT-based OAuth2 flow for the admin API (#1389)
* Initial implementation of a JWT-based OAuth2 flow for the admin API

Implements #1388.

Signed-off-by: Yannick Schaus <github@schaus.net>
2020-03-23 22:36:11 +01:00
Wouter Born
18d0a52d02 Switch to Java 11 and drop Java 8 support (#1305)
Signed-off-by: Wouter Born <github@maindrain.net>
2020-01-12 22:32:28 +01:00
Christoph Weitkamp
84009652a8 Changed configurationPid prefixes from 'org.openhab.core' ot 'org.openhab' (#1314)
* Changed configurationPid prefixes from 'org.openhab.core' ot 'org.openhab'

Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
2020-01-02 09:12:34 +01:00
Wouter Born
3811cb9560 Update copyright headers to 2020 (#1309)
* Update copyright headers to 2020

Signed-off-by: Wouter Born <github@maindrain.net>
2020-01-01 18:06:34 +01:00
Christoph Weitkamp
800956598b Applied spotless formatter (#1302)
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
2019-12-30 22:55:19 +01:00
Christoph Weitkamp
59675788e0 Renamed packages
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
2019-12-28 12:18:16 +01:00
Christoph Weitkamp
fca7c215a5 Moved files to new location
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
2019-12-28 12:18:16 +01:00
jenkins
bc6a380297 [unleash-maven-plugin] Preparation for next development cycle. 2019-12-15 14:55:36 +00:00
Christoph Weitkamp
91617d8af8 Fixed POM XML Shema Definition path (#1119)
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
2019-10-12 08:52:16 +02:00
Wouter Born
3d52c72a91 Fix SAT AuthorContributionDescriptionCheck findings (#1110)
Signed-off-by: Wouter Born <github@maindrain.net>
2019-10-10 11:36:05 +02:00
Christoph Weitkamp
b3802d565d [infrastructure] bump SAT to 0.7.0 (#1007)
* Bump SAT version; Fixed high priority findings
* Defined path to feature file to avoid warnings

Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
2019-08-29 09:17:35 +02:00
Markus Rathgeb
ef05b4d878 start with an upper case on "initial contribution" (#931)
Related to: https://github.com/openhab/openhab-core/pull/916/#discussion_r305082016

Signed-off-by: Markus Rathgeb <maggu2810@gmail.com>
2019-07-21 12:24:58 +02:00
Wouter Born
cbb96945f0 Ignore and remove Eclipse project specific settings (#677)
Signed-off-by: Wouter Born <github@maindrain.net>
2019-03-26 13:04:09 +01:00
Wouter Born
48d873a32b Use openHAB license headers (#632)
Signed-off-by: Wouter Born <github@maindrain.net>
2019-03-06 16:10:00 +01:00
Hilbrand Bouwkamp
d342afbc4e Updated NOTICE files to openHAB (#578)
Signed-off-by: Hilbrand Bouwkamp <hilbrand@h72.nl>
2019-02-15 10:46:18 +01:00
Markus Rathgeb
fbca7e806f remove project specific JDT settings (#481)
Done per request by @wborn.
Related to: https://github.com/openhab/openhab-core/pull/476#discussion_r251566034

Signed-off-by: Markus Rathgeb <maggu2810@gmail.com>
2019-01-29 10:24:39 +01:00
Markus Rathgeb
a37cceab67 mavenize openHAB and integrate mavenized ESH repository (#467)
* mavenize openHAB and integrate mavenized ESH repository

Signed-off-by: Markus Rathgeb <maggu2810@gmail.com>
2019-01-28 13:07:31 +01:00