-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: make account identifiers en- & decodable with central registry
- Loading branch information
Showing
26 changed files
with
123 additions
and
72 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...aries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/accounts/AccountStore.kt
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
2 changes: 1 addition & 1 deletion
2
...th/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/accounts/EditableAccountStore.kt
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
4 changes: 2 additions & 2 deletions
4
...uth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/accounts/ExampleAccountStore.kt
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
21 changes: 21 additions & 0 deletions
21
...thnz/src/main/kotlin/id/walt/ktorauthnz/accounts/identifiers/AccountIdentifierRegistry.kt
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,21 @@ | ||
package id.walt.ktorauthnz.accounts.identifiers | ||
|
||
import id.walt.ktorauthnz.accounts.identifiers.methods.* | ||
|
||
object AccountIdentifierRegistry { | ||
|
||
private val defaultIdentifiers = | ||
listOf(EmailIdentifier, JWTIdentifier, LDAPIdentifier, OIDCIdentifier, RADIUSIdentifier, UsernameIdentifier) | ||
|
||
private val factories: MutableMap<String, AccountIdentifier.AccountIdentifierFactory<out AccountIdentifier>> = | ||
defaultIdentifiers.associateBy { it.identifierName }.toMutableMap() | ||
|
||
fun registerAccountIdentifier(identifierFactory: AccountIdentifier.AccountIdentifierFactory<out AccountIdentifier>) = | ||
factories.set(identifierFactory.identifierName, identifierFactory) | ||
|
||
fun getAccountIdentifier(type: String, accountIdentifierDataString: String): AccountIdentifier { | ||
val factory = factories[type] ?: error("No such account identifier known") | ||
|
||
return factory.fromAccountIdentifierDataString(accountIdentifierDataString) | ||
} | ||
} |
8 changes: 0 additions & 8 deletions
8
...id-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/accounts/identifiers/EmailIdentifier.kt
This file was deleted.
Oops, something went wrong.
9 changes: 0 additions & 9 deletions
9
...ltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/accounts/identifiers/JWTIdentifier.kt
This file was deleted.
Oops, something went wrong.
9 changes: 0 additions & 9 deletions
9
...tid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/accounts/identifiers/LDAPIdentifier.kt
This file was deleted.
Oops, something went wrong.
9 changes: 0 additions & 9 deletions
9
...tid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/accounts/identifiers/OIDCIdentifier.kt
This file was deleted.
Oops, something went wrong.
9 changes: 0 additions & 9 deletions
9
...d-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/accounts/identifiers/RADIUSIdentifier.kt
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
...ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/accounts/identifiers/UsernameIdentifier.kt
This file was deleted.
Oops, something went wrong.
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
12 changes: 12 additions & 0 deletions
12
...authnz/src/main/kotlin/id/walt/ktorauthnz/accounts/identifiers/methods/EmailIdentifier.kt
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,12 @@ | ||
package id.walt.ktorauthnz.accounts.identifiers.methods | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class EmailIdentifier(val email: String) : AccountIdentifier("email") { | ||
override fun toDataString() = email | ||
|
||
companion object : AccountIdentifierFactory<EmailIdentifier>("email") { | ||
override fun fromAccountIdentifierDataString(dataString: String): EmailIdentifier = EmailIdentifier(dataString) | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...r-authnz/src/main/kotlin/id/walt/ktorauthnz/accounts/identifiers/methods/JWTIdentifier.kt
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,12 @@ | ||
package id.walt.ktorauthnz.accounts.identifiers.methods | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class JWTIdentifier(val subject: String) : AccountIdentifier("jwt") { | ||
override fun toDataString() = subject | ||
|
||
companion object : AccountIdentifierFactory<JWTIdentifier>("jwt") { | ||
override fun fromAccountIdentifierDataString(dataString: String) = JWTIdentifier(dataString) | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...-authnz/src/main/kotlin/id/walt/ktorauthnz/accounts/identifiers/methods/LDAPIdentifier.kt
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,14 @@ | ||
package id.walt.ktorauthnz.accounts.identifiers.methods | ||
|
||
import kotlinx.serialization.Serializable | ||
import kotlinx.serialization.encodeToString | ||
import kotlinx.serialization.json.Json | ||
|
||
@Serializable | ||
data class LDAPIdentifier(val host: String, val name: String) : AccountIdentifier("ldap") { | ||
override fun toDataString() = Json.encodeToString(this) | ||
|
||
companion object : AccountIdentifierFactory<LDAPIdentifier>("ldap") { | ||
override fun fromAccountIdentifierDataString(dataString: String) = Json.decodeFromString<LDAPIdentifier>(dataString) | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...-authnz/src/main/kotlin/id/walt/ktorauthnz/accounts/identifiers/methods/OIDCIdentifier.kt
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,12 @@ | ||
package id.walt.ktorauthnz.accounts.identifiers.methods | ||
|
||
import kotlinx.serialization.encodeToString | ||
import kotlinx.serialization.json.Json | ||
|
||
data class OIDCIdentifier(val host: String, val name: String) : AccountIdentifier("oidc") { | ||
override fun toDataString() = Json.encodeToString(this) | ||
|
||
companion object : AccountIdentifierFactory<OIDCIdentifier>("oidc") { | ||
override fun fromAccountIdentifierDataString(dataString: String) = Json.decodeFromString<OIDCIdentifier>(dataString) | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...uthnz/src/main/kotlin/id/walt/ktorauthnz/accounts/identifiers/methods/RADIUSIdentifier.kt
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,14 @@ | ||
package id.walt.ktorauthnz.accounts.identifiers.methods | ||
|
||
import kotlinx.serialization.Serializable | ||
import kotlinx.serialization.encodeToString | ||
import kotlinx.serialization.json.Json | ||
|
||
@Serializable | ||
data class RADIUSIdentifier(val host: String, val name: String) : AccountIdentifier("radius") { | ||
override fun toDataString() = Json.encodeToString(this) | ||
|
||
companion object : AccountIdentifierFactory<RADIUSIdentifier>("radius") { | ||
override fun fromAccountIdentifierDataString(dataString: String) = Json.decodeFromString<RADIUSIdentifier>(dataString) | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...hnz/src/main/kotlin/id/walt/ktorauthnz/accounts/identifiers/methods/UsernameIdentifier.kt
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,12 @@ | ||
package id.walt.ktorauthnz.accounts.identifiers.methods | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class UsernameIdentifier(val name: String) : AccountIdentifier("username") { | ||
override fun toDataString() = name | ||
|
||
companion object : AccountIdentifierFactory<UsernameIdentifier>("username") { | ||
override fun fromAccountIdentifierDataString(dataString: String) = UsernameIdentifier(dataString) | ||
} | ||
} |
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
4 changes: 2 additions & 2 deletions
4
...libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/EmailPass.kt
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
4 changes: 2 additions & 2 deletions
4
waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/LDAP.kt
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
2 changes: 1 addition & 1 deletion
2
waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/OIDC.kt
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
4 changes: 2 additions & 2 deletions
4
...id-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/RADIUS.kt
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
4 changes: 2 additions & 2 deletions
4
...-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/UserPass.kt
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
2 changes: 1 addition & 1 deletion
2
.../waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/UserPassBasedAuthMethod.kt
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