mirror of
https://github.com/google/nomulus.git
synced 2025-05-17 09:57:17 +02:00
Add request/auth package to Nomulus release
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=147087621
This commit is contained in:
parent
c41f5bb31c
commit
dc66cef8ae
13 changed files with 808 additions and 1 deletions
67
java/google/registry/request/auth/Auth.java
Normal file
67
java/google/registry/request/auth/Auth.java
Normal file
|
@ -0,0 +1,67 @@
|
|||
// Copyright 2017 The Nomulus Authors. All Rights Reserved.
|
||||
//
|
||||
// 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 google.registry.request.auth;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/** Annotation used to configure authentication settings for Actions. */
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface Auth {
|
||||
|
||||
/** Available methods for authentication. */
|
||||
public enum AuthMethod {
|
||||
|
||||
/** App Engine internal authentication. Must always be provided as the first method. */
|
||||
INTERNAL,
|
||||
|
||||
/** Authentication methods suitable for API-style access, such as OAuth 2. */
|
||||
API,
|
||||
|
||||
/** Legacy authentication using cookie-based App Engine Users API. Must come last if present. */
|
||||
LEGACY
|
||||
}
|
||||
|
||||
/** User authorization policy options. */
|
||||
public enum UserPolicy {
|
||||
|
||||
/** This action ignores end users; the only configured auth method must be INTERNAL. */
|
||||
IGNORED,
|
||||
|
||||
/** No user policy is enforced; anyone can access this action. */
|
||||
PUBLIC,
|
||||
|
||||
/**
|
||||
* If there is a user, it must be an admin, as determined by isUserAdmin().
|
||||
*
|
||||
* <p>Note that, according to App Engine, anybody with access to the app in the GCP Console,
|
||||
* including editors and viewers, is an admin.
|
||||
*/
|
||||
ADMIN
|
||||
}
|
||||
|
||||
/** Enabled authentication methods for this action. */
|
||||
AuthMethod[] methods() default { AuthMethod.INTERNAL };
|
||||
|
||||
/** Required minimum level of authentication for this action. */
|
||||
// TODO(mountford) This should probably default to APP eventually.
|
||||
AuthLevel minimumLevel() default AuthLevel.NONE;
|
||||
|
||||
/** Required user authorization policy for this action. */
|
||||
UserPolicy userPolicy() default UserPolicy.IGNORED;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue