-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Gi alle tilgang til spesifikke routes (#6454)
- Loading branch information
1 parent
d0fd478
commit df678be
Showing
10 changed files
with
65 additions
and
29 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -36,12 +36,12 @@ spec: | |
azure: | ||
application: | ||
enabled: true | ||
allowAllUsers: true | ||
tenant: nav.no | ||
claims: | ||
groups: | ||
- id: 650684ff-8107-4ae4-98fc-e18b5cf3188b # etterlatte | ||
- id: 1a424f32-16a4-4b97-9d77-3e9e781a887e # (DG) NAV Team Etterlatte | ||
- id: 20e720b3-4be7-42ec-aff4-af613f25361b # po-pensjon | ||
# AD-gruppe for utviklere på Team Etterlatte ([email protected]) | ||
- id: 650684ff-8107-4ae4-98fc-e18b5cf3188b | ||
sidecar: | ||
enabled: true | ||
autoLogin: true | ||
|
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
33 changes: 33 additions & 0 deletions
33
apps/etterlatte-testdata/src/main/kotlin/no/nav/etterlatte/testdata/Auth.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,33 @@ | ||
package no.nav.etterlatte.no.nav.etterlatte.testdata | ||
|
||
import io.ktor.http.HttpStatusCode | ||
import io.ktor.server.application.ApplicationCall | ||
import io.ktor.server.application.call | ||
import io.ktor.server.response.respond | ||
import io.ktor.util.pipeline.PipelineContext | ||
import no.nav.etterlatte.libs.ktor.token.Saksbehandler | ||
import no.nav.etterlatte.libs.ktor.token.Systembruker | ||
import no.nav.etterlatte.libs.ktor.token.brukerTokenInfo | ||
|
||
object ADGruppe { | ||
const val ETTERLATTE = "650684ff-8107-4ae4-98fc-e18b5cf3188b" | ||
} | ||
|
||
suspend inline fun PipelineContext<*, ApplicationCall>.kunEtterlatteUtvikling(onSuccess: () -> Unit) { | ||
val rollerEllerAdGrupper = | ||
when (brukerTokenInfo) { | ||
is Saksbehandler -> (call.brukerTokenInfo as Saksbehandler).groups | ||
is Systembruker -> (call.brukerTokenInfo as Systembruker).roller | ||
} | ||
if (rollerEllerAdGrupper.any { it == ADGruppe.ETTERLATTE }) { | ||
onSuccess() | ||
} else { | ||
call.respond(HttpStatusCode.Unauthorized, "Mangler etterlatte-rolle") | ||
} | ||
} | ||
|
||
fun PipelineContext<*, ApplicationCall>.harGyldigAdGruppe(): Boolean = | ||
when (brukerTokenInfo) { | ||
is Saksbehandler -> (brukerTokenInfo as Saksbehandler).groups | ||
is Systembruker -> (brukerTokenInfo as Systembruker).roller | ||
}.any { it == ADGruppe.ETTERLATTE } |
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
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
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
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