-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #25903: Refactor API tokens after clear-text removal #6031
base: branches/rudder/8.3
Are you sure you want to change the base?
Fixes #25903: Refactor API tokens after clear-text removal #6031
Conversation
ef47b5e
to
3d3c090
Compare
Commit modified |
3d3c090
to
5c706c4
Compare
Commit modified |
5c706c4
to
d060cfb
Compare
Commit modified |
d060cfb
to
e729750
Compare
Commit modified |
Commit modified |
e729750
to
2057a85
Compare
webapp/sources/rudder/rudder-core/src/main/scala/com/normation/rudder/api/DataStructures.scala
Outdated
Show resolved
Hide resolved
webapp/sources/rudder/rudder-core/src/main/scala/com/normation/rudder/api/DataStructures.scala
Outdated
Show resolved
Hide resolved
Fixes #25903: Refactor API tokens after clear-text removal
PR updated with a new commit |
webapp/sources/rudder/rudder-core/src/main/scala/com/normation/rudder/api/DataStructures.scala
Outdated
Show resolved
Hide resolved
Fixes #25903: Refactor API tokens after clear-text removal
PR updated with a new commit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great change !
There only is some compilation problems
@@ -536,7 +536,7 @@ class APIAccountSerialisationImpl(xmlVersion: String) extends APIAccountSerialis | |||
( | |||
<id>{account.id.value}</id> | |||
<name>{account.name.value}</name> | |||
<token>{account.token.value}</token> | |||
<token>{account.token.exposeHash()}</token> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since in an Option
is returned, it will write Some("thehash")
, and this would break. It should be a String, so .getOrElse("")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It compiles now but this will cause a problem without the getOrElse : https://scastie.scala-lang.org/h2QlFY3BSzqlEBruNceAvA
webapp/sources/rudder/rudder-rest/src/main/scala/com/normation/rudder/users/User.scala
Outdated
Show resolved
Hide resolved
webapp/sources/rudder/rudder-core/src/main/scala/com/normation/rudder/api/DataStructures.scala
Show resolved
Hide resolved
webapp/sources/rudder/rudder-web/src/main/elm/sources/Accounts/JsonDecoder.elm
Show resolved
Hide resolved
…xt removal Fixes #25903: Refactor API tokens after clear-text removal
PR updated with a new commit |
@@ -1142,7 +1142,7 @@ class LDAPEntityMapper( | |||
mod.resetValuesTo(A_API_UUID, principal.id.value) | |||
mod.resetValuesTo(A_NAME, principal.name.value) | |||
mod.resetValuesTo(A_CREATION_DATETIME, GeneralizedTime(principal.creationDate).toString) | |||
mod.resetValuesTo(A_API_TOKEN, principal.token.exposeHash()) | |||
mod.resetValuesTo(A_API_TOKEN, principal.token.exposeHash().getOrElse("")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that will work. The API token is a mandatory field in the schema for apiAccount
.
Perhaps we want to be able to have that case, but it seems to be a hard hypothesis in the lower layout. We can perhaps workaround it with a marker value that would be extracted as none.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or even v2:
https://issues.rudder.io/issues/25903
A similar change needs to be done in the api-authorizations plugins for user tokens.
Backend
Data types
Split the
ApiToken
type, which used to contain both clear-text and hashed values into two separate types to prevent confusions and prevent misusage as much as possible:ApiTokenSecret
: The token value, to be sent to the creator and not stored on the serverApiTokenHash
: The token hash, as stored (either in LDAP or memory)Also modifying the account types:
ApiAccount
now contains aApiTokenHash
NewApiAccount
is created, to be used after creation, and contains aApiTokenSecret
Notes:
expose()
methods (and make the value private)Usage
The JSON serialization of the accounts, used by the API tokens Web interface, is modified:
Frontend