Open ID Connect issues and questions #4964
Replies: 6 comments 10 replies
-
Including my previous answer below... The current implementation of auth was designed to cater to a number of different use cases:
It sounds like what you want is the ability for Oqtane to act as a proxy and pass the access token from the Identity Provider to a remote API. This scenario was never implemented which is why you are struggling to get it to work. |
Beta Was this translation helpful? Give feedback.
-
The article at https://www.oqtane.org/blog/!/37/oauth-2-0-and-openid-connect is related to item 3 above - it demonstrates how to use Oqtane to generate a JwT token and validate it in a downstream API. Based on my recollection the AddJwtBearer method has a lot of properties which can be configured based on your specific needs ie. specify ValidateIssuer = false or specify ValidIssuers if you want to include multiple upstream authorities. |
Beta Was this translation helpful? Give feedback.
-
Yes, I could skip issuer validation but I would also have to skip token validation as my api clients can be created ad-hoc, which ends up being a security risk. The only solution is to validate tokens that were issued by my open id server. Do you think a solution for this scenario would ever be implemented in Oqtane, or do I roll my own? Thanks |
Beta Was this translation helpful? Give feedback.
-
Thanks Shaun. |
Beta Was this translation helpful? Give feedback.
-
@Justincale In regards to RemoteServiceBase I believe you are suggesting that if a user had previously authenticated using an IDP that the auth token they received from the IDP should be passed to the downstream API? There is also the case where a user is using local authentication and will have no auth token, and in this case Oqtane could include its own auth token that it generates to send to the downstream API. Does this make sense? The one scenario this does not support is if a user wanted to authenticate remotely against an IDP but wanted to use Oqtane's auth token for downstream APIs (ie. they want to use Oqtane's roles rather than what is defined in the IDP) - not sure if this is an edge case. |
Beta Was this translation helpful? Give feedback.
-
Yes, this is correctJustinOn 18 Jan 2025, at 3:01 am, Shaun Walker ***@***.***> wrote:
@Justincale In regards to RemoteServiceBase I believe you are suggesting that if a user had previously authenticated using an IDP that the auth token they received from the IDP should be passed to the downstream API? There is also the case where a user is using local authentication and will have no auth token, and in this case Oqtane could include its own auth token that it generates to send to the downstream API. Does this make sense? The one scenario this does not support is if a user wanted to authenticate remotely against an IDP but wanted to use Oqtane's auth token for downstream APIs (ie. they want to use Oqtane's roles rather than what is defined in the IDP)
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Apologies for the lengthy question, but i have been playing around with implementing OIDC within Oqtane for an existing downstream API for a few weeks now and am still struggling to get this working. @sbwalker, you may have received a communication from @kevinchalet over at openiddict which is related to the following.
I'll begin by describing my current system and how everything fits together.
I have an existing API which i am attempting to create an Oqtane client (clients) for.
Each client must be able to access the API by retrieving a token from a custom open id connect server (i am currently utilizing openiddict for this). Tokens can be retrieved both before someone has logged in (via a client_credentials call), or after login (via an authorization_code call). I am able to successfully log a user in using Oqtane's built in external login settings/login page etc. This was achieved by following the details of this blog post: https://www.oqtane.org/blog/!/37/oauth-2-0-and-openid-connect
These are the issues i am having:
1: The siteState.AuthorizationToken is only populated after a user logs in, and there doesn't seem to be a way for me to retrieve a token from openiddict via a client_credentials call. I have tried a workaround by utilizing my own HttpClient and manually calling openiddict using client_credentials, but this results in a token issued by my openiddict server, not the Oqtane Implementation, which screws up my API token validation.
2: The example from the above blog post link requires me to register a specific client Issuer and IssuerSigningKey in my API token Validation, such as:
.AddJwtBearer(options => {
options.RequireHttpsMetadata = false;
options.SaveToken = true;
options.TokenValidationParameters = new TokenValidationParameters()
{
ValidateIssuerSigningKey = true,
ValidateIssuer = true,
IssuerSigningKey = new SymmetricSecurityKey(System.Text.Encoding.UTF8.GetBytes("*************************")),
ValidIssuer = "https://localhost:44357",
ValidateAudience = false,
ValidateLifetime = true,
ClockSkew = TimeSpan.FromDays(1)
};
});
This is problematic when i have multiple API Clients (which can be generated by my users programmatically). It seems that this solution has, perhaps, been designed with a single, known client in mind. The way this would usually work is that the token received by the API would be issued by the open id connect server and would either use a secret that both the API and ID server know, or would use introspection to call the ID server and validate the token that way.
So, as it stands, i am either able to configure my API to receive tokens that were issued by openiddict via a client_credentials call (which are validated by using either a secret shared between the API and openiddict, or introspection), or configure my API to receive tokens from the Oqtane client which are validated using the secret shared between the API and Oqtane. What i 'believe' i need is for the access token retrieved from openiddict as part of the authorization_code flow to be passed directly on to my API (as it is when using client_credentials), where i can introspect or decode it (but, again, my knowledge on this is limited). If this is achievable, i am happy to maintain my own HttpClient for client_credential calls (although if this could be baked into the existing RemoteServiceBase that would also be good).
Any help or advice would be really appreciated, and happy new year. :)
Beta Was this translation helpful? Give feedback.
All reactions