Giter Club home page Giter Club logo

Comments (3)

olivergondza avatar olivergondza commented on June 11, 2024

Here are some tips:

  • Try avoiding .scopeToDomain(identifier), you are passing the domain already as third argument to credentials method.
  • Turn on wire logging (OSFactory.enableHttpLoggingFilter(true)) and compare the payload sent by openstack4j.

from openstack4j.

sami-coder avatar sami-coder commented on June 11, 2024

Aqui estão algumas dicas:

  • Tente evitar .scopeToDomain(identifier), você já está passando o domínio como terceiro argumento para o credentialsmétodo.
  • Ligue o wire logging ( OSFactory.enableHttpLoggingFilter(true)) e compare a carga enviada pelo openstack4j.

Hi,
I removed the .scopetoDomain() and am getting a 403 Forbidden.

Here is the code error:

2020-10-06 16:56:30.644  INFO 5340 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2020-10-06 16:56:30.655  INFO 5340 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 11 ms
Data ===================>RegisterDataRequestDTO(registerInfoRequestDTO=RegisterInfoRequestDTO(identifier=123, name=test123, secret=12321, email=123213, isAdmin=false))
2020-10-06 16:56:32.103 ERROR 5340 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is ClientResponseException{message=You are not authorized to perform the requested action: identity:list_domains., status=403, status-code=FORBIDDEN, X-Openstack-Request-Id=req-1304fcdf-9ae6-4e66-8442-000a117eeff4}] with root cause

org.openstack4j.api.exceptions.ClientResponseException: You are not authorized to perform the requested action: identity:list_domains.
	at org.openstack4j.api.exceptions.ResponseException.mapException(ResponseException.java:84) ~[openstack4j-3.8-withdeps.jar:na]

Where do I enable wire logging?

My code:

public class OpenStackAuth {
public static OSClientV3 getOsClientV3() {
    return OSFactory.builderV3()
        .endpoint("http://xxx.xxx.xxx.xx/5000/v3")
        .credentials("admin", "admin1234", Identifier.byId("default"))
        .authenticate();
  }
}
@Api(value="Manager Servers")
@RestController
@RequestMapping("/identities")
public class IdentityController {

    @CrossOrigin
    @PostMapping("/users/register")
    public UserDataResponseDTO register(@RequestBody RegisterDataRequestDTO registerDataRequestDTO) {
        System.out.println("Data ===================>" + registerDataRequestDTO);

        Objects.requireNonNull(registerDataRequestDTO, "registerDataRequestDTO must be not null.");

        OSClientV3 osClientV3 = getOsClientV3();

        Domain domain = osClientV3.identity().domains()
                .getByName(registerDataRequestDTO.getRegisterInfoRequestDTO().getIdentifier()).stream()
                .findAny()
                .orElse(null);

        if (Objects.isNull(domain)) {

            domain = osClientV3.identity().domains()
                    .create(Builders.domain().enabled(true)
                            .name(registerDataRequestDTO.getRegisterInfoRequestDTO().getIdentifier())
                            .build());
        }

        Project project = new KeystoneProject().toBuilder().enabled(true).domainId(domain.getId())
                .name(registerDataRequestDTO.getRegisterInfoRequestDTO().getName()).build();

        project = osClientV3.identity().projects().create(project);

        User user = osClientV3.identity().users().create(Builders.user()
                .domainId(domain.getId())
                .name(registerDataRequestDTO.getRegisterInfoRequestDTO().getName())
                .defaultProjectId(project.getId())
                .password(
                        registerDataRequestDTO.getRegisterInfoRequestDTO().getSecret())
                .email(registerDataRequestDTO.getRegisterInfoRequestDTO().getEmail())
                .enabled(true)
                .defaultProjectId(project.getId())
                .build());

        osClientV3.compute().keypairs()
                .create(registerDataRequestDTO.getRegisterInfoRequestDTO().getIdentifier(), null);

        return UserDataResponseDTO.builder().userID(user.getId()).domainID(domain.getId())
                .name(user.getName()).build();
    }

}

from openstack4j.

olivergondza avatar olivergondza commented on June 11, 2024

Call OSFactory.enableHttpLoggingFilter(true) to get the wire logging enabled. Note this is specific to http controller, so the log format and even support might vary.

from openstack4j.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.