Skip to content

Commit

Permalink
Rename to fakeIdp (#290)
Browse files Browse the repository at this point in the history
  • Loading branch information
olger authored Nov 5, 2023
1 parent 7f37842 commit cb68e4e
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 57 deletions.
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
#docker buildx build --platform=linux/amd64,linux/arm64 --push \
docker buildx build --platform=linux/amd64 --push \
--progress=plain\
-t spectare/oidc-token-test-service:latest \
-t spectare/fakeidp:latest \
--build-arg VERSION=$(cat /tmp/version.txt) \
--build-arg COMMITID=${CIRCLE_SHA1} \
.
Expand All @@ -83,8 +83,8 @@ jobs:
#docker buildx build --platform=linux/arm64,linux/amd64 --push \
docker buildx build --platform=linux/amd64 --push \
--progress=plain\
-t spectare/oidc-token-test-service:$TAG \
-t spectare/oidc-token-test-service:latest \
-t spectare/fakeidp:$TAG \
-t spectare/fakeidp:latest \
--build-arg VERSION=$(cat /tmp/version.txt) \
--build-arg COMMITID=${CIRCLE_SHA1} \
.
Expand Down
66 changes: 33 additions & 33 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
authors = ["Olger Warnier <[email protected]>"]
edition = "2021"
name = "oidc-token-test-service"
name = "fakeidp"
version = "0.3.0"

[dependencies]
Expand Down
16 changes: 8 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
# Cargo Build Stage
# ------------------------------------------------------------------------------

FROM rust:1.69.0-buster as cargo-build
FROM rust:1.73.0-bookworm as cargo-build

RUN apt-get update

WORKDIR /usr/src/oidc-token-test-service
WORKDIR /usr/src/fakeidp

COPY Cargo.toml Cargo.toml

Expand All @@ -24,23 +24,23 @@ RUN cargo build --release
# Final Stage
# ------------------------------------------------------------------------------

FROM debian:bullseye-slim
FROM debian:bookworm-slim

RUN apt-get update && rm -rf /var/lib/apt/lists/*

RUN addgroup --system -gid 1000 runtme

RUN adduser --system --disabled-login --shell /bin/sh -uid 1001 --ingroup runtme runtme

COPY --from=cargo-build /usr/src/oidc-token-test-service/target/release/oidc-token-test-service /usr/local/bin/oidc-token-test-service
COPY --from=cargo-build /usr/src/fakeidp/target/release/fakeidp /usr/local/bin/fakeidp

COPY --from=cargo-build /usr/src/oidc-token-test-service/keys/private_key.der /usr/local/etc/private_key.der
COPY --from=cargo-build /usr/src/fakeidp/keys/private_key.der /usr/local/etc/private_key.der

RUN mkdir -p "/usr/local/fakeidp/static"

COPY --from=cargo-build /usr/src/oidc-token-test-service/static/* /usr/local/fakeidp/static/
COPY --from=cargo-build /usr/src/fakeidp/static/* /usr/local/fakeidp/static/

RUN chown runtme:runtme /usr/local/bin/oidc-token-test-service
RUN chown runtme:runtme /usr/local/bin/fakeidp

USER runtme

Expand All @@ -50,4 +50,4 @@ ENV PORT="8080"

ENV EXPOSED_HOST="http://localhost:8080"

CMD ["sh", "-c", "oidc-token-test-service /usr/local/etc/private_key.der -p ${PORT} -b ${BIND} -e ${EXPOSED_HOST} -f /usr/local/fakeidp/static"]
CMD ["sh", "-c", "fakeidp /usr/local/etc/private_key.der -p ${PORT} -b ${BIND} -e ${EXPOSED_HOST} -f /usr/local/fakeidp/static"]
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ The -h for the exposed host is now -e (that makes the help work as it should)
Running the binary works follows:

```bash
oidc-token-test-service
fakeidp
Allows to generate any valid JWT for OIDC

❯ ./target/debug/oidc-token-test-service --help
Usage: oidc-token-test-service [OPTIONS] [KEYFILE]
❯ ./target/debug/fakeidp --help
Usage: fakeidp [OPTIONS] [KEYFILE]

Arguments:
[KEYFILE] Location of the RSA DER keypair as a file
Expand Down Expand Up @@ -59,7 +59,7 @@ Note that a keypair is provided by default.
### The other option is to run it as a DOCKER container:

```bash
docker run -p9090:9090 -e BIND=0.0.0.0 -e PORT=9090 -e EXPOSED_HOST=http://localhost:9090 spectare/oidc-token-test-service:latest
docker run -p9090:9090 -e BIND=0.0.0.0 -e PORT=9090 -e EXPOSED_HOST=http://localhost:9090 spectare/fakeidp:latest
```

where BIND and PORT are environment variables that allow you to change the endpoint binding and address within the container.
Expand Down
17 changes: 9 additions & 8 deletions src/userinfo.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::discovery::create_jwk_set;
use actix_4_jwt_auth::{
AuthenticatedUser, Oidc, OidcConfig, OidcBiscuitValidator,
biscuit::Validation
biscuit::Validation, AuthenticatedUser, Oidc, OidcBiscuitValidator, OidcConfig,
};
use actix_web::{web, Error, HttpResponse};
use biscuit::jws::*;
Expand Down Expand Up @@ -36,10 +35,11 @@ mod tests {
}

fn create_validator(issuer: String) -> OidcBiscuitValidator {
OidcBiscuitValidator { options: ValidationOptions {
OidcBiscuitValidator {
options: ValidationOptions {
issuer: Validation::Validate(issuer),
..ValidationOptions::default()
}
},
}
}

Expand All @@ -48,7 +48,7 @@ mod tests {
{
"iss": "http://localhost:8080",
"sub": "F82E617D-DEAF-4EE6-8F96-CF3409060CA2",
"aud": "oidc-token-mock",
"aud": "fakeidp",
"email": "[email protected]",
"email_verified": true,
"name": "Arie Ministrone"
Expand Down Expand Up @@ -98,7 +98,6 @@ mod tests {
Ok(())
}


#[actix_rt::test]
async fn test_route_userinfo_no_token() -> Result<(), Error> {
let rsa_keys = Secret::rsa_keypair_from_file("./keys/private_key.der")
Expand All @@ -123,8 +122,10 @@ mod tests {

let resp = test::try_call_service(&app, req).await;
let error = resp.unwrap_err();
assert_eq!(error.to_string(), "No token found or token is not authorized");
assert_eq!(
error.to_string(),
"No token found or token is not authorized"
);
Ok(())
}
}

0 comments on commit cb68e4e

Please sign in to comment.