Fmstrat / Fmstrat/SxncD

[Bug]: Cannot Setup OIDC with Authelia

Open
#2 0 comments 0 reactions 0 assignees View on GitHub
bug review
Dominant language
JavaScript
Stars
3
Forks
0
PR merge metrics
No merged PRs in 30d

Description

### Version, or commit number if you are using a branch and stipulate your fork if one exists

0.1

### What happened?

I have set up OIDC authentication with Authelia and am able to go through the login flow, but the dashboard doesn't load - I see this error:
```
TypeError: /app/http/views/dashboard.ejs:4
2|
3|
>> 4| <%- include('./include/header.ejs', { title: 'SxncD - Dashboard' }) %>
5|
6| <% for (const type in config.appModules) { %>
7| <%- include('./include/app.ejs', { app: config.appModules[type] }) %>

/app/http/views/include/header.ejs:76
74| <% } else { %>
75|


>> 76| <%= user.username.charAt(0).toUpperCase() %>
77|

78| <% } %>
79| <% } %>

Cannot read properties of null (reading 'charAt')
at eval ("/app/http/views/include/header.ejs":24:40)
at header (/app/node_modules/ejs/lib/ejs.js:703:17)
at include (/app/node_modules/ejs/lib/ejs.js:701:39)
at eval ("/app/http/views/dashboard.ejs":12:17)
at dashboard (/app/node_modules/ejs/lib/ejs.js:703:17)
at tryHandleCache (/app/node_modules/ejs/lib/ejs.js:274:36)
at exports.renderFile [as engine] (/app/node_modules/ejs/lib/ejs.js:491:10)
at View.render (/app/node_modules/express/lib/view.js:135:8)
at tryRender (/app/node_modules/express/lib/application.js:657:10)
at Function.render (/app/node_modules/express/lib/application.js:609:3)
```

These are the relevant environment variables (actual values removed):
```yaml
AUTH_MODULES: oidc
OIDC_CLIENT_ID: sxncd
OIDC_CLIENT_SECRET: $AUTHELIA_SXNCD_CLIENT_SECRET
OIDC_ISSUER: https://auth.$SERVICES_DOMAIN
OIDC_AUTHORIZATION_URL: https://auth.$SERVICES_DOMAIN/api/oidc/authorization
OIDC_TOKEN_URL: https://auth.$SERVICES_DOMAIN/api/oidc/token
OIDC_USERINFO_URL: https://auth.$SERVICES_DOMAIN/api/oidc/userinfo
```

And this is the relevant part of my Authelia config:
```yaml
identity_providers:
oidc:
## See: https://www.authelia.com/c/oidc
hmac_secret: '$AUTHELIA_OIDC_HMAC_SECRET'
jwks:
- key: |
$AUTHELIA_JWKS_KEY
enable_client_debug_messages: false
clients:
- client_id: 'sxncd'
client_name: 'sxncd'
client_secret: '$AUTHELIA_SXNCD_CLIENT_SECRET'
public: false
authorization_policy: 'two_factor'
redirect_uris:
- https://sxncd.${SERVICES_DOMAIN}/callback/oidc
scopes:
- 'openid'
- 'profile'
- 'email'
userinfo_signed_response_alg: 'none'
token_endpoint_auth_method: 'client_secret_post'
```

Note I'm already using this instance of Authelia to login to Immich and Sharry, so I know it can work. May be a misconfiguration somewhere. At the same time I don't see a `username` defined in the info returned by Passport.js: https://www.passportjs.org/reference/normalized-profile/

I also noticed that Immich doesn't require you to manually input each OIDC URL, it just takes an "OIDC config" URL (like https://samples.auth0.com/.well-known/openid-configuration) and figures the rest out - maybe this app could do the same?

### How To Reproduce

1. Set up an Authelia instance. Enable OIDC and add SxncD as a client (following the example above).
2. Try logging in to SxncD via OIDC.

### Relevant log output

```shell

```

### Code of Conduct

- [x] I agree to follow this project's Code of Conduct

Contributor guide

Open the contributing guide

Research direction

Start with http/views/include/header.ejs at the failing username.charAt call, then trace the OIDC profile handling and compare it with Passport.js's normalized profile documentation. Reproduce the Authelia login using the listed environment variables; done means the authenticated dashboard renders without the null-profile error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
authentication, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.