-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial declaration of OAuth and OIDC plugin and validator with unimp… #1276
base: activemq-6.1.x
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# OAuth and OIDC Implementation for ActiveMQ | ||
|
||
## Overview | ||
This document outlines the plan to implement OAuth and OIDC authentication for ActiveMQ. The implementation will be done in a maxiumum of four stages: | ||
1. Initial declaration of changes and setup. | ||
2. Implementation of OAuth and OIDC methods. | ||
3. Adding unit and integration tests. | ||
4. Implementing logging for OAuth and OIDC operations. | ||
|
||
## Plugin configuration in the activemq.xml file | ||
|
||
<plugins> | ||
<bean id="oidcAuthenticationPlugin" class="org.apache.activemq.security.OIDCAuthenticationPlugin"> | ||
<property name="clientId" value="YOUR_COMPANY_CLIENT_ID"/> | ||
<property name="clientSecret" value="YOUR_COMPANY_CLIENT_SECRET"/> | ||
<property name="oidcServerUrl" value="https://oidc-server.com"/> | ||
<property name="oidcIssuer" value="https://oidc-issuer.com"/> | ||
</bean> | ||
</plugins> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# OAuth and OIDC Implementation for ActiveMQ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. bak file should not be part of the PR. Please remove this one. |
||
|
||
## Overview | ||
This document outlines the plan to implement OAuth and OIDC authentication for ActiveMQ. The implementation will be done in a maxiumum of four stages: | ||
1. Initial declaration of changes and setup. | ||
2. Implementation of OAuth and OIDC methods. | ||
3. Adding unit and integration tests. | ||
4. Implementing logging for OAuth and OIDC operations. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,7 +50,8 @@ | |
<groupId>jakarta.annotation</groupId> | ||
<artifactId>jakarta.annotation-api</artifactId> | ||
</dependency> | ||
|
||
|
||
|
||
<!-- =============================== --> | ||
<!-- Optional Dependencies --> | ||
<!-- =============================== --> | ||
|
@@ -67,6 +68,23 @@ | |
<optional>true</optional> | ||
</dependency> | ||
|
||
<!-- =============================== --> | ||
<!-- oAuth and OIDC Dependencies --> | ||
<!-- Nimbus JOSE + JWT dependencies --> | ||
<!-- =============================== --> | ||
|
||
<dependency> | ||
<groupId>com.nimbusds</groupId> | ||
<artifactId>oauth2-oidc-sdk</artifactId> | ||
<version>9.15</version> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
</dependency> | ||
<dependency> | ||
<groupId>com.nimbusds</groupId> | ||
<artifactId>nimbus-jose-jwt</artifactId> | ||
<version>9.40</version> | ||
</dependency> | ||
|
||
|
||
<!-- =============================== --> | ||
<!-- Testing Dependencies --> | ||
<!-- =============================== --> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.apache.activemq.security; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ASF header is missing here. |
||
|
||
public class OAuthValidator { | ||
private String clientId; | ||
private String clientSecret; | ||
private String oidcServerUrl; | ||
private String oidcIssuer; | ||
|
||
public OAuthValidator(String clientId, String clientSecret, String oidcServerUrl, String oidcIssuer) { | ||
this.clientId = clientId; | ||
this.clientSecret = clientSecret; | ||
this.oidcServerUrl = oidcServerUrl; | ||
this.oidcIssuer = oidcIssuer; | ||
} | ||
|
||
public void initialize() { | ||
throw new UnsupportedOperationException("Method not implemented yet"); | ||
} | ||
|
||
public boolean validateToken(String token) { | ||
throw new UnsupportedOperationException("Method not implemented yet"); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package org.apache.activemq.security; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ASF header is missing here. |
||
|
||
import org.apache.activemq.broker.Broker; | ||
import org.apache.activemq.broker.BrokerPlugin; | ||
import org.apache.activemq.broker.BrokerPluginSupport; | ||
import org.apache.activemq.command.ConnectionInfo; | ||
import org.apache.activemq.security.OIDCSecurityContext; | ||
|
||
public class OIDCAuthenticationPlugin implements BrokerPlugin { | ||
private String clientId; | ||
private String clientSecret; | ||
private String oidcServerUrl; | ||
private String oidcIssuer; | ||
|
||
@Override | ||
public Broker installPlugin(Broker broker) { | ||
return new OIDCBroker(broker); | ||
} | ||
|
||
private class OIDCBroker extends BrokerPluginSupport { | ||
private final Broker next; | ||
|
||
public OIDCBroker(Broker next) { | ||
this.next = next; | ||
} | ||
|
||
@Override | ||
public void addConnection(org.apache.activemq.broker.ConnectionContext context, ConnectionInfo info) throws Exception { | ||
throw new UnsupportedOperationException("Method not implemented yet"); | ||
} | ||
|
||
private OIDCSecurityContext authenticate(String token) { | ||
throw new UnsupportedOperationException("Method not implemented yet"); | ||
} | ||
} | ||
|
||
public String getClientId() { | ||
return clientId; | ||
} | ||
|
||
public void setClientId(String clientId) { | ||
this.clientId = clientId; | ||
} | ||
|
||
public String getClientSecret() { | ||
return clientSecret; | ||
} | ||
|
||
public void setClientSecret(String clientSecret) { | ||
this.clientSecret = clientSecret; | ||
} | ||
|
||
public String getOidcServerUrl() { | ||
return oidcServerUrl; | ||
} | ||
|
||
public void setOidcServerUrl(String oidcServerUrl) { | ||
this.oidcServerUrl = oidcServerUrl; | ||
} | ||
|
||
public String getOidcIssuer() { | ||
return oidcIssuer; | ||
} | ||
|
||
public void setOidcIssuer(String oidcIssuer) { | ||
this.oidcIssuer = oidcIssuer; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.apache.activemq.security; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ASF header is missing here. |
||
|
||
import java.security.Principal; | ||
import java.util.Set; | ||
|
||
public class OIDCSecurityContext extends SecurityContext { | ||
private final Set<Principal> principals; | ||
|
||
public OIDCSecurityContext(String userName, Set<Principal> principals) { | ||
super(userName); | ||
this.principals = principals; | ||
} | ||
|
||
@Override | ||
public Set<Principal> getPrincipals() { | ||
return principals; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,9 @@ | |
<transportConnectors> | ||
<transportConnector name="openwire" uri="tcp://localhost:61616" /> | ||
<transportConnector name="stomp" uri="stomp://localhost:61613" /> | ||
<!-- Add Jetty Transport Connector for Web Console --> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's not correct: the jetty transport is not for the webconsole. Jetty transport is for http transport connect. |
||
<transportConnector name="jetty" uri="http://localhost:8161"/> | ||
|
||
</transportConnectors> | ||
|
||
</broker> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it makes sense to add a specific README here. Better to add in the doc section.
Also the ASF header is missing.