Skip to content

Commit 029c6fb

Browse files
committed
Add OIDC Auth provider config class (#397)
Adds OIDC provider config class and base class. This is part of adding multi-tenancy support (see issue #332).
1 parent 4d13b23 commit 029c6fb

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

src/main/java/com/google/firebase/auth/AuthProviderConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ public T setDisplayName(String displayName) {
102102
*
103103
* @param enabled a boolean indicating whether the user can sign in with the provider
104104
*/
105-
public T setEnabled(boolean enabled) {
105+
public CreateRequest setEnabled(boolean enabled) {
106106
properties.put("enabled", enabled);
107-
return getThis();
107+
return this;
108108
}
109109

110110
Map<String, Object> getProperties() {

src/main/java/com/google/firebase/auth/OidcProviderConfig.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import com.google.api.client.util.Key;
2222
import com.google.common.base.Strings;
2323
import com.google.common.collect.ImmutableMap;
24+
import java.net.MalformedURLException;
25+
import java.net.URL;
2426
import java.util.HashMap;
2527
import java.util.Map;
2628

@@ -80,6 +82,11 @@ public CreateRequest setClientId(String clientId) {
8082
*/
8183
public CreateRequest setIssuer(String issuer) {
8284
checkArgument(!Strings.isNullOrEmpty(issuer), "issuer must not be null or empty");
85+
try {
86+
new URL(issuer);
87+
} catch (MalformedURLException e) {
88+
throw new IllegalArgumentException(issuer + " is a malformed URL", e);
89+
}
8390
properties.put("issuer", issuer);
8491
return this;
8592
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright 2020 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.firebase.auth;
18+
19+
import org.junit.Test;
20+
21+
public class OidcProviderConfigTest {
22+
@Test(expected = IllegalArgumentException.class)
23+
public void testInvalidIssuerUrl() {
24+
new OidcProviderConfig.CreateRequest().setIssuer("not a valid url");
25+
}
26+
}

0 commit comments

Comments
 (0)