-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add support for Sub claim (default claim is email). Sub or emai…
…l could be used as id for acls
- Loading branch information
Showing
17 changed files
with
255 additions
and
51 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
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
45 changes: 45 additions & 0 deletions
45
src/main/java/io/okdp/spark/authc/provider/IdentityProvider.java
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,45 @@ | ||
/* | ||
* Copyright 2024 tosit.io | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.okdp.spark.authc.provider; | ||
|
||
import com.fasterxml.jackson.annotation.JsonSubTypes; | ||
import com.fasterxml.jackson.annotation.JsonTypeInfo; | ||
import io.okdp.spark.authc.model.UserInfo; | ||
import io.okdp.spark.authc.provider.impl.EmailIdentityProvider; | ||
import io.okdp.spark.authc.provider.impl.SubIdentityProvider; | ||
|
||
@JsonTypeInfo( | ||
include = JsonTypeInfo.As.PROPERTY, | ||
use = JsonTypeInfo.Id.NAME, | ||
property = "type", | ||
defaultImpl = EmailIdentityProvider.class) | ||
@JsonSubTypes({ | ||
@JsonSubTypes.Type(value = EmailIdentityProvider.class, name = "email"), | ||
@JsonSubTypes.Type(value = SubIdentityProvider.class, name = "sub") | ||
}) | ||
|
||
/** Each concrete Identity provider should implement this interface */ | ||
public interface IdentityProvider { | ||
|
||
/** | ||
* Extract the id form the userInfo ({@link UserInfo}) | ||
* | ||
* @param UserInfo the userInfo extracted from the user's access token | ||
* @return the id as a ({@link String}) | ||
*/ | ||
String extractId(UserInfo userInfo); | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/io/okdp/spark/authc/provider/IdentityProviderFactory.java
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,39 @@ | ||
/* | ||
* Copyright 2024 tosit.io | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.okdp.spark.authc.provider; | ||
|
||
import io.okdp.spark.authc.exception.OidcClientException; | ||
import java.lang.reflect.InvocationTargetException; | ||
|
||
public class IdentityProviderFactory { | ||
public static IdentityProvider from(String provider) throws OidcClientException { | ||
try { | ||
return (IdentityProvider) | ||
Class.forName("io.okdp.spark.authc.provider.impl." + provider + "IdentityProvider") | ||
.getDeclaredConstructor() | ||
.newInstance(); | ||
} catch (InstantiationException | ||
| IllegalAccessException | ||
| IllegalArgumentException | ||
| InvocationTargetException | ||
| NoSuchMethodException | ||
| SecurityException | ||
| ClassNotFoundException e) { | ||
throw new OidcClientException("ID provider not found", e); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.